diff options
author | Manuel Bentele | 2020-10-23 18:13:15 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-23 18:13:15 +0200 |
commit | 588368dd2a46ddec70741c6cc87a79a0b26ee383 (patch) | |
tree | 69265caba9b1fb0ee126c142538b75fd49bbe8ee /cmake/GenerateVersion.cmake | |
parent | Move the source code of all xloop components to the common 'src' directory (diff) | |
download | xloop-588368dd2a46ddec70741c6cc87a79a0b26ee383.tar.gz xloop-588368dd2a46ddec70741c6cc87a79a0b26ee383.tar.xz xloop-588368dd2a46ddec70741c6cc87a79a0b26ee383.zip |
Add automatic generation of version and build type headers for compilation
This change replaces the static version and build type header file generation
by CMake with dynamic CMake targets to generate the version file whenever a Make
target is executed. Thus, there is no need anymore to reconfigure and rerun
CMake after the repository version or build configuration has changed.
Diffstat (limited to 'cmake/GenerateVersion.cmake')
-rw-r--r-- | cmake/GenerateVersion.cmake | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake new file mode 100644 index 0000000..73b0771 --- /dev/null +++ b/cmake/GenerateVersion.cmake @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de> +# + +# set CMake module path to include version macros +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} + ${VERSION_MODULE_PATH}) + +# include version macros +include(Version) + +# get Git version of Git repository +get_repository_version(XLOOP_VERSION ${VERSION_INPUT_FILE} ${VERSION_BUILD_TYPE}) + +# generate version header if header does not exists +if(NOT EXISTS ${VERSION_INPUT_FILE}) + # write dnbd3 version into a new C source file based on the specified version template + configure_file(${VERSION_INPUT_FILE_TEMPLATE} ${VERSION_OUTPUT_FILE}) +endif(NOT EXISTS ${VERSION_INPUT_FILE}) |