opm-simulators/cmake/Modules/UseVersion.cmake
Roland Kaufmann be7b392690 Write version information into header file
Akin to config.h, we write project-version.h whenever the VCS sha hash
of the project changes. This file can then be included to embed this
into the project. Since this changes more frequently, we choose another
file than config.h. Care is also taken to not rewrite the header if the
information doesn't change, but the project is rebuilt.
2013-08-14 23:39:03 +02:00

26 lines
919 B
CMake

# - Write version information into the source code
#
# Add an unconditional target to the Makefile which checks the current
# SHA of the source directory and write to a header file if and *only*
# if this has changed (thus we avoid unnecessary rebuilds). By having
# this in the Makefile, we get updated version information even though
# we haven't done any reconfiguring.
#
# The time it takes to probe the VCS for this information and write it
# to the miniature file in negligable.
if (NOT GIT_FOUND)
find_package (Git)
endif ()
add_custom_target (update-version ALL
COMMAND ${CMAKE_COMMAND}
-DCMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
-DPROJECT_LABEL=${${project}_LABEL}
-P ${PROJECT_SOURCE_DIR}/cmake/Scripts/WriteVerSHA.cmake
COMMENT "Updating version information"
)