summaryrefslogtreecommitdiff
path: root/scripts/gen-build-info-cpp.cmake
diff options
context:
space:
mode:
authorbandoti <141645996+bandoti@users.noreply.github.com>2023-11-27 15:25:42 -0400
committerGitHub <noreply@github.com>2023-11-27 21:25:42 +0200
commitb38a16dfcff88d547f78f52d1bea31b84a05aff7 (patch)
tree491d5ab5cebdd953bbcfba3552a8ab1ab2d9ebfd /scripts/gen-build-info-cpp.cmake
parent0dab8cd7cca7e1bc3550dcb4797b9062cdbb1ebd (diff)
cmake : fix issue with version info not getting baked into LlamaConfig.cmake (#3970)
* Split CPP generation from build-info query * Remove blank lines * Add BUILD_SHARED_LIBS option
Diffstat (limited to 'scripts/gen-build-info-cpp.cmake')
-rw-r--r--scripts/gen-build-info-cpp.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/gen-build-info-cpp.cmake b/scripts/gen-build-info-cpp.cmake
new file mode 100644
index 00000000..d8933892
--- /dev/null
+++ b/scripts/gen-build-info-cpp.cmake
@@ -0,0 +1,24 @@
+include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/build-info.cmake)
+
+set(TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/common/build-info.cpp.in")
+set(OUTPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/common/build-info.cpp")
+
+# Only write the build info if it changed
+if(EXISTS ${OUTPUT_FILE})
+ file(READ ${OUTPUT_FILE} CONTENTS)
+ string(REGEX MATCH "LLAMA_COMMIT = \"([^\"]*)\";" _ ${CONTENTS})
+ set(OLD_COMMIT ${CMAKE_MATCH_1})
+ string(REGEX MATCH "LLAMA_COMPILER = \"([^\"]*)\";" _ ${CONTENTS})
+ set(OLD_COMPILER ${CMAKE_MATCH_1})
+ string(REGEX MATCH "LLAMA_BUILD_TARGET = \"([^\"]*)\";" _ ${CONTENTS})
+ set(OLD_TARGET ${CMAKE_MATCH_1})
+ if (
+ NOT OLD_COMMIT STREQUAL BUILD_COMMIT OR
+ NOT OLD_COMPILER STREQUAL BUILD_COMPILER OR
+ NOT OLD_TARGET STREQUAL BUILD_TARGET
+ )
+ configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE})
+ endif()
+else()
+ configure_file(${TEMPLATE_FILE} ${OUTPUT_FILE})
+endif()