Move non-git source version info to subdirectory

In the case where source is not a git repository, an empty repository info
file is created at configure time.  The git-rev.h file is placed in the src/
subdirectory.  If the code to create it is in the top-level CMakeLists.txt,
the src/ directory does not yet exist and it fails to create the file.
Move the git-ver.h file creation code to the src/CMakeLists.txt.
This commit is contained in:
Mark Dewing 2017-01-18 23:02:22 -06:00
parent b7afe0b0a1
commit 1fba9520cc
2 changed files with 13 additions and 15 deletions

View File

@ -271,21 +271,6 @@ IF (EXISTS "${PROJECT_SOURCE_DIR}/.git")
SET(IS_GIT_PROJECT true)
ENDIF()
SET(GITREV_BARE_FILE git-rev.h)
SET(GITREV_BARE_TMP git-rev-tmp.h)
SET(GITREV_FILE ${CMAKE_BINARY_DIR}/src/${GITREV_BARE_FILE})
SET(GITREV_TMP ${CMAKE_BINARY_DIR}/src/${GITREV_BARE_TMP})
IF (NOT (GIT_FOUND AND IS_GIT_PROJECT))
# Output a blank git version file
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E remove ${GITREV_FILE}
COMMAND ${CMAKE_COMMAND} -E touch ${GITREV_FILE}
COMMAND ${CMAKE_COMMAND} -E remove ${GITREV_TMP}
COMMAND ${CMAKE_COMMAND} -E touch ${GITREV_TMP}
)
ENDIF()
######################################################
#COMPILER choose one of the cmake files to customize the compiler options

View File

@ -20,6 +20,11 @@
CONFIGURE_FILE(${qmcpack_SOURCE_DIR}/src/config.h.cmake.in
${qmcpack_BINARY_DIR}/src/config.h)
SET(GITREV_BARE_FILE git-rev.h)
SET(GITREV_BARE_TMP git-rev-tmp.h)
SET(GITREV_FILE ${CMAKE_BINARY_DIR}/src/${GITREV_BARE_FILE})
SET(GITREV_TMP ${CMAKE_BINARY_DIR}/src/${GITREV_BARE_TMP})
IF (GIT_FOUND AND IS_GIT_PROJECT)
# The following custom command picks up changes to the git revision information
# every time the project is rebuilt. Even if the repositiory is updated (git pull)
@ -49,6 +54,14 @@ IF (GIT_FOUND AND IS_GIT_PROJECT)
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM
)
ELSE()
# Output a blank git version file
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E remove ${GITREV_FILE}
COMMAND ${CMAKE_COMMAND} -E touch ${GITREV_FILE}
COMMAND ${CMAKE_COMMAND} -E remove ${GITREV_TMP}
COMMAND ${CMAKE_COMMAND} -E touch ${GITREV_TMP}
)
ENDIF()