From a97b69288baed753a89d6559876df25e36b19fe7 Mon Sep 17 00:00:00 2001 From: doodspav Date: Sat, 21 Oct 2023 11:27:12 +0100 Subject: [PATCH] GHI #18 Fix cache variable issue with `CMAKE_INSTALL_INCLUDEDIR` - include `GNUInstallDirs` after setting `CMAKE_INSTALL_INCLUDEDIR` cache variable to avoid interfering with pre-existing one (previously changes didn't take effect) - add `/` at the end of the directory paths in `install(...)`, or CMake is unhappy --- cmake/InstallRules.cmake | 6 +++--- cmake/OptionVariables.cmake | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/InstallRules.cmake b/cmake/InstallRules.cmake index b245a22a5..b8c683c91 100644 --- a/cmake/InstallRules.cmake +++ b/cmake/InstallRules.cmake @@ -3,14 +3,14 @@ include(CMakePackageConfigHelpers) # copy header files to CMAKE_INSTALL_INCLUDEDIR install( DIRECTORY - "${PROJECT_SOURCE_DIR}/include" # our header files - "${PROJECT_BINARY_DIR}/include" # generated header files + "${PROJECT_SOURCE_DIR}/include/" # our header files + "${PROJECT_BINARY_DIR}/include/" # generated header files DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT ${package_name}-development ) # copy target build output artifacts to OS dependent locations -# (except includes) +# (except includes, that just sets a compiler flag with the path) install( TARGETS ${target_name} EXPORT ${package_name}-targets diff --git a/cmake/OptionVariables.cmake b/cmake/OptionVariables.cmake index 2e95642d1..a7480567a 100644 --- a/cmake/OptionVariables.cmake +++ b/cmake/OptionVariables.cmake @@ -1,4 +1,5 @@ -include(GNUInstallDirs) +# included further down to avoid interfering with our cache variables +# include(GNUInstallDirs) # ---- Options Summary ---- @@ -93,6 +94,11 @@ if(PROJECT_IS_TOP_LEVEL) endif() +# do not include earlier or we can't set CMAKE_INSTALL_INCLUDEDIR above +# required for CMAKE_INSTALL_LIBDIR below +include(GNUInstallDirs) + + # ---- Install CMake Directory ---- # This allows package maintainers to freely override the installation path for