From 77dc7ef5e2925cfcce13c3a7b5ae5649e89f83b4 Mon Sep 17 00:00:00 2001 From: Erich Essmann Date: Fri, 24 Oct 2025 13:43:43 +0100 Subject: [PATCH 1/2] Simplify installation path configuration Removed unnecessary path normalization and appending for installation. --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb826e18..8d5650da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,6 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) # GNUInstallDirs to provide sensible default install directory names -cmake_path(SET ORG_INSTALL_PATH NORMALIZE "${CMAKE_INSTALL_PREFIX}") -cmake_path(APPEND CMAKE_INSTALL_PREFIX "quest") include(GNUInstallDirs) include(CMakePackageConfigHelpers) From 653b62c73b76a3f1eb2e85056c5a9efada601e39 Mon Sep 17 00:00:00 2001 From: Erich Essmann Date: Mon, 27 Oct 2025 11:01:03 +0000 Subject: [PATCH 2/2] Updates CMake config for conditional installs Modifies CMakeLists to conditionally build shared libraries and install binaries only at the top-level project. Introduces the INSTALL_BINARIES option to control the inclusion of example binaries in the installation process. Corrects a typo from 'RATH' to 'RPATH' for build configurations. --- CMakeLists.txt | 26 +++++++++++++++++--------- examples/CMakeLists.txt | 12 +++++++----- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d5650da..7831a17e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,10 +72,11 @@ endif() # Library type -# Shared library by default -option(BUILD_SHARED_LIBS "Build shared library. Turned ON by default." ON) -message(STATUS "Shared library is turned ${BUILD_SHARED_LIBS}. Set BUILD_SHARED_LIBS to modify.") - +# Shared library by default when we are the top level cmake project +if(PROJECT_IS_TOP_LEVEL) + option(BUILD_SHARED_LIBS "Build shared library. Turned ON by default." ON) + message(STATUS "Shared library is turned ${BUILD_SHARED_LIBS}. Set BUILD_SHARED_LIBS to modify.") +endif () # Library naming set(LIB_NAME QuEST @@ -183,6 +184,7 @@ option( ) message(STATUS "Disabling of deprecated API warnings is turned ${DISABLE_DEPRECATION_WARNINGS}. Set DISABLE_DEPRECATION_WARNINGS to modify.") +option(INSTALL_BINARIES "Whether to include example and user binaries in the install." OFF) # ============================ @@ -563,10 +565,12 @@ add_executable(min_example ) target_link_libraries(min_example PRIVATE QuEST::QuEST) -install(TARGETS min_example - RUNTIME - DESTINATION ${CMAKE_INSTALL_BINDIR} -) +if (INSTALL_BINARIES) + install(TARGETS min_example + RUNTIME + DESTINATION ${CMAKE_INSTALL_BINDIR} + ) +endif () # all examples optionally built @@ -575,7 +579,7 @@ if (BUILD_EXAMPLES) endif() -## RATH +## RPATH set(BUILD_RPATH_USE_ORIGIN ON) if(APPLE) set(_RPATH_ORIGIN "@loader_path") @@ -730,3 +734,7 @@ install( NAMESPACE QuEST:: DESTINATION "${QuEST_INSTALL_CONFIGDIR}" ) + +if(PROJECT_IS_TOP_LEVEL) + include(CPack) +endif () \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 00d4c343..afc8f85d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -20,11 +20,13 @@ function(add_example direc in_fn) add_executable(${target} ${in_fn}) target_link_libraries(${target} PUBLIC QuEST) - install( - TARGETS ${target} - RUNTIME - DESTINATION ${out_dir} - ) + if (INSTALL_BINARIES) + install( + TARGETS ${target} + RUNTIME + DESTINATION ${out_dir} + ) + endif () set_target_properties(${target} PROPERTIES