add find_package support.

This commit is contained in:
Luca Schlecker 2021-08-29 16:20:45 +02:00
parent f90f9b8e61
commit fda2cddc70
2 changed files with 43 additions and 1 deletions

View File

@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
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")

19
cmake/CrowConfig.cmake.in Normal file
View File

@ -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@")