libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

git_version.cmake (1110B)


      1 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
      2 #
      3 # Use of this source code is governed by a BSD-style
      4 # license that can be found in the LICENSE file.
      5 
      6 # git_version.cmake is a script which creates tools_version_git.h in the build
      7 # directory if building from a git repository.
      8 find_package(Git QUIET)
      9 
     10 # Check that this script was invoked with the necessary arguments.
     11 if(NOT IS_DIRECTORY "${JPEGXL_ROOT_DIR}")
     12   message(FATAL_ERROR "JPEGXL_ROOT_DIR is invalid")
     13 endif()
     14 
     15 execute_process(
     16   COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
     17   OUTPUT_VARIABLE GIT_REV
     18   WORKING_DIRECTORY "${JPEGXL_ROOT_DIR}"
     19   OUTPUT_STRIP_TRAILING_WHITESPACE
     20   ERROR_QUIET)
     21 
     22 # The define line in the file.
     23 set(JPEGXL_VERSION_DEFINE "#define JPEGXL_VERSION \"${GIT_REV}\"\n")
     24 
     25 # Update the header file only if needed.
     26 if(EXISTS "${DST}")
     27   file(READ "${DST}" ORIG_DST)
     28   if(NOT ORIG_DST STREQUAL JPEGXL_VERSION_DEFINE)
     29     message(STATUS "Changing JPEGXL_VERSION to ${GIT_REV}")
     30     file(WRITE "${DST}" "${JPEGXL_VERSION_DEFINE}")
     31   endif()
     32 else()
     33   file(WRITE "${DST}" "${JPEGXL_VERSION_DEFINE}")
     34 endif()