diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c3b80a84..0154b3c9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,12 @@ option(CROW_ENABLE_COMPRESSION "Enable compression capabilities (ZLIB)" OFF) ##################################### add_library(Crow INTERFACE) add_library(Crow::Crow ALIAS Crow) -target_include_directories(Crow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) + +target_include_directories(Crow + INTERFACE + $ + $ +) find_package(Boost 1.64 COMPONENTS system date_time REQUIRED) find_package(Threads REQUIRED) @@ -86,7 +91,25 @@ endif() # Install Files ##################################### if(CROW_INSTALL) + install(TARGETS Crow EXPORT CrowTargets) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include) + + install(EXPORT CrowTargets + FILE CrowTargets.cmake + NAMESPACE Crow:: + DESTINATION lib/cmake/Crow + ) + + include(CMakePackageConfigHelpers) + configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CrowConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/CrowConfig.cmake" + INSTALL_DESTINATION lib/cmake/Crow + ) + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/CrowConfig.cmake" + DESTINATION lib/cmake/Crow + ) endif() set(CPACK_GENERATOR "DEB") diff --git a/cmake/CrowConfig.cmake.in b/cmake/CrowConfig.cmake.in new file mode 100644 index 000000000..d24c72277 --- /dev/null +++ b/cmake/CrowConfig.cmake.in @@ -0,0 +1,19 @@ +@PACKAGE_INIT@ + +set(CROW_ENABLE_COMPRESSION @CROW_ENABLE_COMPRESSION@) +set(CROW_ENABLE_SSL @CROW_ENABLE_SSL@) + +include(CMakeFindDependencyMacro) +find_dependency(Boost 1.64 COMPONENTS system date_time) +find_dependency(Threads) + +if(CROW_ENABLE_COMPRESSION) + find_dependency(ZLIB) +endif() + +if(CROW_ENABLE_SSL) + find_dependency(OpenSSL) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/CrowTargets.cmake") +check_required_components("@PROJECT_NAME@")