From b63a5f461b324da0fe464aaced211733b44f8ab8 Mon Sep 17 00:00:00 2001 From: Sverre Briseid Date: Tue, 25 Mar 2025 14:47:53 +0100 Subject: [PATCH] Now adding cmake config files when installing gotools-core, sisl and lrsplines2D. --- gotools-core/CMakeLists.txt | 45 +++++++++++++++++++ gotools-core/cmake/GoToolsCoreConfig.cmake.in | 9 ++++ lrsplines2D/CMakeLists.txt | 40 +++++++++++++++++ .../cmake/GoLRsplines2DConfig.cmake.in | 9 ++++ sisl | 2 +- 5 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 gotools-core/cmake/GoToolsCoreConfig.cmake.in create mode 100644 lrsplines2D/cmake/GoLRsplines2DConfig.cmake.in diff --git a/gotools-core/CMakeLists.txt b/gotools-core/CMakeLists.txt index 362fc662..de421047 100644 --- a/gotools-core/CMakeLists.txt +++ b/gotools-core/CMakeLists.txt @@ -122,4 +122,49 @@ ELSE(WIN32) ) ENDIF(WIN32) +# === Install Targets and Export Package === + +include(CMakePackageConfigHelpers) + +# Install the GoToolsCore target with export set +install(TARGETS GoToolsCore + EXPORT GoToolsCoreTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +# Install headers +install(DIRECTORY include/ + DESTINATION include + FILES_MATCHING PATTERN "*.h" +) + +# Export the targets to a file +install(EXPORT GoToolsCoreTargets + FILE GoToolsCoreTargets.cmake + #NAMESPACE GoTools:: # So consumer can do target_link_libraries(... GoTools::GoToolsCore) + DESTINATION lib/cmake/GoToolsCore +) + +# Generate and install the Config and Version files +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/GoToolsCoreConfigVersion.cmake" + VERSION ${GoTools_VERSION_MAJOR}.${GoTools_VERSION_MINOR}.${GoTools_VERSION_PATCH} + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/GoToolsCoreConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/GoToolsCoreConfig.cmake" + INSTALL_DESTINATION lib/cmake/GoToolsCore +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/GoToolsCoreConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/GoToolsCoreConfigVersion.cmake" + DESTINATION lib/cmake/GoToolsCore +) + SET(CPACK_STRIP_FILES ${CPACK_STRIP_FILES} libGoToolsCore.so) diff --git a/gotools-core/cmake/GoToolsCoreConfig.cmake.in b/gotools-core/cmake/GoToolsCoreConfig.cmake.in new file mode 100644 index 00000000..d00f0c30 --- /dev/null +++ b/gotools-core/cmake/GoToolsCoreConfig.cmake.in @@ -0,0 +1,9 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/GoToolsCoreTargets.cmake") + +# Legacy compatibility +set(GoTools_LIBRARIES GoToolsCore) + +# Optionally set variables +set(GoToolsCore_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include") diff --git a/lrsplines2D/CMakeLists.txt b/lrsplines2D/CMakeLists.txt index 7cce75da..7c2b7f48 100644 --- a/lrsplines2D/CMakeLists.txt +++ b/lrsplines2D/CMakeLists.txt @@ -156,4 +156,44 @@ ELSE(WIN32) ) ENDIF(WIN32) +# === Install and Export CMake Config Package === + +include(CMakePackageConfigHelpers) + +# Install the GoLRspline2D target +install(TARGETS GoLRspline2D + EXPORT GoLRspline2DTargets + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +# Export the target without namespace +install(EXPORT GoLRspline2DTargets + FILE GoLRsplines2DTargets.cmake + DESTINATION lib/cmake/GoLRsplines2D +) + +# Generate the version file for find_package() +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/GoLRsplines2DConfigVersion.cmake" + VERSION ${GoTools_ABI_VERSION} + COMPATIBILITY SameMajorVersion +) + +# Generate the config file from template +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/GoLRsplines2DConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/GoLRsplines2DConfig.cmake" + INSTALL_DESTINATION lib/cmake/GoLRsplines2D +) + +# Install the generated config files +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/GoLRsplines2DConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/GoLRsplines2DConfigVersion.cmake" + DESTINATION lib/cmake/GoLRsplines2D +) + SET(CPACK_STRIP_FILES ${CPACK_STRIP_FILES} libGoLRspline2D.so) diff --git a/lrsplines2D/cmake/GoLRsplines2DConfig.cmake.in b/lrsplines2D/cmake/GoLRsplines2DConfig.cmake.in new file mode 100644 index 00000000..1873cab2 --- /dev/null +++ b/lrsplines2D/cmake/GoLRsplines2DConfig.cmake.in @@ -0,0 +1,9 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/GoLRsplines2DTargets.cmake") + +# Legacy compatibility +set(GoLRsplines2D_LIBRARIES GoLRspline2D) + +# Optional include path var +set(GoLRsplines2D_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include") diff --git a/sisl b/sisl index 885ade18..f4c94502 160000 --- a/sisl +++ b/sisl @@ -1 +1 @@ -Subproject commit 885ade18ac0e2ba852869da60de796522292a142 +Subproject commit f4c94502c13da57d78d501aad0e72a1e8257b5b3