From d99acc979d3c018e0d21e023f4b586c7747a4192 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Oct 2023 23:12:14 -0400 Subject: [PATCH 1/3] xo-cmake: additions to README --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a06e0291..c5c6353d 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,17 @@ Collects cmake macros to be shared across XO projects (e.g. indentlog, reflect, In some XO project `foo`: ``` $ cd build -$ cmake -DCMAKE_MODULE_PATH=/usr/local/share/cmake .. +$ PREFIX=/usr/local # or wherever you prefer +$ cmake -DCMAKE_MODULE_PATH=${PREFIX}/share/cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} .. +$ make install ``` then in `foo/CMakeLists.txt`: ``` include(xo_macros/xo_cxx) ``` + +when configuring `foo`: +``` +$ cmake -DCMAKE_MODULE_PATH=${PREFIX}/share/cmake path/to/foo +``` From 4c78144b472029bafcddc144641e073387dae9f3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Oct 2023 23:17:24 -0400 Subject: [PATCH 2/3] xo-cmake: need CMAKE_INSTALL_PREFIX at least for OSX --- cmake/xo_cxx.cmake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake/xo_cxx.cmake b/cmake/xo_cxx.cmake index 64ec2822..2246fd5d 100644 --- a/cmake/xo_cxx.cmake +++ b/cmake/xo_cxx.cmake @@ -165,7 +165,9 @@ endmacro() # use this to install typical include file subtree # macro(xo_install_include_tree) - install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include) + install( + DIRECTORY ${PROJECT_SOURCE_DIR}/include/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/include) endmacro() # ---------------------------------------------------------------- @@ -222,13 +224,10 @@ macro(xo_export_cmake_config projectname projectversion projecttargets) ) install( EXPORT ${projecttargets} - DESTINATION lib/cmake/${projectname} - ) - install( FILES "${PROJECT_BINARY_DIR}/${projectname}ConfigVersion.cmake" "${PROJECT_BINARY_DIR}/${projectname}Config.cmake" - DESTINATION lib/cmake/${projectname} + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/${projectname} ) endmacro() From 9a1e33dfd6fea415976caed215c0a5f1993efb94 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Oct 2023 00:17:02 -0400 Subject: [PATCH 3/3] cmake: set readonly permissions on install --- CMakeLists.txt | 1 + cmake/xo_cxx.cmake | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c018ef2d..9c9aa85f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,5 +14,6 @@ install( FILES "cmake/xo_cxx.cmake" "cmake/code-coverage.cmake" + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ DESTINATION share/cmake/${XO_PROJECT_NAME} ) diff --git a/cmake/xo_cxx.cmake b/cmake/xo_cxx.cmake index 2246fd5d..c2d64247 100644 --- a/cmake/xo_cxx.cmake +++ b/cmake/xo_cxx.cmake @@ -167,6 +167,7 @@ endmacro() macro(xo_install_include_tree) install( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ + FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ DESTINATION ${CMAKE_INSTALL_PREFIX}/include) endmacro() @@ -224,9 +225,13 @@ macro(xo_export_cmake_config projectname projectversion projecttargets) ) install( EXPORT ${projecttargets} + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/${projectname}) + install( FILES "${PROJECT_BINARY_DIR}/${projectname}ConfigVersion.cmake" "${PROJECT_BINARY_DIR}/${projectname}Config.cmake" + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/${projectname} ) endmacro()