From 3da73f5d3c9beba836ca29c3ed9c6ab22aa6ee2c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 13:18:40 -0400 Subject: [PATCH 1/3] xo-cmake: + xo_install_include_tree() --- cmake/xo_cxx.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/xo_cxx.cmake b/cmake/xo_cxx.cmake index 160a1833..d2f95936 100644 --- a/cmake/xo_cxx.cmake +++ b/cmake/xo_cxx.cmake @@ -42,6 +42,13 @@ macro(xo_compile_options target) target_copmile_options(${target} PRIVATE ${XO_COMPILE_OPTIONS}) endmacro() +# ---------------------------------------------------------------- +# use this to install typical include file subtree +# +macro(xo_install_include_tree) + install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include) +endmacro() + # ---------------------------------------------------------------- # # dependency on an xo library (including header-only libraries) From 795d5ddb69ff38ccdb9ffcbe5226af7b194d5ec7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 13:18:59 -0400 Subject: [PATCH 2/3] xo-cmake: + xo_install_library2() --- cmake/xo_cxx.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmake/xo_cxx.cmake b/cmake/xo_cxx.cmake index d2f95936..6728db82 100644 --- a/cmake/xo_cxx.cmake +++ b/cmake/xo_cxx.cmake @@ -49,6 +49,22 @@ macro(xo_install_include_tree) install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include) endmacro() +# ---------------------------------------------------------------- +# use this for a subdir that builds a library +# and supports find_package() +# +macro(xo_install_library2 target) + install( + TARGETS ${target} + EXPORT ${target}Targets + LIBRARY DESTINATION lib COMPONENT Runtime + ARCHIVE DESTINATION lib COMPONENT Development + RUNTIME DESTINATION bin COMPONENT Runtime + PUBLIC_HEADER DESTINATION include COMPONENT Development + BUNDLE DESTINATION bin COMPONENT Runtime + ) +endmacro() + # ---------------------------------------------------------------- # # dependency on an xo library (including header-only libraries) From 8884d7f9aa55f6a77530f7487a5bec0f24860544 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 13:19:11 -0400 Subject: [PATCH 3/3] xo-cmake: + xo_export_cmake_config() --- cmake/xo_cxx.cmake | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/cmake/xo_cxx.cmake b/cmake/xo_cxx.cmake index 6728db82..8f70a590 100644 --- a/cmake/xo_cxx.cmake +++ b/cmake/xo_cxx.cmake @@ -65,6 +65,40 @@ macro(xo_install_library2 target) ) endmacro() +# ---------------------------------------------------------------- + +# for projectname=foo, require: +# cmake/fooConfig.cmake.in +# +# prepares +# ${PREFIX}/lib/cmake/foo/fooConfig.cmake +# ${PREFIX}/lib/cmake/foo/fooConfigVersion.cmake +# ${PREFIX}/lib/cmake/foo/fooTargets.cmake +# +macro(xo_export_cmake_config projectname projectversion projecttargets) + include(CMakePackageConfigHelpers) + write_basic_package_version_file( + "${PROJECT_BINARY_DIR}/${projectname}ConfigVersion.cmake" + VERSION ${projectversion} + COMPATIBILITY AnyNewerVersion + ) + configure_package_config_file( + "${PROJECT_SOURCE_DIR}/cmake/${projectname}Config.cmake.in" + "${PROJECT_BINARY_DIR}/${projectname}Config.cmake" + INSTALL_DESTINATION lib/cmake/${projectname} + ) + 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} + ) +endmacro() + # ---------------------------------------------------------------- # # dependency on an xo library (including header-only libraries)