2021-01-08 15:13:39 +00:00
|
|
|
#####################################
|
|
|
|
# Define Project-Wide Settings
|
|
|
|
#####################################
|
|
|
|
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
|
|
|
|
|
2021-08-23 20:30:39 +00:00
|
|
|
# Define the project name and language
|
|
|
|
project(Crow
|
|
|
|
LANGUAGES CXX
|
2024-01-23 18:55:12 +00:00
|
|
|
VERSION 1.1.1
|
2021-08-23 20:30:39 +00:00
|
|
|
)
|
2016-11-19 10:18:21 +00:00
|
|
|
|
2022-06-22 16:08:13 +00:00
|
|
|
# Make sure Findasio.cmake module is found
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
|
2021-09-09 15:19:20 +00:00
|
|
|
# Check if Crow is the main project
|
|
|
|
set(CROW_IS_MAIN_PROJECT OFF)
|
|
|
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
|
|
set(CROW_IS_MAIN_PROJECT ON)
|
|
|
|
endif()
|
2016-10-03 11:47:22 +00:00
|
|
|
|
2021-08-23 20:30:39 +00:00
|
|
|
# Set required C++ standard
|
2021-01-06 07:10:59 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
2021-01-08 15:13:39 +00:00
|
|
|
|
2021-09-27 11:56:17 +00:00
|
|
|
# Default to build type "Release" unless tests are being built
|
2021-08-23 20:30:39 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2021-09-27 11:56:17 +00:00
|
|
|
if (NOT CROW_BUILD_TESTS)
|
|
|
|
message(STATUS "No build type selected, default to Release")
|
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
|
|
else()
|
|
|
|
message(STATUS "No build type selected but tests are being built, default to Debug")
|
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
|
|
endif()
|
2014-08-06 23:31:27 +00:00
|
|
|
endif()
|
2023-07-02 21:39:55 +00:00
|
|
|
if (MSVC)
|
|
|
|
add_compile_options(/bigobj)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
include(FindPython3)
|
|
|
|
find_package(Python3)
|
2014-08-06 23:31:27 +00:00
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
#####################################
|
|
|
|
# Define Options
|
|
|
|
#####################################
|
2021-09-09 15:19:20 +00:00
|
|
|
option(CROW_BUILD_EXAMPLES "Build the examples in the project" ${CROW_IS_MAIN_PROJECT})
|
|
|
|
option(CROW_BUILD_TESTS "Build the tests in the project" ${CROW_IS_MAIN_PROJECT})
|
2021-08-23 20:30:39 +00:00
|
|
|
option(CROW_AMALGAMATE "Combine all headers into one" OFF)
|
|
|
|
option(CROW_INSTALL "Add install step for Crow" ON )
|
2021-01-08 15:13:39 +00:00
|
|
|
|
2022-04-03 21:42:13 +00:00
|
|
|
# Possible values: ssl, compression
|
|
|
|
option(CROW_FEATURES "Enable features extending Crow's abilities" "")
|
2021-01-08 15:13:39 +00:00
|
|
|
|
|
|
|
#####################################
|
2021-08-23 20:30:39 +00:00
|
|
|
# Define Targets
|
2021-01-08 15:13:39 +00:00
|
|
|
#####################################
|
2021-08-23 20:30:39 +00:00
|
|
|
add_library(Crow INTERFACE)
|
|
|
|
add_library(Crow::Crow ALIAS Crow)
|
2021-01-08 15:13:39 +00:00
|
|
|
|
2021-08-29 14:20:45 +00:00
|
|
|
target_include_directories(Crow
|
|
|
|
INTERFACE
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
|
|
$<INSTALL_INTERFACE:include>
|
|
|
|
)
|
2015-02-20 20:46:28 +00:00
|
|
|
|
2022-06-22 16:08:13 +00:00
|
|
|
find_package(asio REQUIRED)
|
2015-02-20 20:46:28 +00:00
|
|
|
|
2021-08-23 20:30:39 +00:00
|
|
|
target_link_libraries(Crow
|
|
|
|
INTERFACE
|
2022-06-22 16:08:13 +00:00
|
|
|
asio::asio
|
2022-06-06 16:52:43 +00:00
|
|
|
)
|
2014-08-06 16:18:33 +00:00
|
|
|
|
2022-11-26 17:54:08 +00:00
|
|
|
target_compile_definitions(Crow INTERFACE "")
|
|
|
|
|
2022-04-03 21:42:13 +00:00
|
|
|
if("compression" IN_LIST CROW_FEATURES)
|
2021-08-23 20:30:39 +00:00
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
target_link_libraries(Crow INTERFACE ZLIB::ZLIB)
|
|
|
|
target_compile_definitions(Crow INTERFACE CROW_ENABLE_COMPRESSION)
|
|
|
|
endif()
|
|
|
|
|
2022-04-03 21:42:13 +00:00
|
|
|
if("ssl" IN_LIST CROW_FEATURES)
|
2021-08-23 20:30:39 +00:00
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
target_link_libraries(Crow INTERFACE OpenSSL::SSL)
|
|
|
|
target_compile_definitions(Crow INTERFACE CROW_ENABLE_SSL)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CROW_AMALGAMATE)
|
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
|
|
|
|
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/merge_all.py
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/middlewares/*.h
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(crow_amalgamated ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h)
|
|
|
|
endif()
|
2016-11-22 16:50:06 +00:00
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
# Examples
|
2021-08-23 20:30:39 +00:00
|
|
|
if(CROW_BUILD_EXAMPLES)
|
2021-01-08 15:13:39 +00:00
|
|
|
add_subdirectory(examples)
|
2021-01-06 07:10:59 +00:00
|
|
|
endif()
|
2016-10-03 11:47:22 +00:00
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
# Tests
|
2023-07-02 21:39:55 +00:00
|
|
|
if(CROW_BUILD_TESTS)
|
|
|
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
enable_testing()
|
|
|
|
add_test(
|
|
|
|
NAME crow_test
|
|
|
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT "compression" IN_LIST CROW_FEATURES)
|
|
|
|
message(STATUS "Compression tests are omitted. (Configure with CROW_FEATURES containing 'compression' to enable them)")
|
|
|
|
endif()
|
|
|
|
if(NOT "ssl" IN_LIST CROW_FEATURES)
|
|
|
|
message(STATUS "SSL tests are omitted. (Configure with CROW_FEATURES containing 'ssl' to enable them)")
|
|
|
|
else()
|
|
|
|
if(NOT MSVC)
|
|
|
|
add_test(
|
|
|
|
NAME ssl_test
|
|
|
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/ssl/ssltest
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-01-06 07:10:59 +00:00
|
|
|
endif()
|
2014-08-07 16:14:27 +00:00
|
|
|
|
2021-01-08 15:13:39 +00:00
|
|
|
#####################################
|
|
|
|
# Install Files
|
|
|
|
#####################################
|
2021-08-23 20:30:39 +00:00
|
|
|
if(CROW_INSTALL)
|
2023-05-23 07:38:19 +00:00
|
|
|
include(GNUInstallDirs)
|
2021-08-29 14:20:45 +00:00
|
|
|
install(TARGETS Crow EXPORT CrowTargets)
|
2023-05-23 07:38:19 +00:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
)
|
2021-08-29 14:20:45 +00:00
|
|
|
|
|
|
|
install(EXPORT CrowTargets
|
|
|
|
FILE CrowTargets.cmake
|
|
|
|
NAMESPACE Crow::
|
2023-05-23 07:38:19 +00:00
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Crow"
|
2021-08-29 14:20:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
configure_package_config_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/CrowConfig.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/CrowConfig.cmake"
|
2023-05-23 07:38:19 +00:00
|
|
|
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Crow"
|
2021-08-29 14:20:45 +00:00
|
|
|
)
|
|
|
|
install(FILES
|
2022-06-22 16:08:13 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Findasio.cmake"
|
2023-05-23 07:38:19 +00:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/CrowConfig.cmake"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Crow"
|
|
|
|
)
|
2021-08-23 20:30:39 +00:00
|
|
|
endif()
|
2021-07-03 20:02:32 +00:00
|
|
|
|
2024-01-23 18:55:12 +00:00
|
|
|
set(CPACK_GENERATOR "ZIP")
|
2021-09-22 03:34:12 +00:00
|
|
|
set(CPACK_PACKAGE_NAME "Crow")
|
2021-07-03 20:02:32 +00:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "CrowCpp")
|
2021-09-22 03:34:12 +00:00
|
|
|
set(CPACK_PACKAGE_VENDOR "CrowCpp")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION "A Fast and Easy to use C++ microframework for the web.")
|
|
|
|
set(CPACK_PACKAGE_HOMEPAGE_URL "https://crowcpp.org")
|
2022-10-30 17:56:58 +00:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all")
|
2021-09-22 03:34:12 +00:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEBUG OFF)
|
2022-10-30 17:56:58 +00:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libasio-dev")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_SECTION "libdevel")
|
2021-07-03 20:02:32 +00:00
|
|
|
|
|
|
|
include(CPack)
|
2021-12-18 07:00:51 +00:00
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Uninstall Files
|
|
|
|
#####################################
|
|
|
|
if(NOT TARGET uninstall)
|
|
|
|
configure_file(
|
2021-12-19 07:27:17 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
2021-12-18 07:00:51 +00:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(uninstall
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
|
|
endif()
|