mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
parent
3c9e5d1e1d
commit
28acb2c5a7
24
.drone.yml
24
.drone.yml
@ -18,13 +18,13 @@ steps:
|
||||
- export TRAVIS_BRANCH=$DRONE_BRANCH
|
||||
- export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER
|
||||
- apt-get -y update
|
||||
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git
|
||||
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev libssl-dev gcc clang make cmake python3 python3-pip git
|
||||
- pip3 install mkdocs-material cpp-coveralls pyyaml
|
||||
- export CC=/usr/bin/gcc
|
||||
- export CXX=/usr/bin/g++
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
- make -j4
|
||||
- ctest -V -j4
|
||||
- cd ..
|
||||
@ -33,7 +33,7 @@ steps:
|
||||
- export CXX=/usr/bin/clang++
|
||||
- mkdir build-clang
|
||||
- cd build-clang
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
- make -j4
|
||||
- ctest -V -j4
|
||||
|
||||
@ -58,11 +58,11 @@ steps:
|
||||
commands:
|
||||
- export DEBIAN_FRONTEND=noninteractive
|
||||
- apt-get -y update
|
||||
- apt-get -y install libboost-all-dev zlib1g-dev gcc clang make cmake python3
|
||||
- apt-get -y install libboost-all-dev zlib1g-dev libssl-dev gcc clang make cmake python3
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake --version
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
- make -j4
|
||||
- ctest -V -j4
|
||||
- cd ..
|
||||
@ -70,7 +70,7 @@ steps:
|
||||
- export CXX=/usr/bin/clang++
|
||||
- mkdir build-clang
|
||||
- cd build-clang
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
- make -j4
|
||||
- ctest -V -j4
|
||||
|
||||
@ -108,13 +108,13 @@ steps:
|
||||
- export TRAVIS_BRANCH=$DRONE_REPO_BRANCH
|
||||
- export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER
|
||||
- apt-get -y update
|
||||
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git
|
||||
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev libssl-dev gcc clang make cmake python3 python3-pip git
|
||||
- pip3 install mkdocs-material cpp-coveralls pyyaml
|
||||
- export CC=/usr/bin/gcc
|
||||
- export CXX=/usr/bin/g++
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
- make -j4
|
||||
- ctest -V -j4
|
||||
- cd ..
|
||||
@ -123,7 +123,7 @@ steps:
|
||||
- export CXX=/usr/bin/clang++
|
||||
- mkdir build-clang
|
||||
- cd build-clang
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
- make -j4
|
||||
- ctest -V -j4
|
||||
- cd ..
|
||||
@ -151,11 +151,11 @@ steps:
|
||||
commands:
|
||||
- export DEBIAN_FRONTEND=noninteractive
|
||||
- apt-get -y update
|
||||
- apt-get -y install libboost-all-dev zlib1g-dev gcc clang make cmake python3
|
||||
- apt-get -y install libboost-all-dev zlib1g-dev libssl-dev gcc clang make cmake python3
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake --version
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
- make -j4
|
||||
- ctest -V -j4
|
||||
- cd ..
|
||||
@ -163,7 +163,7 @@ steps:
|
||||
- export CXX=/usr/bin/clang++
|
||||
- mkdir build-clang
|
||||
- cd build-clang
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
- make -j4
|
||||
- ctest -V -j4
|
||||
|
||||
|
@ -33,6 +33,7 @@ addons:
|
||||
- mkdocs
|
||||
- graphviz
|
||||
- zlib1g-dev
|
||||
- libssl-dev
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_COMPILER" == "gcc" -a "$TRAVIS_CPU_ARCH" == "amd64" ]; then export PUSH_COVERAGE=ON; fi
|
||||
@ -45,7 +46,7 @@ before_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake --version
|
||||
- cmake ..
|
||||
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
|
||||
|
||||
script: make -j4 && ctest -V -j4
|
||||
|
||||
|
@ -3,17 +3,17 @@
|
||||
#####################################
|
||||
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
|
||||
|
||||
# Define the Project Name and Description
|
||||
project (crow_all LANGUAGES CXX)
|
||||
# Define the project name and language
|
||||
project(Crow
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
# Define the module path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
||||
|
||||
# Set required C++ Standard
|
||||
# Set required C++ standard
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
# Default to build type "Release"
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "No build type selected, default to Release")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
@ -21,50 +21,61 @@ endif()
|
||||
#####################################
|
||||
# Define Options
|
||||
#####################################
|
||||
option(BUILD_EXAMPLES "Builds the examples in the project" ON)
|
||||
option(BUILD_TESTING "Builds the tests in the project" ON)
|
||||
option(CROW_BUILD_EXAMPLES "Build the examples in the project" ON )
|
||||
option(CROW_BUILD_TESTS "Build the tests in the project" ON )
|
||||
option(CROW_AMALGAMATE "Combine all headers into one" OFF)
|
||||
option(CROW_INSTALL "Add install step for Crow" ON )
|
||||
|
||||
#####################################
|
||||
# Define CMake Module Imports
|
||||
#####################################
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/compiler_options.cmake)
|
||||
|
||||
#####################################
|
||||
# Define project-wide imports
|
||||
#####################################
|
||||
# this can be alternatively (and as recommended way) done with target_include_directories()
|
||||
if(BUILD_EXAMPLES OR BUILD_TESTING)
|
||||
set(PROJECT_INCLUDE_DIR
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
include_directories("${PROJECT_INCLUDE_DIR}")
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}") # To include crow_all.h
|
||||
endif()
|
||||
option(CROW_ENABLE_SSL "Enable SSL capabilities (OpenSSL)" OFF)
|
||||
option(CROW_ENABLE_COMPRESSION "Enable compression capabilities (ZLIB)" OFF)
|
||||
|
||||
#####################################
|
||||
# Define Targets
|
||||
#####################################
|
||||
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_library(Crow INTERFACE)
|
||||
add_library(Crow::Crow ALIAS Crow)
|
||||
target_include_directories(Crow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
find_package(Boost 1.64 COMPONENTS system date_time REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
target_link_libraries(Crow
|
||||
INTERFACE
|
||||
Boost::boost Boost::system Boost::date_time
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
# Amalgamation
|
||||
add_custom_target(amalgamation ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h)
|
||||
if(CROW_ENABLE_COMPRESSION)
|
||||
find_package(ZLIB REQUIRED)
|
||||
target_link_libraries(Crow INTERFACE ZLIB::ZLIB)
|
||||
target_compile_definitions(Crow INTERFACE CROW_ENABLE_COMPRESSION)
|
||||
endif()
|
||||
|
||||
if(CROW_ENABLE_SSL)
|
||||
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()
|
||||
|
||||
# Examples
|
||||
if(BUILD_EXAMPLES)
|
||||
if(CROW_BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
# Tests
|
||||
if (NOT MSVC AND BUILD_TESTING)
|
||||
if(NOT MSVC AND CROW_BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
enable_testing()
|
||||
add_test(NAME crow_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest)
|
||||
@ -74,7 +85,9 @@ endif()
|
||||
#####################################
|
||||
# Install Files
|
||||
#####################################
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h DESTINATION include)
|
||||
if(CROW_INSTALL)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include)
|
||||
endif()
|
||||
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "CrowCpp")
|
||||
|
@ -1,38 +0,0 @@
|
||||
# - Find Tcmalloc
|
||||
# Find the native Tcmalloc library
|
||||
#
|
||||
# Tcmalloc_LIBRARIES - List of libraries when using Tcmalloc.
|
||||
# Tcmalloc_FOUND - True if Tcmalloc found.
|
||||
|
||||
if (USE_TCMALLOC)
|
||||
set(Tcmalloc_NAMES tcmalloc)
|
||||
else ()
|
||||
set(Tcmalloc_NAMES tcmalloc_minimal tcmalloc)
|
||||
endif ()
|
||||
|
||||
find_library(Tcmalloc_LIBRARY NO_DEFAULT_PATH
|
||||
NAMES ${Tcmalloc_NAMES}
|
||||
PATHS ${HT_DEPENDENCY_LIB_DIR} /lib /usr/lib /usr/local/lib /opt/local/lib
|
||||
)
|
||||
|
||||
if (Tcmalloc_LIBRARY)
|
||||
set(Tcmalloc_FOUND TRUE)
|
||||
set( Tcmalloc_LIBRARIES ${Tcmalloc_LIBRARY} )
|
||||
else ()
|
||||
set(Tcmalloc_FOUND FALSE)
|
||||
set( Tcmalloc_LIBRARIES )
|
||||
endif ()
|
||||
|
||||
if (Tcmalloc_FOUND)
|
||||
message(STATUS "Found Tcmalloc: ${Tcmalloc_LIBRARY}")
|
||||
else ()
|
||||
message(STATUS "Not Found Tcmalloc: ${Tcmalloc_LIBRARY}")
|
||||
if (Tcmalloc_FIND_REQUIRED)
|
||||
message(STATUS "Looked for Tcmalloc libraries named ${Tcmalloc_NAMES}.")
|
||||
message(FATAL_ERROR "Could NOT find Tcmalloc library")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(
|
||||
Tcmalloc_LIBRARY
|
||||
)
|
@ -1,22 +1,24 @@
|
||||
# Compiler options with hardening flags
|
||||
|
||||
if(MSVC)
|
||||
|
||||
list(APPEND compiler_options
|
||||
/W4
|
||||
/permissive-
|
||||
$<$<CONFIG:RELEASE>:/O2 /Ob2>
|
||||
$<$<CONFIG:MINSIZEREL>:/O1 /Ob1>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:/Zi /O2 /Ob1>
|
||||
$<$<CONFIG:DEBUG>:/Zi /Ob0 /Od /RTC1>)
|
||||
|
||||
else(MSVC)
|
||||
|
||||
list(APPEND compiler_options
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
$<$<CONFIG:RELEASE>:-O2>
|
||||
$<$<CONFIG:DEBUG>:-O0 -g -p -pg>)
|
||||
|
||||
endif()
|
||||
function(add_warnings_optimizations target_name)
|
||||
if(MSVC)
|
||||
target_compile_options(${target_name}
|
||||
PRIVATE
|
||||
/W4
|
||||
/permissive-
|
||||
$<$<CONFIG:RELEASE>:/O2 /Ob2>
|
||||
$<$<CONFIG:MINSIZEREL>:/O1 /Ob1>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:/Zi /O2 /Ob1>
|
||||
$<$<CONFIG:DEBUG>:/Zi /Ob0 /Od /RTC1>
|
||||
)
|
||||
else()
|
||||
target_compile_options(${target_name}
|
||||
PRIVATE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
$<$<CONFIG:RELEASE>:-O2>
|
||||
$<$<CONFIG:DEBUG>:-O0 -g -p -pg>
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -1,35 +0,0 @@
|
||||
# Dependencies
|
||||
|
||||
if(BUILD_EXAMPLES OR BUILD_TESTING)
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if(CCACHE_FOUND)
|
||||
message("Found ccache ${CCACHE_FOUND}")
|
||||
message("Using ccache to speed up compilation")
|
||||
set(ENV{CCACHE_CPP2} "yes")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif(CCACHE_FOUND)
|
||||
|
||||
find_package(Tcmalloc)
|
||||
find_package(Threads)
|
||||
|
||||
if (MSVC)
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
find_package( Boost 1.64.0 COMPONENTS system thread regex REQUIRED )
|
||||
else()
|
||||
find_package( Boost 1.64.0 COMPONENTS system thread REQUIRED )
|
||||
endif()
|
||||
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_EXAMPLES)
|
||||
# OpenSSL is needed at runtime dynamically by some examples
|
||||
# if it isn't installed, the examples won't be built
|
||||
find_package(OpenSSL)
|
||||
if(OPENSSL_FOUND)
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
endif()
|
@ -1,91 +1,85 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project (crow_examples)
|
||||
project(crow_examples)
|
||||
|
||||
# Define Required libraries
|
||||
list(APPEND REQUIRED_LIBRARIES
|
||||
${Boost_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
z
|
||||
)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler_options.cmake)
|
||||
|
||||
if (MSVC)
|
||||
add_executable(example_vs example_vs.cpp)
|
||||
target_compile_options(example_vs PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_vs )
|
||||
else ()
|
||||
add_executable(helloworld helloworld.cpp)
|
||||
target_compile_options(helloworld PRIVATE "${compiler_options}")
|
||||
target_link_libraries(helloworld PUBLIC ${REQUIRED_LIBRARIES})
|
||||
add_executable(helloworld helloworld.cpp)
|
||||
add_warnings_optimizations(helloworld)
|
||||
target_link_libraries(helloworld PUBLIC Crow::Crow)
|
||||
|
||||
# If compression is enabled, the example will be built
|
||||
if(CROW_ENABLE_COMPRESSION)
|
||||
add_executable(example_compression example_compression.cpp)
|
||||
target_compile_options(example_compression PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_compression ${REQUIRED_LIBRARIES})
|
||||
|
||||
# If OpenSSL is not found, the example won't be built
|
||||
if (OPENSSL_FOUND)
|
||||
add_executable(example_ssl ssl/example_ssl.cpp)
|
||||
target_compile_options(example_ssl PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_ssl PUBLIC ${REQUIRED_LIBRARIES} ${OPENSSL_LIBRARIES})
|
||||
else()
|
||||
message(STATUS "example_ssl Example deactivated - OpenSSL was not found")
|
||||
endif()
|
||||
|
||||
add_executable(example_websocket websocket/example_ws.cpp)
|
||||
target_compile_options(example_websocket PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_websocket )
|
||||
target_link_libraries(example_websocket PUBLIC ${REQUIRED_LIBRARIES})
|
||||
add_custom_command(OUTPUT ws.html
|
||||
COMMAND ${CMAKE_COMMAND} -E
|
||||
copy ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html ${CMAKE_CURRENT_BINARY_DIR}/templates/ws.html
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html
|
||||
)
|
||||
add_custom_target(example_ws_copy ALL DEPENDS ws.html)
|
||||
|
||||
add_executable(basic_example example.cpp)
|
||||
target_compile_options(basic_example PRIVATE "${compiler_options}")
|
||||
target_link_libraries(basic_example PUBLIC ${REQUIRED_LIBRARIES})
|
||||
|
||||
if (Tcmalloc_FOUND)
|
||||
target_link_libraries(basic_example PRIVATE ${Tcmalloc_LIBRARIES})
|
||||
endif(Tcmalloc_FOUND)
|
||||
|
||||
add_executable(example_with_all example_with_all.cpp)
|
||||
add_dependencies(example_with_all amalgamation)
|
||||
target_compile_options(example_with_all PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_with_all PUBLIC ${REQUIRED_LIBRARIES})
|
||||
|
||||
add_custom_command(OUTPUT example_test.py
|
||||
COMMAND ${CMAKE_COMMAND} -E
|
||||
copy ${PROJECT_SOURCE_DIR}/example_test.py ${CMAKE_CURRENT_BINARY_DIR}/example_test.py
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/example_test.py
|
||||
)
|
||||
add_custom_target(example_copy ALL DEPENDS example_test.py)
|
||||
|
||||
add_executable(example_chat example_chat.cpp)
|
||||
target_compile_options(example_chat PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_chat PUBLIC ${REQUIRED_LIBRARIES})
|
||||
|
||||
add_executable(example_static_file example_static_file.cpp)
|
||||
target_compile_options(example_static_file PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_static_file PUBLIC ${REQUIRED_LIBRARIES})
|
||||
|
||||
add_executable(example_catchall example_catchall.cpp)
|
||||
target_compile_options(example_catchall PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_catchall PUBLIC ${REQUIRED_LIBRARIES})
|
||||
|
||||
add_executable(example_json_map example_json_map.cpp)
|
||||
target_compile_options(example_json_map PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_json_map PUBLIC ${REQUIRED_LIBRARIES})
|
||||
|
||||
add_executable(example_blueprint example_blueprint.cpp)
|
||||
target_compile_options(example_blueprint PRIVATE "${compiler_options}")
|
||||
target_link_libraries(example_blueprint PUBLIC ${REQUIRED_LIBRARIES})
|
||||
|
||||
add_custom_command(OUTPUT example_chat.html
|
||||
COMMAND ${CMAKE_COMMAND} -E
|
||||
copy ${PROJECT_SOURCE_DIR}/example_chat.html ${CMAKE_CURRENT_BINARY_DIR}/example_chat.html
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/example_chat.html
|
||||
)
|
||||
add_custom_target(example_chat_copy ALL DEPENDS example_chat.html)
|
||||
|
||||
add_warnings_optimizations(example_compression)
|
||||
target_link_libraries(example_compression Crow::Crow)
|
||||
else()
|
||||
message(STATUS "example_compression example deactivated")
|
||||
endif()
|
||||
|
||||
# If SSL is enabled, the example will be built
|
||||
if(CROW_ENABLE_SSL)
|
||||
add_executable(example_ssl ssl/example_ssl.cpp)
|
||||
add_warnings_optimizations(example_ssl)
|
||||
target_link_libraries(example_ssl PUBLIC Crow::Crow)
|
||||
else()
|
||||
message(STATUS "example_ssl example deactivated")
|
||||
endif()
|
||||
|
||||
add_executable(example_websocket websocket/example_ws.cpp)
|
||||
add_warnings_optimizations(example_websocket)
|
||||
target_link_libraries(example_websocket PUBLIC Crow::Crow)
|
||||
add_custom_command(OUTPUT ws.html
|
||||
COMMAND ${CMAKE_COMMAND} -E
|
||||
copy ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html ${CMAKE_CURRENT_BINARY_DIR}/templates/ws.html
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html
|
||||
)
|
||||
add_custom_target(example_ws_copy ALL DEPENDS ws.html)
|
||||
|
||||
add_executable(basic_example example.cpp)
|
||||
add_warnings_optimizations(basic_example)
|
||||
target_link_libraries(basic_example PUBLIC Crow::Crow)
|
||||
add_custom_command(OUTPUT example_test.py
|
||||
COMMAND ${CMAKE_COMMAND} -E
|
||||
copy ${PROJECT_SOURCE_DIR}/example_test.py ${CMAKE_CURRENT_BINARY_DIR}/example_test.py
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/example_test.py
|
||||
)
|
||||
add_custom_target(example_copy ALL DEPENDS example_test.py)
|
||||
|
||||
if(CROW_AMALGAMATE)
|
||||
add_executable(example_with_all example_with_all.cpp)
|
||||
add_dependencies(example_with_all crow_amalgamated)
|
||||
add_warnings_optimizations(example_with_all)
|
||||
target_include_directories(example_with_all PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
add_executable(example_chat example_chat.cpp)
|
||||
add_warnings_optimizations(example_chat)
|
||||
target_link_libraries(example_chat PUBLIC Crow::Crow)
|
||||
add_custom_command(OUTPUT example_chat.html
|
||||
COMMAND ${CMAKE_COMMAND} -E
|
||||
copy ${PROJECT_SOURCE_DIR}/example_chat.html ${CMAKE_CURRENT_BINARY_DIR}/example_chat.html
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/example_chat.html
|
||||
)
|
||||
add_custom_target(example_chat_copy ALL DEPENDS example_chat.html)
|
||||
|
||||
add_executable(example_static_file example_static_file.cpp)
|
||||
add_warnings_optimizations(example_static_file)
|
||||
target_link_libraries(example_static_file PUBLIC Crow::Crow)
|
||||
|
||||
add_executable(example_catchall example_catchall.cpp)
|
||||
add_warnings_optimizations(example_catchall)
|
||||
target_link_libraries(example_catchall PUBLIC Crow::Crow)
|
||||
|
||||
add_executable(example_json_map example_json_map.cpp)
|
||||
add_warnings_optimizations(example_json_map)
|
||||
target_link_libraries(example_json_map PUBLIC Crow::Crow)
|
||||
|
||||
add_executable(example_blueprint example_blueprint.cpp)
|
||||
add_warnings_optimizations(example_blueprint)
|
||||
target_link_libraries(example_blueprint PUBLIC Crow::Crow)
|
||||
|
||||
if(MSVC)
|
||||
add_executable(example_vs example_vs.cpp)
|
||||
add_warnings_optimizations(example_vs)
|
||||
target_link_libraries(example_vs Crow::Crow)
|
||||
endif()
|
||||
|
@ -1,5 +1,4 @@
|
||||
#define CROW_MAIN
|
||||
#define CROW_ENABLE_COMPRESSION
|
||||
#include "crow.h"
|
||||
#include "crow/compression.h"
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
#define CROW_ENABLE_SSL
|
||||
#define CROW_MAIN
|
||||
#include "crow.h"
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(crow_test)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler_options.cmake)
|
||||
|
||||
set(TEST_SRCS
|
||||
unittest.cpp
|
||||
)
|
||||
|
||||
add_executable(unittest ${TEST_SRCS})
|
||||
target_link_libraries(unittest ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} z)
|
||||
# set target compile options as defined in the cmake/compiler_options.cmake Module
|
||||
target_compile_options(unittest PRIVATE ${compiler_options})
|
||||
target_link_libraries(unittest Crow::Crow)
|
||||
add_warnings_optimizations(unittest)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set_target_properties(unittest PROPERTIES COMPILE_FLAGS "--coverage -fprofile-arcs -ftest-coverage")
|
||||
target_link_libraries(unittest gcov)
|
||||
endif()
|
||||
|
@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project (template_test)
|
||||
project(template_test)
|
||||
|
||||
set(PROJECT_INCLUDE_DIR
|
||||
set(PROJECT_INCLUDE_DIR
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
@ -10,9 +10,10 @@ set(TEST_SRCS
|
||||
)
|
||||
|
||||
add_executable(mustachetest ${TEST_SRCS})
|
||||
target_compile_options(mustachetest PRIVATE "${compiler_options}")
|
||||
target_link_libraries(mustachetest Crow::Crow)
|
||||
add_warnings_optimizations(mustachetest)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set_target_properties(mustachetest PROPERTIES COMPILE_FLAGS "--coverage -fprofile-arcs -ftest-coverage")
|
||||
target_link_libraries(mustachetest gcov)
|
||||
endif()
|
||||
|
@ -1,5 +1,4 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#define CROW_ENABLE_COMPRESSION
|
||||
#define CROW_ENABLE_DEBUG
|
||||
#define CROW_LOG_LEVEL 0
|
||||
#define CROW_MAIN
|
||||
|
Loading…
Reference in New Issue
Block a user