rework cmake configs.

See #160 for more info.
This commit is contained in:
Luca Schlecker 2021-08-23 22:30:39 +02:00
parent 3c9e5d1e1d
commit 28acb2c5a7
12 changed files with 177 additions and 241 deletions

View File

@ -18,13 +18,13 @@ steps:
- export TRAVIS_BRANCH=$DRONE_BRANCH - export TRAVIS_BRANCH=$DRONE_BRANCH
- export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER - export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER
- apt-get -y update - 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 - pip3 install mkdocs-material cpp-coveralls pyyaml
- export CC=/usr/bin/gcc - export CC=/usr/bin/gcc
- export CXX=/usr/bin/g++ - export CXX=/usr/bin/g++
- mkdir build - mkdir build
- cd build - cd build
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
- make -j4 - make -j4
- ctest -V -j4 - ctest -V -j4
- cd .. - cd ..
@ -33,7 +33,7 @@ steps:
- export CXX=/usr/bin/clang++ - export CXX=/usr/bin/clang++
- mkdir build-clang - mkdir build-clang
- cd build-clang - cd build-clang
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
- make -j4 - make -j4
- ctest -V -j4 - ctest -V -j4
@ -58,11 +58,11 @@ steps:
commands: commands:
- export DEBIAN_FRONTEND=noninteractive - export DEBIAN_FRONTEND=noninteractive
- apt-get -y update - 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 - mkdir build
- cd build - cd build
- cmake --version - cmake --version
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
- make -j4 - make -j4
- ctest -V -j4 - ctest -V -j4
- cd .. - cd ..
@ -70,7 +70,7 @@ steps:
- export CXX=/usr/bin/clang++ - export CXX=/usr/bin/clang++
- mkdir build-clang - mkdir build-clang
- cd build-clang - cd build-clang
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
- make -j4 - make -j4
- ctest -V -j4 - ctest -V -j4
@ -108,13 +108,13 @@ steps:
- export TRAVIS_BRANCH=$DRONE_REPO_BRANCH - export TRAVIS_BRANCH=$DRONE_REPO_BRANCH
- export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER - export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER
- apt-get -y update - 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 - pip3 install mkdocs-material cpp-coveralls pyyaml
- export CC=/usr/bin/gcc - export CC=/usr/bin/gcc
- export CXX=/usr/bin/g++ - export CXX=/usr/bin/g++
- mkdir build - mkdir build
- cd build - cd build
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
- make -j4 - make -j4
- ctest -V -j4 - ctest -V -j4
- cd .. - cd ..
@ -123,7 +123,7 @@ steps:
- export CXX=/usr/bin/clang++ - export CXX=/usr/bin/clang++
- mkdir build-clang - mkdir build-clang
- cd build-clang - cd build-clang
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
- make -j4 - make -j4
- ctest -V -j4 - ctest -V -j4
- cd .. - cd ..
@ -151,11 +151,11 @@ steps:
commands: commands:
- export DEBIAN_FRONTEND=noninteractive - export DEBIAN_FRONTEND=noninteractive
- apt-get -y update - 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 - mkdir build
- cd build - cd build
- cmake --version - cmake --version
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
- make -j4 - make -j4
- ctest -V -j4 - ctest -V -j4
- cd .. - cd ..
@ -163,7 +163,7 @@ steps:
- export CXX=/usr/bin/clang++ - export CXX=/usr/bin/clang++
- mkdir build-clang - mkdir build-clang
- cd build-clang - cd build-clang
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
- make -j4 - make -j4
- ctest -V -j4 - ctest -V -j4

View File

@ -33,6 +33,7 @@ addons:
- mkdocs - mkdocs
- graphviz - graphviz
- zlib1g-dev - zlib1g-dev
- libssl-dev
before_install: before_install:
- if [ "$TRAVIS_COMPILER" == "gcc" -a "$TRAVIS_CPU_ARCH" == "amd64" ]; then export PUSH_COVERAGE=ON; fi - if [ "$TRAVIS_COMPILER" == "gcc" -a "$TRAVIS_CPU_ARCH" == "amd64" ]; then export PUSH_COVERAGE=ON; fi
@ -45,7 +46,7 @@ before_script:
- mkdir build - mkdir build
- cd build - cd build
- cmake --version - cmake --version
- cmake .. - cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON
script: make -j4 && ctest -V -j4 script: make -j4 && ctest -V -j4

View File

@ -3,17 +3,17 @@
##################################### #####################################
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR) cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
# Define the Project Name and Description # Define the project name and language
project (crow_all LANGUAGES CXX) project(Crow
LANGUAGES CXX
)
# Define the module path # Set required C++ standard
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
# Set required C++ Standard
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) 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") message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")
endif() endif()
@ -21,50 +21,61 @@ endif()
##################################### #####################################
# Define Options # Define Options
##################################### #####################################
option(BUILD_EXAMPLES "Builds the examples in the project" ON) option(CROW_BUILD_EXAMPLES "Build the examples in the project" ON )
option(BUILD_TESTING "Builds the tests 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 )
##################################### option(CROW_ENABLE_SSL "Enable SSL capabilities (OpenSSL)" OFF)
# Define CMake Module Imports option(CROW_ENABLE_COMPRESSION "Enable compression capabilities (ZLIB)" OFF)
#####################################
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()
##################################### #####################################
# Define Targets # Define Targets
##################################### #####################################
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h add_library(Crow INTERFACE)
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/merge_all.py add_library(Crow::Crow ALIAS Crow)
${CMAKE_CURRENT_SOURCE_DIR}/include target_include_directories(Crow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} find_package(Boost 1.64 COMPONENTS system date_time REQUIRED)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/middlewares/*.h find_package(Threads REQUIRED)
target_link_libraries(Crow
INTERFACE
Boost::boost Boost::system Boost::date_time
Threads::Threads
) )
# Amalgamation if(CROW_ENABLE_COMPRESSION)
add_custom_target(amalgamation ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h) 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 # Examples
if(BUILD_EXAMPLES) if(CROW_BUILD_EXAMPLES)
add_subdirectory(examples) add_subdirectory(examples)
endif() endif()
# Tests # Tests
if (NOT MSVC AND BUILD_TESTING) if(NOT MSVC AND CROW_BUILD_TESTS)
add_subdirectory(tests) add_subdirectory(tests)
enable_testing() enable_testing()
add_test(NAME crow_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest) add_test(NAME crow_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest)
@ -74,7 +85,9 @@ endif()
##################################### #####################################
# Install Files # 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_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "CrowCpp") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "CrowCpp")

View File

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

View File

@ -1,22 +1,24 @@
# Compiler options with hardening flags # Compiler options with hardening flags
if(MSVC) function(add_warnings_optimizations target_name)
if(MSVC)
list(APPEND compiler_options target_compile_options(${target_name}
/W4 PRIVATE
/permissive- /W4
$<$<CONFIG:RELEASE>:/O2 /Ob2> /permissive-
$<$<CONFIG:MINSIZEREL>:/O1 /Ob1> $<$<CONFIG:RELEASE>:/O2 /Ob2>
$<$<CONFIG:RELWITHDEBINFO>:/Zi /O2 /Ob1> $<$<CONFIG:MINSIZEREL>:/O1 /Ob1>
$<$<CONFIG:DEBUG>:/Zi /Ob0 /Od /RTC1>) $<$<CONFIG:RELWITHDEBINFO>:/Zi /O2 /Ob1>
$<$<CONFIG:DEBUG>:/Zi /Ob0 /Od /RTC1>
else(MSVC) )
else()
list(APPEND compiler_options target_compile_options(${target_name}
-Wall PRIVATE
-Wextra -Wall
-Wpedantic -Wextra
$<$<CONFIG:RELEASE>:-O2> -Wpedantic
$<$<CONFIG:DEBUG>:-O0 -g -p -pg>) $<$<CONFIG:RELEASE>:-O2>
$<$<CONFIG:DEBUG>:-O0 -g -p -pg>
endif() )
endif()
endfunction()

View File

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

View File

@ -1,91 +1,85 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
project (crow_examples) project(crow_examples)
# Define Required libraries include(${CMAKE_SOURCE_DIR}/cmake/compiler_options.cmake)
list(APPEND REQUIRED_LIBRARIES
${Boost_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
z
)
if (MSVC) add_executable(helloworld helloworld.cpp)
add_executable(example_vs example_vs.cpp) add_warnings_optimizations(helloworld)
target_compile_options(example_vs PRIVATE "${compiler_options}") target_link_libraries(helloworld PUBLIC Crow::Crow)
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})
# If compression is enabled, the example will be built
if(CROW_ENABLE_COMPRESSION)
add_executable(example_compression example_compression.cpp) add_executable(example_compression example_compression.cpp)
target_compile_options(example_compression PRIVATE "${compiler_options}") add_warnings_optimizations(example_compression)
target_link_libraries(example_compression ${REQUIRED_LIBRARIES}) target_link_libraries(example_compression Crow::Crow)
else()
# If OpenSSL is not found, the example won't be built message(STATUS "example_compression example deactivated")
if (OPENSSL_FOUND) endif()
add_executable(example_ssl ssl/example_ssl.cpp)
target_compile_options(example_ssl PRIVATE "${compiler_options}") # If SSL is enabled, the example will be built
target_link_libraries(example_ssl PUBLIC ${REQUIRED_LIBRARIES} ${OPENSSL_LIBRARIES}) if(CROW_ENABLE_SSL)
else() add_executable(example_ssl ssl/example_ssl.cpp)
message(STATUS "example_ssl Example deactivated - OpenSSL was not found") add_warnings_optimizations(example_ssl)
endif() target_link_libraries(example_ssl PUBLIC Crow::Crow)
else()
add_executable(example_websocket websocket/example_ws.cpp) message(STATUS "example_ssl example deactivated")
target_compile_options(example_websocket PRIVATE "${compiler_options}") endif()
target_link_libraries(example_websocket )
target_link_libraries(example_websocket PUBLIC ${REQUIRED_LIBRARIES}) add_executable(example_websocket websocket/example_ws.cpp)
add_custom_command(OUTPUT ws.html add_warnings_optimizations(example_websocket)
COMMAND ${CMAKE_COMMAND} -E target_link_libraries(example_websocket PUBLIC Crow::Crow)
copy ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html ${CMAKE_CURRENT_BINARY_DIR}/templates/ws.html add_custom_command(OUTPUT ws.html
DEPENDS ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html COMMAND ${CMAKE_COMMAND} -E
) copy ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html ${CMAKE_CURRENT_BINARY_DIR}/templates/ws.html
add_custom_target(example_ws_copy ALL DEPENDS ws.html) DEPENDS ${PROJECT_SOURCE_DIR}/websocket/templates/ws.html
)
add_executable(basic_example example.cpp) add_custom_target(example_ws_copy ALL DEPENDS ws.html)
target_compile_options(basic_example PRIVATE "${compiler_options}")
target_link_libraries(basic_example PUBLIC ${REQUIRED_LIBRARIES}) add_executable(basic_example example.cpp)
add_warnings_optimizations(basic_example)
if (Tcmalloc_FOUND) target_link_libraries(basic_example PUBLIC Crow::Crow)
target_link_libraries(basic_example PRIVATE ${Tcmalloc_LIBRARIES}) add_custom_command(OUTPUT example_test.py
endif(Tcmalloc_FOUND) COMMAND ${CMAKE_COMMAND} -E
copy ${PROJECT_SOURCE_DIR}/example_test.py ${CMAKE_CURRENT_BINARY_DIR}/example_test.py
add_executable(example_with_all example_with_all.cpp) DEPENDS ${PROJECT_SOURCE_DIR}/example_test.py
add_dependencies(example_with_all amalgamation) )
target_compile_options(example_with_all PRIVATE "${compiler_options}") add_custom_target(example_copy ALL DEPENDS example_test.py)
target_link_libraries(example_with_all PUBLIC ${REQUIRED_LIBRARIES})
if(CROW_AMALGAMATE)
add_custom_command(OUTPUT example_test.py add_executable(example_with_all example_with_all.cpp)
COMMAND ${CMAKE_COMMAND} -E add_dependencies(example_with_all crow_amalgamated)
copy ${PROJECT_SOURCE_DIR}/example_test.py ${CMAKE_CURRENT_BINARY_DIR}/example_test.py add_warnings_optimizations(example_with_all)
DEPENDS ${PROJECT_SOURCE_DIR}/example_test.py target_include_directories(example_with_all PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
) endif()
add_custom_target(example_copy ALL DEPENDS example_test.py)
add_executable(example_chat example_chat.cpp)
add_executable(example_chat example_chat.cpp) add_warnings_optimizations(example_chat)
target_compile_options(example_chat PRIVATE "${compiler_options}") target_link_libraries(example_chat PUBLIC Crow::Crow)
target_link_libraries(example_chat PUBLIC ${REQUIRED_LIBRARIES}) add_custom_command(OUTPUT example_chat.html
COMMAND ${CMAKE_COMMAND} -E
add_executable(example_static_file example_static_file.cpp) copy ${PROJECT_SOURCE_DIR}/example_chat.html ${CMAKE_CURRENT_BINARY_DIR}/example_chat.html
target_compile_options(example_static_file PRIVATE "${compiler_options}") DEPENDS ${PROJECT_SOURCE_DIR}/example_chat.html
target_link_libraries(example_static_file PUBLIC ${REQUIRED_LIBRARIES}) )
add_custom_target(example_chat_copy ALL DEPENDS example_chat.html)
add_executable(example_catchall example_catchall.cpp)
target_compile_options(example_catchall PRIVATE "${compiler_options}") add_executable(example_static_file example_static_file.cpp)
target_link_libraries(example_catchall PUBLIC ${REQUIRED_LIBRARIES}) add_warnings_optimizations(example_static_file)
target_link_libraries(example_static_file PUBLIC Crow::Crow)
add_executable(example_json_map example_json_map.cpp)
target_compile_options(example_json_map PRIVATE "${compiler_options}") add_executable(example_catchall example_catchall.cpp)
target_link_libraries(example_json_map PUBLIC ${REQUIRED_LIBRARIES}) add_warnings_optimizations(example_catchall)
target_link_libraries(example_catchall PUBLIC Crow::Crow)
add_executable(example_blueprint example_blueprint.cpp)
target_compile_options(example_blueprint PRIVATE "${compiler_options}") add_executable(example_json_map example_json_map.cpp)
target_link_libraries(example_blueprint PUBLIC ${REQUIRED_LIBRARIES}) add_warnings_optimizations(example_json_map)
target_link_libraries(example_json_map PUBLIC Crow::Crow)
add_custom_command(OUTPUT example_chat.html
COMMAND ${CMAKE_COMMAND} -E add_executable(example_blueprint example_blueprint.cpp)
copy ${PROJECT_SOURCE_DIR}/example_chat.html ${CMAKE_CURRENT_BINARY_DIR}/example_chat.html add_warnings_optimizations(example_blueprint)
DEPENDS ${PROJECT_SOURCE_DIR}/example_chat.html target_link_libraries(example_blueprint PUBLIC Crow::Crow)
)
add_custom_target(example_chat_copy ALL DEPENDS example_chat.html) if(MSVC)
add_executable(example_vs example_vs.cpp)
add_warnings_optimizations(example_vs)
target_link_libraries(example_vs Crow::Crow)
endif() endif()

View File

@ -1,5 +1,4 @@
#define CROW_MAIN #define CROW_MAIN
#define CROW_ENABLE_COMPRESSION
#include "crow.h" #include "crow.h"
#include "crow/compression.h" #include "crow/compression.h"

View File

@ -1,4 +1,3 @@
#define CROW_ENABLE_SSL
#define CROW_MAIN #define CROW_MAIN
#include "crow.h" #include "crow.h"

View File

@ -1,16 +1,17 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
project(crow_test) project(crow_test)
include(${CMAKE_SOURCE_DIR}/cmake/compiler_options.cmake)
set(TEST_SRCS set(TEST_SRCS
unittest.cpp unittest.cpp
) )
add_executable(unittest ${TEST_SRCS}) add_executable(unittest ${TEST_SRCS})
target_link_libraries(unittest ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} z) target_link_libraries(unittest Crow::Crow)
# set target compile options as defined in the cmake/compiler_options.cmake Module add_warnings_optimizations(unittest)
target_compile_options(unittest PRIVATE ${compiler_options})
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") set_target_properties(unittest PROPERTIES COMPILE_FLAGS "--coverage -fprofile-arcs -ftest-coverage")
target_link_libraries(unittest gcov) target_link_libraries(unittest gcov)
endif() endif()

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
project (template_test) project(template_test)
set(PROJECT_INCLUDE_DIR set(PROJECT_INCLUDE_DIR
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
@ -10,9 +10,10 @@ set(TEST_SRCS
) )
add_executable(mustachetest ${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") set_target_properties(mustachetest PROPERTIES COMPILE_FLAGS "--coverage -fprofile-arcs -ftest-coverage")
target_link_libraries(mustachetest gcov) target_link_libraries(mustachetest gcov)
endif() endif()

View File

@ -1,5 +1,4 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#define CROW_ENABLE_COMPRESSION
#define CROW_ENABLE_DEBUG #define CROW_ENABLE_DEBUG
#define CROW_LOG_LEVEL 0 #define CROW_LOG_LEVEL 0
#define CROW_MAIN #define CROW_MAIN