From 58d17e7990e65ae6abdfc1a2d5728c1994148880 Mon Sep 17 00:00:00 2001 From: Jonas Schuhmacher Date: Fri, 13 Dec 2024 13:22:15 +0100 Subject: [PATCH] Refactor versioning system and enhance build metadata. Replaced hardcoded versioning with a dynamic CMake-driven system using `Info.h` to embed version, parallelization, and commit metadata directly into the build. Simplified Python version parsing and renamed `LOGGING_LEVEL` to `POLYHEDRAL_GRAVITY_LOGGING_LEVEL` for consistency. Consolidated version management and improved Git commit hash handling. --- .gitignore | 3 +- CMakeLists.txt | 48 +++++++++---------- README.md | 16 +++---- cmake/git.cmake | 35 +++++++++++--- cmake/version.cmake | 12 ----- docs/quickstart/installation.rst | 2 +- setup.py | 22 ++++----- src/main.cpp | 10 ++-- src/polyhedralGravity/CMakeLists.txt | 2 +- src/polyhedralGravity/Info.h.in | 36 ++++++++++++++ src/polyhedralGravity/Version.h | 29 ----------- .../PolyhedralGravityPython.cpp | 12 +++-- version.cmake | 18 +++++++ 13 files changed, 143 insertions(+), 102 deletions(-) delete mode 100644 cmake/version.cmake create mode 100644 src/polyhedralGravity/Info.h.in delete mode 100644 src/polyhedralGravity/Version.h create mode 100644 version.cmake diff --git a/.gitignore b/.gitignore index faa3a36..4020348 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ cmake-build-* build polyhedral_gravity.egg-info dist -docs/Doxyfile \ No newline at end of file +docs/Doxyfile +src/polyhedralGravity/Info.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 893ac91..4c24e15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Appends the the module path to contain additional CMake modules for this project # and include everything necessary list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) -include(version) -include(git) - -# Set and Print the Version number -polyhedral_gravity_parse_version(POLYHEDRAL_GRAVITY_VERSION) -get_git_commit_hash(POLYHEDRAL_GRAVITY_GIT_HASH) -message(STATUS "Polyhedral Gravity Version ${POLYHEDRAL_GRAVITY_VERSION}") -message(STATUS "Polyhedral Gravity Git Hash ${POLYHEDRAL_GRAVITY_GIT_HASH}") - include(CMakeDependentOption) ##################################### @@ -27,38 +18,30 @@ set(POLYHEDRAL_GRAVITY_PARALLELIZATION "CPP" CACHE STRING "Host parallelization set_property(CACHE POLYHEDRAL_GRAVITY_PARALLELIZATION PROPERTY STRINGS CPP, OMP, TBB) # Set the Logging Level -set(LOGGING_LEVEL_LIST "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF") -set(LOGGING_LEVEL "INFO" CACHE STRING "Set the Logging level, default (INFO), available options: TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF") -set_property(CACHE LOGGING_LEVEL PROPERTY STRINGS ${LOGGING_LEVEL_LIST}) +set(POLYHEDRAL_GRAVITY_LOGGING_LEVEL_LIST "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF") +set(POLYHEDRAL_GRAVITY_LOGGING_LEVEL "INFO" CACHE STRING "Set the Logging level, default (INFO), available options: TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF") +set_property(CACHE POLYHEDRAL_GRAVITY_LOGGING_LEVEL PROPERTY STRINGS ${POLYHEDRAL_GRAVITY_LOGGING_LEVEL_LIST}) # Convert the logging level string to its corresponding number -list(FIND LOGGING_LEVEL_LIST ${LOGGING_LEVEL} LOGGING_LEVEL_INDEX) +list(FIND POLYHEDRAL_GRAVITY_LOGGING_LEVEL_LIST ${POLYHEDRAL_GRAVITY_LOGGING_LEVEL} LOGGING_LEVEL_INDEX) if (${LOGGING_LEVEL_INDEX} EQUAL -1) - message(FATAL_ERROR "Invalid logging level: ${LOGGING_LEVEL}") + message(FATAL_ERROR "Invalid logging level: ${POLYHEDRAL_GRAVITY_LOGGING_LEVEL}") endif () add_compile_definitions(SPDLOG_ACTIVE_LEVEL=${LOGGING_LEVEL_INDEX}) -message(STATUS "Logging level set to ${LOGGING_LEVEL} (=${LOGGING_LEVEL_INDEX})") - -################################### -# What actually to build? - Options -################################### +######################################################### +# What actually to build? - Options, Versions and Output +######################################################### # Build docs option(BUILD_POLYHEDRAL_GRAVITY_DOCS "Builds the documentation (Default: OFF)" OFF) -message(STATUS "BUILD_POLYHEDRAL_GRAVITY_DOCS = ${BUILD_POLYHEDRAL_GRAVITY_DOCS}") # Build C++ executable option(BUILD_POLYHEDRAL_GRAVITY_EXECUTABLE "Builds the C++ executable (Default: ON)" ON) -message(STATUS "BUILD_POLYHEDRAL_GRAVITY_EXECUTABLE = ${BUILD_POLYHEDRAL_GRAVITY_EXECUTABLE}") # Build library (default ON), if the executable or tests are built this forced to ON cmake_dependent_option(BUILD_POLYHEDRAL_GRAVITY_LIBRARY "Builds the library (Default: ON)" ON "NOT BUILD_POLYHEDRAL_GRAVITY_EXECUTABLE AND NOT BUILD_POLYHEDRAL_GRAVITY_TESTS" ON) -message(STATUS "BUILD_POLYHEDRAL_GRAVITY_LIBRARY = ${BUILD_POLYHEDRAL_GRAVITY_LIBRARY}") # Option to build the python interface option(BUILD_POLYHEDRAL_GRAVITY_PYTHON_INTERFACE "Set this to on if the python interface should be built (Default: ON)" ON) -message(STATUS "BUILD_POLYHEDRAL_GRAVITY_PYTHON_INTERFACE = ${BUILD_POLYHEDRAL_GRAVITY_PYTHON_INTERFACE}") # Option to build tests or not option(BUILD_POLYHEDRAL_GRAVITY_TESTS "Set to on if the tests should be built (Default: ON)" ON) -message(STATUS "BUILD_POLYHEDRAL_GRAVITY_TESTS = ${BUILD_POLYHEDRAL_GRAVITY_TESTS}") - IF(_LIBCPP_DISABLE_AVAILABILITY) message(STATUS "Disabling availability macros for libc++") @@ -69,6 +52,21 @@ endif () # Refer to https://github.com/gabime/spdlog/issues/660 add_compile_definitions(FMT_HEADER_ONLY) +include(git) +include(version.cmake) + +message(STATUS "#################################################################") +message(STATUS "Polyhedral Gravity Version ${POLYHEDRAL_GRAVITY_VERSION}") +message(STATUS "Polyhedral Gravity Commit Hash ${POLYHEDRAL_GRAVITY_COMMIT_HASH}") +message(STATUS "Polyhedral Parallelization Backend ${POLYHEDRAL_GRAVITY_PARALLELIZATION}") +message(STATUS "Polyhedral Gravity Logging Level ${POLYHEDRAL_GRAVITY_LOGGING_LEVEL}") +message(STATUS "#################################################################") +message(STATUS "Polyhedral Gravity Documentation ${BUILD_POLYHEDRAL_GRAVITY_DOCS}") +message(STATUS "Polyhedral Gravity Library ${BUILD_POLYHEDRAL_GRAVITY_LIBRARY}") +message(STATUS "Polyhedral Gravity C++ Executable ${BUILD_POLYHEDRAL_GRAVITY_EXECUTABLE}") +message(STATUS "Polyhedral Gravity Python Interface ${BUILD_POLYHEDRAL_GRAVITY_PYTHON_INTERFACE}") +message(STATUS "Polyhedral Gravity Tests ${BUILD_POLYHEDRAL_GRAVITY_TESTS}") +message(STATUS "#################################################################") ####################################################### # Including dependencies needed across multiple targets ####################################################### diff --git a/README.md b/README.md index 706e394..d33be82 100644 --- a/README.md +++ b/README.md @@ -305,16 +305,16 @@ cmake --build . The following options are available: -| Name (Default) | Options | -|-------------------------------------------------:|:--------------------------------------------------------------------------------------------| -| POLYHEDRAL_GRAVITY_PARALLELIZATION (`CPP`) | `CPP` = Serial Execution / `OMP` or `TBB` = Parallel Execution with OpenMP or Intel\'s TBB | -| LOGGING_LEVEL (`INFO`) | `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, `OFF` | -| BUILD_POLYHEDRAL_GRAVITY_DOCS (`OFF`) | Build this documentation | -| BUILD_POLYHEDRAL_GRAVITY_TESTS (`ON`) | Build the Tests | -| BUILD_POLYHEDRAL_GRAVITY_PYTHON_INTERFACE (`ON`) | Build the Python interface | +| Name (Default) | Options | +|-------------------------------------------------------------:|:--------------------------------------------------------------------------------------------| +| POLYHEDRAL_GRAVITY_PARALLELIZATION (`CPP`) | `CPP` = Serial Execution / `OMP` or `TBB` = Parallel Execution with OpenMP or Intel\'s TBB | +| POLYHEDRAL_GRAVITY_LOGGING_LEVEL (`INFO`) | `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, `OFF` | +| BUILD_POLYHEDRAL_GRAVITY_DOCS (`OFF`) | Build this documentation | +| BUILD_POLYHEDRAL_GRAVITY_TESTS (`ON`) | Build the Tests | +| BUILD_POLYHEDRAL_GRAVITY_PYTHON_INTERFACE (`ON`) | Build the Python interface | During testing POLYHEDRAL_GRAVITY_PARALLELIZATION=`TBB` has been the most performant. -It is further not recommend to change the LOGGING_LEVEL to something else than `INFO=2`. +It is further not recommend to change the POLYHEDRAL_GRAVITY_LOGGING_LEVEL to something else than `INFO=2`. The recommended CMake settings using the `TBB` backend would look like this: diff --git a/cmake/git.cmake b/cmake/git.cmake index aec6d4c..d74ba2f 100644 --- a/cmake/git.cmake +++ b/cmake/git.cmake @@ -1,10 +1,9 @@ -function(get_git_commit_hash OUTPUT_VAR) - # Ensure Git is available - find_package(Git QUIET REQUIRED) +find_package(Git QUIET REQUIRED) - # Run a Git command to get the current commit hash +function(get_git_commit_hash OUTPUT_VAR) + # Run a Git command to get the first 8 characters of the current commit hash execute_process( - COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + COMMAND ${GIT_EXECUTABLE} rev-parse --short=8 HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE @@ -17,7 +16,31 @@ function(get_git_commit_hash OUTPUT_VAR) message(WARNING "Failed to retrieve Git commit hash: ${GIT_ERROR}") set(${OUTPUT_VAR} "UNKNOWN" PARENT_SCOPE) else() - # Pass the hash back to the calling scope + # Pass the short hash back to the calling scope set(${OUTPUT_VAR} "${GIT_COMMIT_HASH}" PARENT_SCOPE) endif() +endfunction() + +function(is_git_working_tree_clean OUTPUT_VAR) + # Run a Git command to check if the working tree is clean + execute_process( + COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD -- + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE GIT_STATUS_RESULT + ERROR_VARIABLE GIT_ERROR + ERROR_STRIP_TRAILING_WHITESPACE + ) + + # Check the result of the Git command + if (NOT GIT_ERROR AND GIT_STATUS_RESULT EQUAL 0) + # Working tree is clean + set(${OUTPUT_VAR} TRUE PARENT_SCOPE) + else() + # Working tree has uncommitted changes or an error occurred + set(${OUTPUT_VAR} FALSE PARENT_SCOPE) + + if (GIT_ERROR) + message(WARNING "Error while checking Git working tree: ${GIT_ERROR}") + endif() + endif() endfunction() \ No newline at end of file diff --git a/cmake/version.cmake b/cmake/version.cmake deleted file mode 100644 index 4ed3736..0000000 --- a/cmake/version.cmake +++ /dev/null @@ -1,12 +0,0 @@ -function(polyhedral_gravity_parse_version OUTPUT_VAR) - # Read the content of the given header file - file(READ "${PROJECT_SOURCE_DIR}/src/polyhedralGravity/Version.h" HEADER_CONTENTS) - # Extract the version using regex - string(REGEX MATCH "constexpr std::string_view POLYHEDRAL_GRAVITY_VERSION = \"([0-9]+\\.[0-9]+\\.[0-9]+[a-zA-Z0-9]*)\"" VERSION_MATCH "${HEADER_CONTENTS}") - # Set the output variable to the matched version group - if(CMAKE_MATCH_1) - set(${OUTPUT_VAR} "${CMAKE_MATCH_1}" PARENT_SCOPE) - else() - message(FATAL_ERROR "Failed to parse POLYHEDRAL_GRAVITY_VERSION from '${HEADER_FILE}'") - endif() -endfunction() \ No newline at end of file diff --git a/docs/quickstart/installation.rst b/docs/quickstart/installation.rst index 37d8755..43339a2 100644 --- a/docs/quickstart/installation.rst +++ b/docs/quickstart/installation.rst @@ -91,7 +91,7 @@ The available options are the following: Name (Default) Options ====================================================== ============================================================================================================ POLYHEDRAL_GRAVITY_PARALLELIZATION (:code:`CPP`) :code:`CPP` = Serial Execution / :code:`OMP` or :code:`TBB` = Parallel Execution with OpenMP or Intel's TBB -LOGGING_LEVEL (:code:`INFO`) :code:`TRACE`, :code:`DEBUG`, :code:`INFO`, :code:`WARN`, :code:`ERROR`, :code:`CRITICAL`, :code:`OFF` +POLYHEDRAL_GRAVITY_LOGGING_LEVEL (:code:`INFO`) :code:`TRACE`, :code:`DEBUG`, :code:`INFO`, :code:`WARN`, :code:`ERROR`, :code:`CRITICAL`, :code:`OFF` BUILD_POLYHEDRAL_GRAVITY_DOCS (:code:`OFF`) Build this documentation BUILD_POLYHEDRAL_GRAVITY_TESTS (:code:`ON`) Build the Tests BUILD_POLYHEDRAL_GRAVITY_PYTHON_INTERFACE (:code:`ON`) Build the Python interface diff --git a/setup.py b/setup.py index 736081c..46d70cb 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ # Modify to change the parallelization (Default value: TBB) "POLYHEDRAL_GRAVITY_PARALLELIZATION": "TBB", # Default value (INFO=2) - "LOGGING_LEVEL": "INFO", + "POLYHEDRAL_GRAVITY_LOGGING_LEVEL": "INFO", # Not required for the python interface (--> OFF) "BUILD_POLYHEDRAL_GRAVITY_DOCS": "OFF", # Not required for the python interface (--> OFF) @@ -54,24 +54,24 @@ def get_cmake_generator(): return None def get_version(): - """Returns the version of the polyhedral gravity package by reading Version.h.""" - # Construct the path to Version.h relative to the current file - version_file = os.path.join(os.path.dirname(__file__), "src", "polyhedralGravity", "Version.h") + """Returns the version of the polyhedral gravity package by reading the CMake file.""" + # Path to the CMake file + cmake_file = os.path.join(os.path.dirname(__file__), "version.cmake" ) - # Check if the Version.h file exists - if not os.path.exists(version_file): - raise FileNotFoundError(f"Version file not found: {version_file}") + # Check if the CMake file exists + if not os.path.exists(cmake_file): + raise FileNotFoundError(f"CMake file not found: {cmake_file}") # Open and read the file - with open(version_file, "r") as file: + with open(cmake_file, "r") as file: content = file.read() - # Use regex to extract the version string - version_match = re.search(r'POLYHEDRAL_GRAVITY_VERSION\s*=\s*\"([^\"]+)\"', content) + # Use regex to extract the PROJECT_VERSION + version_match = re.search(r'set\(PROJECT_VERSION\s+([^\s)]+)\)', content) if version_match: return version_match.group(1) else: - raise ValueError("Version string not found in Version.h") + raise ValueError("Version string not found in CMakeLists.txt") # ----------------------------------------------------------------------------------------- diff --git a/src/main.cpp b/src/main.cpp index 356456f..4acea72 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,16 +1,18 @@ -#include +#include "polyhedralGravity/Info.h" #include "polyhedralGravity/input/ConfigSource.h" #include "polyhedralGravity/input/YAMLConfigReader.h" #include "polyhedralGravity/model/GravityModel.h" -#include "polyhedralGravity/output/Logging.h" #include "polyhedralGravity/output/CSVWriter.h" -#include "polyhedralGravity/Version.h" +#include "polyhedralGravity/output/Logging.h" +#include int main(int argc, char *argv[]) { using namespace polyhedralGravity; - SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Polyhedral Gravity Model Version " + std::string(POLYHEDRAL_GRAVITY_VERSION)); + SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Polyhedral Gravity Model Version: " + std::string(POLYHEDRAL_GRAVITY_VERSION)); + SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Polyhedral Gravity Commit Hash: " + std::string(POLYHEDRAL_GRAVITY_COMMIT_HASH)); SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Polyhedral Gravity Model Parallelization Backend: " + std::string(POLYHEDRAL_GRAVITY_PARALLELIZATION)); + SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Polyhedral Gravity Logging Level: " + std::string(POLYHEDRAL_GRAVITY_LOGGING_LEVEL)); if (argc != 2) { SPDLOG_LOGGER_INFO(PolyhedralGravityLogger::DEFAULT_LOGGER.getLogger(), "Wrong program call! " diff --git a/src/polyhedralGravity/CMakeLists.txt b/src/polyhedralGravity/CMakeLists.txt index 30bbb4e..c2a28b3 100644 --- a/src/polyhedralGravity/CMakeLists.txt +++ b/src/polyhedralGravity/CMakeLists.txt @@ -3,4 +3,4 @@ file(GLOB_RECURSE SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") -add_library(${PROJECT_NAME}_lib OBJECT ${SRC} Version.h) +add_library(${PROJECT_NAME}_lib OBJECT ${SRC} Info.h) diff --git a/src/polyhedralGravity/Info.h.in b/src/polyhedralGravity/Info.h.in new file mode 100644 index 0000000..ecb0c35 --- /dev/null +++ b/src/polyhedralGravity/Info.h.in @@ -0,0 +1,36 @@ +#pragma once + +#include + +// ########################################################################################## +// Please note! The content of this file is automatically modified by the CMake build system +// which replaces the variables +// ########################################################################################## + +namespace polyhedralGravity { + + /** + * The API version of the polyhedral gravity model's interface. + * The value is set by the CMake configuration. + */ + constexpr std::string_view POLYHEDRAL_GRAVITY_VERSION = "@POLYHEDRAL_GRAVITY_VERSION@"; + + /** + * The API parallelization backend of the polyhedral gravity model's interface. + * The value is set by the CMake configuration. + */ + constexpr std::string_view POLYHEDRAL_GRAVITY_PARALLELIZATION = "@POLYHEDRAL_GRAVITY_PARALLELIZATION@"; + + /** + * The API commit with which it was compiled. + * The value is set by the CMake configuration. + */ + constexpr std::string_view POLYHEDRAL_GRAVITY_COMMIT_HASH = "@POLYHEDRAL_GRAVITY_COMMIT_HASH@"; + + /** + * The API's Loggin Level. Determines the amount of output. + * The value is set by the CMake configuration. + */ + constexpr std::string_view POLYHEDRAL_GRAVITY_LOGGING_LEVEL = "@POLYHEDRAL_GRAVITY_LOGGING_LEVEL@"; + +}// namespace polyhedralGravity diff --git a/src/polyhedralGravity/Version.h b/src/polyhedralGravity/Version.h deleted file mode 100644 index 1c668cb..0000000 --- a/src/polyhedralGravity/Version.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -namespace polyhedralGravity { - - /** - * The API version of the polyhedral gravity model's interface. - * This value is utilized across C++ and Python Interface and the single value - * to change in case of updates. - */ - constexpr std::string_view POLYHEDRAL_GRAVITY_VERSION = "3.2.1"; - - /** - * The API parallelization backend of the polyhedral gravity model's interface. - * This value depends on the CMake configuration. - */ - constexpr std::string_view POLYHEDRAL_GRAVITY_PARALLELIZATION = -#ifdef POLYHEDRAL_GRAVITY_TBB - "TBB" -#elifdef POLYHEDRAL_GRAVITY_OMP - "OMP" -#else - "CPP" -#endif - ; - - -}// namespace polyhedralGravity diff --git a/src/polyhedralGravityPython/PolyhedralGravityPython.cpp b/src/polyhedralGravityPython/PolyhedralGravityPython.cpp index b5212f3..abaf3bb 100644 --- a/src/polyhedralGravityPython/PolyhedralGravityPython.cpp +++ b/src/polyhedralGravityPython/PolyhedralGravityPython.cpp @@ -6,11 +6,11 @@ #include "pybind11/pybind11.h" #include "pybind11/stl.h" -#include "polyhedralGravity/model/Polyhedron.h" -#include "polyhedralGravity/model/GravityModelData.h" -#include "polyhedralGravity/model/GravityModel.h" +#include "polyhedralGravity/Info.h" #include "polyhedralGravity/model/GravityEvaluable.h" -#include "polyhedralGravity/Version.h" +#include "polyhedralGravity/model/GravityModel.h" +#include "polyhedralGravity/model/GravityModelData.h" +#include "polyhedralGravity/model/Polyhedron.h" namespace py = pybind11; @@ -102,8 +102,12 @@ PYBIND11_MODULE(polyhedral_gravity, m) { Accordingly, the second derivative tensor is defined as the derivative of :math:`\textbf{g}`. )mydelimiter"; + + // We embedded the version & compilation information into the Python Interface m.attr("__version__") = POLYHEDRAL_GRAVITY_VERSION; m.attr("__parallelization__") = POLYHEDRAL_GRAVITY_PARALLELIZATION; + m.attr("__commit__") = POLYHEDRAL_GRAVITY_COMMIT_HASH; + m.attr("__logging__") = POLYHEDRAL_GRAVITY_LOGGING_LEVEL; py::enum_(m, "NormalOrientation", R"mydelimiter( The orientation of the plane unit normals of the polyhedron. diff --git a/version.cmake b/version.cmake new file mode 100644 index 0000000..869dc0b --- /dev/null +++ b/version.cmake @@ -0,0 +1,18 @@ +# Modify the version with a new release +set(PROJECT_VERSION 3.2.1) +set(POLYHEDRAL_GRAVITY_VERSION ${PROJECT_VERSION}) + +# Get the Git information +get_git_commit_hash(POLYHEDRAL_GRAVITY_COMMIT_HASH) +is_git_working_tree_clean(POLYHEDRAL_GRAVITY_WORKING_TREE) + +# Append "-modified" to the commit hash if the working tree is not clean +if (NOT ${POLYHEDRAL_GRAVITY_WORKING_TREE}) + set(POLYHEDRAL_GRAVITY_COMMIT_HASH "${POLYHEDRAL_GRAVITY_COMMIT_HASH}+modified") +endif () + +# Configure the output header file +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/src/polyhedralGravity/Info.h.in" + "${CMAKE_CURRENT_SOURCE_DIR}/src/polyhedralGravity/Info.h" +) \ No newline at end of file