From 969496f15e1e0359e26c2c6e995ad4ef82720f86 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Fri, 16 Oct 2020 17:15:49 +0200 Subject: [BUILD] rewrite CMake build system to track changes of source files This change restructures the source code directories, separates shared form non-shared application code and adds CMake dependencies. These dependencies allow the tracking of changes and trigger a rebuild of those build targets where changed files are involved. WARNING: Note that the support of the DNBD3_SERVER_AFL build option is not supported yet. Thus, the option should be never turned on. --- cmake/ProjectVersion.cmake | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 cmake/ProjectVersion.cmake (limited to 'cmake/ProjectVersion.cmake') diff --git a/cmake/ProjectVersion.cmake b/cmake/ProjectVersion.cmake new file mode 100644 index 0000000..108505d --- /dev/null +++ b/cmake/ProjectVersion.cmake @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2020 Manuel Bentele +# + +macro(gen_project_version VERSION_INPUT_FILE VERSION_OUTPUT_FILE) + get_filename_component(VERSION_OUTPUT_FILENAME ${VERSION_OUTPUT_FILE} NAME) + # command that will trigger a rebuild of version.c every time + add_custom_command(OUTPUT regenerate-version-file + COMMAND ${CMAKE_COMMAND} -E sleep 0 + COMMENT "Trigger generating ${VERSION_OUTPUT_FILENAME}") + + # call the GenerateVersion.cmake file to generate the version.c file + add_custom_command(OUTPUT ${VERSION_OUTPUT_FILE} + COMMAND ${CMAKE_COMMAND} -D VERSION_INPUT_FILE=${VERSION_INPUT_FILE} + -D VERSION_OUTPUT_FILE=${VERSION_OUTPUT_FILE} + -P ${PROJECT_MODULES_DIR}/GenerateVersion.cmake + COMMENT "Generating ${VERSION_OUTPUT_FILENAME}" + DEPENDS regenerate-version-file) + add_custom_target(dnbd3-generate-version DEPENDS ${VERSION_OUTPUT_FILE}) + + # create target to expose project version + add_library(dnbd3-version INTERFACE) + target_include_directories(dnbd3-version INTERFACE ${PROJECT_INCLUDE_TMP_DIR}) + add_dependencies(dnbd3-version dnbd3-generate-version) + +endmacro(gen_project_version VERSION_INPUT_FILE VERSION_OUTPUT_FILE) -- cgit v1.2.3-55-g7522