From e3fbcfc085411475cb07da84308f03dbd3405e5e Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 28 Jan 2023 16:54:36 +0100 Subject: Commits will now trigger version-files regeneration during build --- cmake/modules/AddVersionFile.cmake | 15 +++++++++++++++ cmake/modules/GitRevParse.cmake | 14 -------------- cmake/modules/generate_version_file.cmake | 12 ++++++++++++ 3 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 cmake/modules/AddVersionFile.cmake delete mode 100644 cmake/modules/GitRevParse.cmake create mode 100644 cmake/modules/generate_version_file.cmake (limited to 'cmake/modules') diff --git a/cmake/modules/AddVersionFile.cmake b/cmake/modules/AddVersionFile.cmake new file mode 100644 index 0000000..1cce0b9 --- /dev/null +++ b/cmake/modules/AddVersionFile.cmake @@ -0,0 +1,15 @@ +set(ADD_VERSION_FILE_DIR "${CMAKE_CURRENT_LIST_DIR}") + +function(add_version_file OUTPUT TEMPLATE) + add_custom_target( + ${OUTPUT} + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND + cmake + -DOUTPUT='${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT}' + -DTEMPLATE='${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE}' + -P "${ADD_VERSION_FILE_DIR}/generate_version_file.cmake" + ) +endfunction() diff --git a/cmake/modules/GitRevParse.cmake b/cmake/modules/GitRevParse.cmake deleted file mode 100644 index 9005d65..0000000 --- a/cmake/modules/GitRevParse.cmake +++ /dev/null @@ -1,14 +0,0 @@ -function(git_rev_parse VAR) - execute_process( - COMMAND git rev-parse --short HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE PARSE_RESULT - OUTPUT_VARIABLE PARSE_OUTPUT - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(NOT PARSE_RESULT) - set(${VAR} ${PARSE_OUTPUT} PARENT_SCOPE) - else() - set(${VAR} "Unknown" PARENT_SCOPE) - endif() -endfunction() diff --git a/cmake/modules/generate_version_file.cmake b/cmake/modules/generate_version_file.cmake new file mode 100644 index 0000000..4479855 --- /dev/null +++ b/cmake/modules/generate_version_file.cmake @@ -0,0 +1,12 @@ +execute_process( + COMMAND git rev-parse --short HEAD + RESULT_VARIABLE PARSE_RESULT + OUTPUT_VARIABLE PARSE_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if(NOT PARSE_RESULT) + set(HASH "${PARSE_OUTPUT}") +else() + set(HASH "NOTFOUND") +endif() +configure_file("${TEMPLATE}" "${OUTPUT}" @ONLY) -- cgit v1.1