summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt35
-rw-r--r--cmake/InstallVersionFile.cmake.in8
-rw-r--r--cmake/PostVersionPackaging.cmake9
-rw-r--r--cmake/PreVersionPackaging.cmake11
4 files changed, 44 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7fe82ca..66d67a4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -142,24 +142,37 @@ if(CMAKE_BUILD_TYPE MATCHES "Release")
# configure source packaging
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR}" "/"
- "${PROJECT_GEN_DIR}" "/")
- set(CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;.gitignore$;.*~;version.h.in$")
-
- # generate install script for CPack to install generated files
- configure_file(${PROJECT_MODULES_DIR}/InstallVersionFile.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/package/InstallVersionFile.cmake)
-
- # set CPack install script
- set(CPACK_INSTALL_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/package/InstallVersionFile.cmake)
+ "${PROJECT_GEN_DIR}" "/")
+ set(CPACK_SOURCE_IGNORE_FILES "/build/"
+ "/.git/"
+ ".gitignore"
+ "version.h.in")
# include CPack functionality
include(CPack)
- # create custom target to build package source
- add_custom_target(source
+ # prepare source packaging
+ add_custom_command(OUTPUT ${INCLUDE_VERSION_HEADER}
+ COMMAND ${CMAKE_COMMAND} -D VERSION_HEADER_INPUT_FILE=${INCLUDE_VERSION_HEADER_GENERATE}
+ -D VERSION_HEADER_OUTPUT_FILE=${INCLUDE_VERSION_HEADER}
+ -P ${PROJECT_MODULES_DIR}/PreVersionPackaging.cmake
+ COMMENT "Prepare version.h"
+ DEPENDS xloop-generate-version)
+
+ # main source packaging
+ add_custom_target(package_source_main
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target package_source
- DEPENDS xloop-generate-version
+ DEPENDS ${INCLUDE_VERSION_HEADER}
VERBATIM
USES_TERMINAL)
+
+ # post source packaging and exported target to build source packages
+ add_custom_target(source
+ COMMAND ${CMAKE_COMMAND} -D VERSION_HEADER_INPUT_FILE=${INCLUDE_VERSION_HEADER_GENERATE}
+ -D VERSION_HEADER_OUTPUT_FILE=${INCLUDE_VERSION_HEADER}
+ -P ${PROJECT_MODULES_DIR}/PostVersionPackaging.cmake
+ COMMENT "Cleanup version.h"
+ DEPENDS package_source_main)
endif(CMAKE_BUILD_TYPE MATCHES "Release")
# add all xloop related projects from the source code directory
diff --git a/cmake/InstallVersionFile.cmake.in b/cmake/InstallVersionFile.cmake.in
deleted file mode 100644
index 8121c25..0000000
--- a/cmake/InstallVersionFile.cmake.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# AUTOGENERATED: DO NOT EDIT THIS FILE
-#
-
-if(CPACK_SOURCE_INSTALLED_DIRECTORIES AND EXISTS "@INCLUDE_VERSION_HEADER_GENERATE@")
- file(INSTALL "@INCLUDE_VERSION_HEADER_GENERATE@"
- DESTINATION "@INCLUDE_VERSION_HEADER_GENERATE_PREFIX@")
-endif(CPACK_SOURCE_INSTALLED_DIRECTORIES AND EXISTS "@INCLUDE_VERSION_HEADER_GENERATE@")
diff --git a/cmake/PostVersionPackaging.cmake b/cmake/PostVersionPackaging.cmake
new file mode 100644
index 0000000..877cd12
--- /dev/null
+++ b/cmake/PostVersionPackaging.cmake
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
+#
+
+if(EXISTS ${VERSION_HEADER_INPUT_FILE})
+ # remove version.h if generated version.h is available from a Git build
+ file(REMOVE ${VERSION_HEADER_OUTPUT_FILE})
+endif(EXISTS ${VERSION_HEADER_INPUT_FILE})
diff --git a/cmake/PreVersionPackaging.cmake b/cmake/PreVersionPackaging.cmake
new file mode 100644
index 0000000..e960155
--- /dev/null
+++ b/cmake/PreVersionPackaging.cmake
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
+#
+
+if(EXISTS ${VERSION_HEADER_INPUT_FILE})
+ # copy generated version.h into the source repository for packaging purposes
+ get_filename_component(VERSION_HEADER_OUTPUT_FILE_PATH ${VERSION_HEADER_OUTPUT_FILE} PATH)
+ file(COPY ${VERSION_HEADER_INPUT_FILE}
+ DESTINATION ${VERSION_HEADER_OUTPUT_FILE_PATH})
+endif(EXISTS ${VERSION_HEADER_INPUT_FILE})