From 588368dd2a46ddec70741c6cc87a79a0b26ee383 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Fri, 23 Oct 2020 18:13:15 +0200 Subject: 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. --- cmake/GenerateVersion.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cmake/GenerateVersion.cmake (limited to 'cmake/GenerateVersion.cmake') 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 +# + +# 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}) -- cgit v1.2.3-55-g7522