From cc41ebe9a3f08511665c3d29c023f11d1ca4b871 Mon Sep 17 00:00:00 2001 From: Dominik Berner Date: Sat, 20 Apr 2024 10:14:51 +0000 Subject: [PATCH] Stub again --- .../ex07_pack_nsis_standalone/CMakeLists.txt | 29 +++++-------------- .../executable/CMakeLists.txt | 15 ++++------ .../executable/src/main.cpp | 2 +- .../library/CMakeLists.txt | 26 +++++++++++++---- .../include/chapter4/{ex07 => ex06}/lib.hpp | 0 .../library/src/lib.cpp | 2 +- 6 files changed, 36 insertions(+), 38 deletions(-) rename chapter04/ex07_pack_nsis_standalone/library/include/chapter4/{ex07 => ex06}/lib.hpp (100%) diff --git a/chapter04/ex07_pack_nsis_standalone/CMakeLists.txt b/chapter04/ex07_pack_nsis_standalone/CMakeLists.txt index d4d86ef..d9a8fe2 100644 --- a/chapter04/ex07_pack_nsis_standalone/CMakeLists.txt +++ b/chapter04/ex07_pack_nsis_standalone/CMakeLists.txt @@ -6,40 +6,27 @@ cmake_minimum_required(VERSION 3.23) project( - ch04_ex07_pack_nsis + ch4_ex07_pack VERSION 1.0 - DESCRIPTION "Chapter 4 Example 06, Packaging with CPack" + DESCRIPTION "Chapter 4 Example 07, Packaging with CPack" LANGUAGES CXX) if(NOT PROJECT_IS_TOP_LEVEL) - message(FATAL_ERROR "The chapter-4, ex07_pack_nsis project is intended to be a standalone, top-level project. Do not include this directory.") -endif() -if(NOT WIN32) -# message(FATAL_ERROR "The chapter-4, ex07_pack_nsis project is intended to be built on Windows platform.") + message(FATAL_ERROR "The chapter-4, ex07_pack project is intended to be a standalone, top-level project. Do not include this directory.") endif() add_subdirectory(executable) -# the library is built but does not contain any install rules add_subdirectory(library) -#including the InstallRequiredSystemLibraries will cause CMake to search for compiler-provided system runtime libraries and copy them from the system to the package. -include(InstallRequiredSystemLibraries) - -# This install commands will install all dependendent libraries for ch04_ex07_executable -# the PRE_EXCLUDE_REGEXES and POST_EXCLUDE_REGEXES are used to exclude system DLLs that are not needed -install(TARGETS ch04_ex07_executable - RUNTIME_DEPENDENCIES - PRE_EXCLUDE_REGEXES "api-ms-.*" "ext-ms-.*" - POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" - ) - # We will not explicitly specify project name and version here and # let CPack to get project name and version from the project() set(CPACK_PACKAGE_VENDOR "CBP Authors") -# Enable NSIS installers -set(CPACK_GENERATOR "NSIS") +# Enable DEB, RPM and TBZ2 generators by default +set(CPACK_GENERATOR "DEB;TBZ2;TGZ;STGZ") # Use all available cores when parallelism is supported set(CPACK_THREADS 0) - +# The DEB generator requires CPACK_DEBIAN_PACKAGE_MAINTAINER +# value to be set. +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "CBP Authors") # Enable packaging support for the project include(CPack) \ No newline at end of file diff --git a/chapter04/ex07_pack_nsis_standalone/executable/CMakeLists.txt b/chapter04/ex07_pack_nsis_standalone/executable/CMakeLists.txt index 2c7ecb2..eb182de 100644 --- a/chapter04/ex07_pack_nsis_standalone/executable/CMakeLists.txt +++ b/chapter04/ex07_pack_nsis_standalone/executable/CMakeLists.txt @@ -6,21 +6,18 @@ cmake_minimum_required(VERSION 3.23) project( - ch04_ex07_executable + ch4_ex07_executable VERSION 1.0 - DESCRIPTION "Chapter 4 Example 06, CPack example" + DESCRIPTION "Chapter 4 Example 07, CPack example" LANGUAGES CXX) # Define the executable that will consume the ch4_ex05_lib package -add_executable(ch04_ex07_executable src/main.cpp) +add_executable(ch4_ex07_executable src/main.cpp) # Set the required C++ standard for the target -target_compile_features(ch04_ex07_executable PRIVATE cxx_std_11) +target_compile_features(ch4_ex07_executable PRIVATE cxx_std_11) # Link executable target to library target -target_link_libraries(ch04_ex07_executable PRIVATE ch4_ex07_library) +target_link_libraries(ch4_ex07_executable PRIVATE ch4_ex07_library) - -include(GNUInstallDirs) - -install(TARGETS ch04_ex07_executable) +install(TARGETS ch4_ex07_executable) \ No newline at end of file diff --git a/chapter04/ex07_pack_nsis_standalone/executable/src/main.cpp b/chapter04/ex07_pack_nsis_standalone/executable/src/main.cpp index f902d71..9043ec8 100644 --- a/chapter04/ex07_pack_nsis_standalone/executable/src/main.cpp +++ b/chapter04/ex07_pack_nsis_standalone/executable/src/main.cpp @@ -6,7 +6,7 @@ * ______________________________________________________ */ -#include +#include int main(void) { chapter4::ex07::greeter g; diff --git a/chapter04/ex07_pack_nsis_standalone/library/CMakeLists.txt b/chapter04/ex07_pack_nsis_standalone/library/CMakeLists.txt index d96d5a0..319b2c6 100644 --- a/chapter04/ex07_pack_nsis_standalone/library/CMakeLists.txt +++ b/chapter04/ex07_pack_nsis_standalone/library/CMakeLists.txt @@ -6,16 +6,30 @@ cmake_minimum_required(VERSION 3.23) project( - ch04_ex07_library + ch4_ex07_library VERSION 1.0 - DESCRIPTION "Chapter 4 Example 06, CPack example" + DESCRIPTION "Chapter 4 Example 07, CPack example" LANGUAGES CXX) -add_library(ch04_ex07_library STATIC src/lib.cpp) +# Define the executable that will consume the ch4_ex05_lib package +add_library(ch4_ex07_library STATIC src/lib.cpp) # Set the required C++ standard for the target -target_compile_features(ch04_ex07_library PRIVATE cxx_std_17) +target_compile_features(ch4_ex07_library PRIVATE cxx_std_11) -target_include_directories(ch04_ex07_library PUBLIC include) +# Specify the include directories for the target named `ch4_ex02_static` +target_include_directories(ch4_ex07_library PUBLIC include) + +include(GNUInstallDirs) # Defines the ${CMAKE_INSTALL_INCLUDEDIR} variable. + +# Make executable target `ch4_ex02_static` installable. As mentioned before +# in Chapter 4 content, this will only install the output artifacts produced by the target. +install(TARGETS ch4_ex07_library) + +# Install the header files. Since header files are not listed as output artifacts, they have +# to be installed separately. +install ( + DIRECTORY ${PROJECT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) -# this target ist not installed deliberately to illustrate how to use RUNTIME_DEPENDENCIES in CPack \ No newline at end of file diff --git a/chapter04/ex07_pack_nsis_standalone/library/include/chapter4/ex07/lib.hpp b/chapter04/ex07_pack_nsis_standalone/library/include/chapter4/ex06/lib.hpp similarity index 100% rename from chapter04/ex07_pack_nsis_standalone/library/include/chapter4/ex07/lib.hpp rename to chapter04/ex07_pack_nsis_standalone/library/include/chapter4/ex06/lib.hpp diff --git a/chapter04/ex07_pack_nsis_standalone/library/src/lib.cpp b/chapter04/ex07_pack_nsis_standalone/library/src/lib.cpp index 9665545..98c070c 100644 --- a/chapter04/ex07_pack_nsis_standalone/library/src/lib.cpp +++ b/chapter04/ex07_pack_nsis_standalone/library/src/lib.cpp @@ -6,7 +6,7 @@ * ______________________________________________________ */ -#include +#include #include namespace chapter4 {