diff --git a/CMakeLists.txt b/CMakeLists.txt index dc281211e0..15a58d0964 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,3 +338,27 @@ install(DIRECTORY "${slang_SOURCE_DIR}/docs/" DESTINATION share/doc/slang) install(DIRECTORY "${slang_SOURCE_DIR}/include" DESTINATION .) include(CPack) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion) + +configure_package_config_file( + "${PROJECT_SOURCE_DIR}/cmake/SlangConfig.cmake.in" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION + cmake +) + +install(TARGETS slang EXPORT SlangExportTarget) + +install(EXPORT SlangExportTarget + FILE ${PROJECT_NAME}Targets.cmake + NAMESPACE ${PROJECT_NAME}:: + DESTINATION cmake) + +install(FILES + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + DESTINATION cmake) diff --git a/cmake/SlangConfig.cmake.in b/cmake/SlangConfig.cmake.in new file mode 100644 index 0000000000..0074f6ae9b --- /dev/null +++ b/cmake/SlangConfig.cmake.in @@ -0,0 +1,6 @@ + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/slangTargets.cmake") +check_required_components("slang") +