Back to home page

EIC code displayed by LXR

 
 

    


Warning, /jana2/cmake/MakeJVersionH.cmake is written in an unsupported language. File is not indexed.

0001 
0002 
0003 # Generate JVersion.h
0004 
0005 # Force CMake to reconfigure itself whenever git's HEAD pointer changes
0006 # Note that HEAD usually points to the branch name, not the commit hash.
0007 # This will correctly force CMake to reconfigure itself when you check out an existing branch, tag, or commit.
0008 # It will not force CMake to reconfigure if you are adding successive commits to a branch.
0009 # For that, you have to manually reconfigure CMake.
0010 set_property(
0011         DIRECTORY
0012         APPEND
0013         PROPERTY CMAKE_CONFIGURE_DEPENDS
0014         ${CMAKE_SOURCE_DIR}/.git/HEAD
0015 )
0016 
0017 execute_process(
0018         COMMAND git log -1 --format=%H
0019         WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
0020         RESULT_VARIABLE JVERSION_GIT_RESULT
0021         OUTPUT_VARIABLE JVERSION_COMMIT_HASH
0022         ERROR_QUIET
0023         OUTPUT_STRIP_TRAILING_WHITESPACE
0024 )
0025 
0026 execute_process(
0027         COMMAND git log -1 --format=%aD
0028         WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
0029         OUTPUT_VARIABLE JVERSION_COMMIT_DATE
0030         ERROR_QUIET
0031         OUTPUT_STRIP_TRAILING_WHITESPACE
0032 )
0033 
0034 execute_process(
0035         COMMAND git show-ref -s v${jana2_VERSION_MAJOR}.${jana2_VERSION_MINOR}.${jana2_VERSION_PATCH}
0036         WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
0037         OUTPUT_VARIABLE JVERSION_RELEASE_COMMIT_HASH
0038         ERROR_QUIET
0039         OUTPUT_STRIP_TRAILING_WHITESPACE
0040 )
0041 
0042 execute_process(
0043         COMMAND git status --porcelain
0044         WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
0045         OUTPUT_VARIABLE JVERSION_MODIFIED_FILES
0046         ERROR_QUIET
0047         OUTPUT_STRIP_TRAILING_WHITESPACE
0048 )
0049 
0050 
0051 # If our call to git log returned a non-zero exit code, we don't have git information and shouldn't pretend we do
0052 if(JVERSION_GIT_RESULT EQUAL 0)
0053     set(JVERSION_UNKNOWN 0)
0054 else()
0055     set(JVERSION_UNKNOWN 1)
0056 endif()
0057 
0058 # We figure out whether we are actually the release commit (according to git) by comparing the commit hashes
0059 if(JVERSION_RELEASE_COMMIT_HASH STREQUAL JVERSION_COMMIT_HASH)
0060     set(JVERSION_RELEASE 1)
0061 else()
0062     set(JVERSION_RELEASE 0)
0063 endif()
0064 
0065 # Even if `git log` indicates we are on the latest release, there might have been some changes
0066 # made on top that haven't been committed yet
0067 #
0068 if(JVERSION_MODIFIED_FILES STREQUAL "")
0069     set(JVERSION_MODIFIED 0)
0070 else()
0071     set(JVERSION_MODIFIED 1)
0072 endif()
0073 
0074 message(STATUS "Generating JVersion.h")
0075 
0076 configure_file(src/libraries/JANA/JVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/libraries/JANA/JVersion.h @ONLY)
0077 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libraries/JANA/JVersion.h DESTINATION include/JANA)