summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2020-07-10 15:35:17 -0700
committerGitHub <noreply@github.com>2020-07-10 15:35:17 -0700
commit88da95573d600f2af8538c3c5a29459a1146127c (patch)
tree9ebe2293d6c62fde23c1e023a613d929ab5065e8
parent7e9b3dfa40f0297bdb005f6c802443ebb3b8cad1 (diff)
Always Update Git information when rebuilding (#4696)
Commit 61734b41b7b96e7e7cbf46021a357d840d64b42e changed the way some of our source files are generated. However, the change meant that once `git_versioninfo.cpp` was generated, it was never updated again: The custom command for `git_versioninfo.cpp` has no dependencies, so CMake does not rebuild it unless the output file is missing [0]. This commit reverts the change to our `gen-gitinfo` target and adds `git_versioninfo.cpp` to `BYPRODUCTS` for the target to indicate that the file may have changed. I am not sure if there is a better solution because we actually have to run `GitInfo.cmake` to see if there have been any changes in the Git information. Introducing a dependency on all source files is not sufficient because other files or just the branch name may change. Note: The original solution only updates the timestamp of `git_versioninfo.cpp` if its contents actually change (`GitInfo.cmake` uses `configure_file()` to generate `git_versioninfo.cpp`, which only updates the timestamp when the contents changed [1]), so we don't do any unnecessary work. [0] https://cmake.org/cmake/help/latest/command/add_custom_command.html [1] https://cmake.org/cmake/help/latest/command/configure_file.html Signed-off-by: Andrew V. Jones <andrew.jones@vector.com> Co-authored-by: Andrew V. Jones <andrew.jones@vector.com>
-rw-r--r--src/base/CMakeLists.txt12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt
index 96b188238..a34716fea 100644
--- a/src/base/CMakeLists.txt
+++ b/src/base/CMakeLists.txt
@@ -4,17 +4,9 @@
find_package(Git)
configure_file(GitInfo.cmake.in GitInfo.cmake @ONLY)
-add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/git_versioninfo.cpp
- COMMAND ${CMAKE_COMMAND} -DGIT_FOUND=${GIT_FOUND} -P GitInfo.cmake
-)
-set_source_files_properties(
- ${CMAKE_CURRENT_BINARY_DIR}/git_versioninfo.cpp
- PROPERTIES GENERATED TRUE
-)
add_custom_target(gen-gitinfo
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/git_versioninfo.cpp
-)
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/git_versioninfo.cpp
+ COMMAND ${CMAKE_COMMAND} -DGIT_FOUND=${GIT_FOUND} -P GitInfo.cmake)
#-----------------------------------------------------------------------------#
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback