Skip to content

Commit

Permalink
Stub again
Browse files Browse the repository at this point in the history
  • Loading branch information
bernedom committed Apr 20, 2024
1 parent 120eb88 commit cc41ebe
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 38 deletions.
29 changes: 8 additions & 21 deletions chapter04/ex07_pack_nsis_standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
15 changes: 6 additions & 9 deletions chapter04/ex07_pack_nsis_standalone/executable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* ______________________________________________________
*/

#include <chapter4/ex07/lib.hpp>
#include <chapter4/ex06/lib.hpp>

int main(void) {
chapter4::ex07::greeter g;
Expand Down
26 changes: 20 additions & 6 deletions chapter04/ex07_pack_nsis_standalone/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion chapter04/ex07_pack_nsis_standalone/library/src/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* ______________________________________________________
*/

#include <chapter4/ex07/lib.hpp>
#include <chapter4/ex06/lib.hpp>
#include <iostream>

namespace chapter4 {
Expand Down

0 comments on commit cc41ebe

Please sign in to comment.