From 57cb84d321b9874bd84ac74df75215ed174498ee Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 28 Jan 2023 20:07:34 +0100 Subject: Added a sentence about reconfiguration of the cmake in version --- lets_not_store_versions_in_versioned_files.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lets_not_store_versions_in_versioned_files.html') diff --git a/lets_not_store_versions_in_versioned_files.html b/lets_not_store_versions_in_versioned_files.html index dc6479b..8872383 100644 --- a/lets_not_store_versions_in_versioned_files.html +++ b/lets_not_store_versions_in_versioned_files.html @@ -85,13 +85,15 @@ git_describe(VERSION) configure_file(version.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/version.cpp @ONLY) target_sources(version-print PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/version.cpp) -

Now, CMake does not support this out-of-box sadly, so you need to implement git_describe yourself or get -an external module for it. There is one in +

Now, CMake does not support this out-of-box sadly, so you need to implement git_describe (or similar) +yourself or get an external module for it. There is one in Ryan A. Pavlik's repository and I have implemented one for Starshatter at some point. -They are rather easy and fun to write (altough there is a variety of edge cases), but it's still a bit shame that they -are not part of the core CMake. +They are rather easy and fun to write (although there is a variety of edge cases), but it's still a bit shame that they +are not part of the core CMake. Now, note that one of these "edge cases" might be triggering the reconfiguration of the +output file as configure_file is configuration-time action and changes to the output of the +git_describe may or may not be properly detected. Be wary.

Alternatively, you can consider using a define to, well, define the version number. I use this approach with separate file that defines the variable for the sake of dependency checks and recompilation.

Final Thoughts

-- cgit v1.1