From 2e785a0e833b49d1adac6489430e75967d8930e4 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sat, 10 Jan 2026 21:53:30 +0800 Subject: [PATCH] improve basalt shared install --- .../CMake/BasaltSharedConfig.cmake.in | 7 +++++ BasaltPresenter/CMakeLists.txt | 29 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 BasaltPresenter/CMake/BasaltSharedConfig.cmake.in diff --git a/BasaltPresenter/CMake/BasaltSharedConfig.cmake.in b/BasaltPresenter/CMake/BasaltSharedConfig.cmake.in new file mode 100644 index 0000000..4a2e3cc --- /dev/null +++ b/BasaltPresenter/CMake/BasaltSharedConfig.cmake.in @@ -0,0 +1,7 @@ + +@PACKAGE_INIT@ + +# Include targets file +include("${CMAKE_CURRENT_LIST_DIR}/BasaltSharedTargets.cmake") + +check_required_components(BasaltShared) \ No newline at end of file diff --git a/BasaltPresenter/CMakeLists.txt b/BasaltPresenter/CMakeLists.txt index 6f176a9..cca4903 100644 --- a/BasaltPresenter/CMakeLists.txt +++ b/BasaltPresenter/CMakeLists.txt @@ -52,8 +52,35 @@ if (BASALT_OBJ_OBJECT_LOADER) find_package(tinyobjloader REQUIRED) endif () - # Include projects add_subdirectory(Shared) add_subdirectory(Presenter) add_subdirectory(Plugins) + +# Install target and package +# Install target +install(EXPORT BasaltSharedTargets + FILE BasaltSharedTargets.cmake + NAMESPACE BasaltShared:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/BasaltShared +) +# Package configuration file +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + BasaltSharedConfigVersion.cmake + VERSION ${PACKAGE_VERSION} + COMPATIBILITY SameMinorVersion +) +configure_package_config_file( + ${CMAKE_CURRENT_LIST_DIR}/CMake/BasaltSharedConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/BasaltSharedConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/BasaltShared +) +# Copy package files to install destination +install( +FILES + "${CMAKE_CURRENT_BINARY_DIR}/BasaltSharedConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/BasaltSharedConfigVersion.cmake" +DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/BasaltShared +) \ No newline at end of file