diff --git a/cmake/gitcommit.cmake b/cmake/gitcommit.cmake index 30d1dab1..37358208 100644 --- a/cmake/gitcommit.cmake +++ b/cmake/gitcommit.cmake @@ -3,19 +3,19 @@ set(DEFAULT_COMMIT "unavailable") set(commit "${DEFAULT_COMMIT}") +set(TOPLEVEL_SOURCE_DIR ${CMAKE_SOURCE_DIR}) + execute_process( - COMMAND ${GIT_EXECUTABLE} -C ${TOPLEVEL_SOURCE_DIR} - rev-parse --show-toplevel + COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel OUTPUT_VARIABLE git_worktree ERROR_VARIABLE stderr RESULT_VARIABLE status) string(REGEX REPLACE "\n$" "" git_worktree "${git_worktree}") if(status EQUAL 0) - if(git_worktree STREQUAL TOPLEVEL_SOURCE_DIR) + if(git_worktree STREQUAL CMAKE_SOURCE_DIR) execute_process( - COMMAND ${GIT_EXECUTABLE} -C ${TOPLEVEL_SOURCE_DIR} - rev-parse HEAD + COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE git_commit ERROR_VARIABLE stderr RESULT_VARIABLE status) @@ -28,7 +28,7 @@ if(status EQUAL 0) endif() else() if(commit STREQUAL "unavailable") - message("Unable to determine git commit: top-level source dir ${TOPLEVEL_SOURCE_DIR} is not the root of a repository") + message("Unable to determine git commit: top-level source dir ${CMAKE_SOURCE_DIR} is not the root of a repository") endif() endif() else() diff --git a/cmake/setup.cmake b/cmake/setup.cmake index 8b64acc8..c0965c49 100644 --- a/cmake/setup.cmake +++ b/cmake/setup.cmake @@ -42,7 +42,6 @@ add_custom_target(check_git_commit BYPRODUCTS ${INTERMEDIATE_COMMIT_C} COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} - -DTOPLEVEL_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DOUTPUT_FILE=${INTERMEDIATE_COMMIT_C} -DOUTPUT_TYPE=header -P ${CMAKE_SOURCE_DIR}/cmake/gitcommit.cmake diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 8404b994..f7fcb4e2 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -21,7 +21,6 @@ if(HALIBUT AND PERL_EXECUTABLE) BYPRODUCTS ${INTERMEDIATE_VERSION_BUT} COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} - -DTOPLEVEL_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DOUTPUT_FILE=${INTERMEDIATE_VERSION_BUT} -DOUTPUT_TYPE=halibut -P ${CMAKE_SOURCE_DIR}/cmake/gitcommit.cmake