diff --git a/CMakeLists.txt b/CMakeLists.txt index 48826c6..6bf4eb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,51 @@ cmake_minimum_required(VERSION 3.10) -project(recycle) + +project(recycle + VERSION 6.0.0 + DESCRIPTION "Simple resource pool for recycling resources in C++" + LANGUAGES CXX) # Define library add_library(recycle INTERFACE) target_compile_features(recycle INTERFACE cxx_std_14) -target_include_directories(recycle INTERFACE src/) +target_include_directories(recycle INTERFACE $ $) add_library(steinwurf::recycle ALIAS recycle) +include(GNUInstallDirs) +set(RECYCLE_CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/recycle" CACHE PATH "recycle config directory") + # Install headers install( DIRECTORY ./src/recycle - DESTINATION ${CMAKE_INSTALL_PREFIX}/include + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN *.hpp) + +# Install targets +install(TARGETS recycle EXPORT recycle-targets) +install( + EXPORT recycle-targets + DESTINATION ${RECYCLE_CONFIG_DIR} + NAMESPACE steinwurf::) + +# Install package config +include(CMakePackageConfigHelpers) + +configure_package_config_file( + cmake/recycle-config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/recycle-config.cmake" + INSTALL_DESTINATION ${RECYCLE_CONFIG_DIR} + NO_CHECK_REQUIRED_COMPONENTS_MACRO) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/recycle-config-version.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/recycle-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/recycle-config-version.cmake" + DESTINATION + ${RECYCLE_CONFIG_DIR}) diff --git a/cmake/recycle-config.cmake.in b/cmake/recycle-config.cmake.in new file mode 100644 index 0000000..9f4e6c6 --- /dev/null +++ b/cmake/recycle-config.cmake.in @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ + +if(NOT TARGET steinwurf::recycle) + set_and_check(RECYCLE_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@") + include(${CMAKE_CURRENT_LIST_DIR}/recycle-targets.cmake) +endif()