Skip to content

Commit 41468b0

Browse files
authored
Merge pull request #228 from CrowCpp/revamped_setup
Revamped setup
2 parents 6b71f92 + 72e33c7 commit 41468b0

37 files changed

+949
-316
lines changed

.drone.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ steps:
1717
- export DEBIAN_FRONTEND=noninteractive
1818
- export TRAVIS_BRANCH=$DRONE_BRANCH
1919
- export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER
20+
- export COVERALLS_PULL_REQUEST=$DRONE_PULL_REQUEST
2021
- apt-get -y update
21-
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git
22-
- pip3 install mkdocs-material cpp-coveralls pyyaml
22+
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git openssl libssl-dev
23+
- pip3 install mkdocs-material pyyaml --no-input
24+
- git clone https://github.com/CrowCpp/cpp-coveralls.git
25+
- cd cpp-coveralls
26+
- pip3 install . --no-input
27+
- cd ..
2328
- export CC=/usr/bin/gcc
2429
- export CXX=/usr/bin/g++
2530
- mkdir build
2631
- cd build
27-
- cmake ..
32+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
2833
- make -j4
2934
- ctest -V -j4
3035
- cd ..
@@ -33,7 +38,7 @@ steps:
3338
- export CXX=/usr/bin/clang++
3439
- mkdir build-clang
3540
- cd build-clang
36-
- cmake ..
41+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
3742
- make -j4
3843
- ctest -V -j4
3944

@@ -58,19 +63,19 @@ steps:
5863
commands:
5964
- export DEBIAN_FRONTEND=noninteractive
6065
- apt-get -y update
61-
- apt-get -y install libboost-all-dev zlib1g-dev gcc clang make cmake python3
66+
- apt-get -y install libboost-all-dev zlib1g-dev gcc clang make cmake python3 openssl libssl-dev
6267
- mkdir build
6368
- cd build
6469
- cmake --version
65-
- cmake ..
70+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
6671
- make -j4
6772
- ctest -V -j4
6873
- cd ..
6974
- export CC=/usr/bin/clang
7075
- export CXX=/usr/bin/clang++
7176
- mkdir build-clang
7277
- cd build-clang
73-
- cmake ..
78+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
7479
- make -j4
7580
- ctest -V -j4
7681

@@ -108,13 +113,17 @@ steps:
108113
- export TRAVIS_BRANCH=$DRONE_REPO_BRANCH
109114
- export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER
110115
- apt-get -y update
111-
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git
112-
- pip3 install mkdocs-material cpp-coveralls pyyaml
116+
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git openssl libssl-dev
117+
- pip3 install mkdocs-material pyyaml --no-input
118+
- git clone https://github.com/CrowCpp/cpp-coveralls.git
119+
- cd cpp-coveralls
120+
- pip3 install . --no-input
121+
- cd ..
113122
- export CC=/usr/bin/gcc
114123
- export CXX=/usr/bin/g++
115124
- mkdir build
116125
- cd build
117-
- cmake ..
126+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
118127
- make -j4
119128
- ctest -V -j4
120129
- cd ..
@@ -123,7 +132,7 @@ steps:
123132
- export CXX=/usr/bin/clang++
124133
- mkdir build-clang
125134
- cd build-clang
126-
- cmake ..
135+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
127136
- make -j4
128137
- ctest -V -j4
129138
- cd ..
@@ -151,19 +160,19 @@ steps:
151160
commands:
152161
- export DEBIAN_FRONTEND=noninteractive
153162
- apt-get -y update
154-
- apt-get -y install libboost-all-dev zlib1g-dev gcc clang make cmake python3
163+
- apt-get -y install libboost-all-dev zlib1g-dev gcc clang make cmake python3 openssl libssl-dev
155164
- mkdir build
156165
- cd build
157166
- cmake --version
158-
- cmake ..
167+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
159168
- make -j4
160169
- ctest -V -j4
161170
- cd ..
162171
- export CC=/usr/bin/clang
163172
- export CXX=/usr/bin/clang++
164173
- mkdir build-clang
165174
- cd build-clang
166-
- cmake ..
175+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
167176
- make -j4
168177
- ctest -V -j4
169178

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ addons:
3333
- mkdocs
3434
- graphviz
3535
- zlib1g-dev
36+
- libssl-dev
3637

3738
before_install:
3839
- if [ "$TRAVIS_COMPILER" == "gcc" -a "$TRAVIS_CPU_ARCH" == "amd64" ]; then export PUSH_COVERAGE=ON; fi
@@ -45,12 +46,12 @@ before_script:
4546
- mkdir build
4647
- cd build
4748
- cmake --version
48-
- cmake ..
49+
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
4950

5051
script: make -j4 && ctest -V -j4
5152

5253
after_success:
5354
- cd ..
54-
- if [ "$PUSH_COVERAGE" == "ON" ]; then coveralls -i include --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp --gcov-options '\-lp'; fi
55+
- if [ "$PUSH_COVERAGE" == "ON" ]; then coveralls -i include --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp --gcov-options '\-lp'; fi
5556
- chmod +x scripts/generateDocumentationAndDeploy.sh
5657
- if [ "$TRAVIS_BUILD_DOCS" == "ON" ]; then ./scripts/generateDocumentationAndDeploy.sh; fi

CMakeLists.txt

Lines changed: 100 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,68 +3,104 @@
33
#####################################
44
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
55

6-
# Define the Project Name and Description
7-
project (crow_all LANGUAGES CXX)
6+
# Define the project name and language
7+
project(Crow
8+
LANGUAGES CXX
9+
)
810

9-
# Define the module path
10-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
11+
# Check if Crow is the main project
12+
set(CROW_IS_MAIN_PROJECT OFF)
13+
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
14+
set(CROW_IS_MAIN_PROJECT ON)
15+
endif()
1116

12-
# Set required C++ Standard
17+
# Set required C++ standard
1318
set(CMAKE_CXX_STANDARD 11)
1419
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
1520

16-
if (NOT CMAKE_BUILD_TYPE)
17-
message(STATUS "No build type selected, default to Release")
18-
set(CMAKE_BUILD_TYPE "Release")
21+
# Default to build type "Release" unless tests are being built
22+
if(NOT CMAKE_BUILD_TYPE)
23+
if (NOT CROW_BUILD_TESTS)
24+
message(STATUS "No build type selected, default to Release")
25+
set(CMAKE_BUILD_TYPE "Release")
26+
else()
27+
message(STATUS "No build type selected but tests are being built, default to Debug")
28+
set(CMAKE_BUILD_TYPE "Debug")
29+
endif()
1930
endif()
2031

2132
#####################################
2233
# Define Options
2334
#####################################
24-
option(BUILD_EXAMPLES "Builds the examples in the project" ON)
25-
option(BUILD_TESTING "Builds the tests in the project" ON)
35+
option(CROW_BUILD_EXAMPLES "Build the examples in the project" ${CROW_IS_MAIN_PROJECT})
36+
option(CROW_BUILD_TESTS "Build the tests in the project" ${CROW_IS_MAIN_PROJECT})
37+
option(CROW_AMALGAMATE "Combine all headers into one" OFF)
38+
option(CROW_INSTALL "Add install step for Crow" ON )
2639

27-
#####################################
28-
# Define CMake Module Imports
29-
#####################################
30-
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/dependencies.cmake)
31-
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/compiler_options.cmake)
40+
option(CROW_ENABLE_SSL "Enable SSL capabilities (OpenSSL)" OFF)
41+
option(CROW_ENABLE_COMPRESSION "Enable compression capabilities (ZLIB)" OFF)
3242

3343
#####################################
34-
# Define project-wide imports
44+
# Define Targets
3545
#####################################
36-
# this can be alternatively (and as recommended way) done with target_include_directories()
37-
if(BUILD_EXAMPLES OR BUILD_TESTING)
38-
set(PROJECT_INCLUDE_DIR
39-
${CMAKE_CURRENT_SOURCE_DIR}/include
40-
)
46+
add_library(Crow INTERFACE)
47+
add_library(Crow::Crow ALIAS Crow)
4148

42-
include_directories("${PROJECT_INCLUDE_DIR}")
43-
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
44-
include_directories("${CMAKE_CURRENT_BINARY_DIR}") # To include crow_all.h
45-
endif()
49+
target_include_directories(Crow
50+
INTERFACE
51+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
52+
$<INSTALL_INTERFACE:include>
53+
)
4654

47-
#####################################
48-
# Define Targets
49-
#####################################
50-
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
51-
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/merge_all.py
52-
${CMAKE_CURRENT_SOURCE_DIR}/include
53-
${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
54-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
55-
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/middlewares/*.h
55+
find_package(Boost 1.64 COMPONENTS system date_time REQUIRED)
56+
find_package(Threads REQUIRED)
57+
58+
target_link_libraries(Crow
59+
INTERFACE
60+
Boost::boost Boost::system Boost::date_time
61+
Threads::Threads
5662
)
5763

58-
# Amalgamation
59-
add_custom_target(amalgamation ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h)
64+
if(CROW_ENABLE_COMPRESSION)
65+
find_package(ZLIB REQUIRED)
66+
target_link_libraries(Crow INTERFACE ZLIB::ZLIB)
67+
target_compile_definitions(Crow INTERFACE CROW_ENABLE_COMPRESSION)
68+
endif()
69+
70+
if(CROW_ENABLE_SSL)
71+
find_package(OpenSSL REQUIRED)
72+
target_link_libraries(Crow INTERFACE OpenSSL::SSL)
73+
target_compile_definitions(Crow INTERFACE CROW_ENABLE_SSL)
74+
endif()
75+
76+
if(CROW_AMALGAMATE)
77+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
78+
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/merge_all.py
79+
${CMAKE_CURRENT_SOURCE_DIR}/include
80+
${CMAKE_CURRENT_BINARY_DIR}/crow_all.h
81+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
82+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/crow/middlewares/*.h
83+
)
84+
85+
add_custom_target(crow_amalgamated ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h)
86+
endif()
6087

6188
# Examples
62-
if(BUILD_EXAMPLES)
89+
if(CROW_BUILD_EXAMPLES)
6390
add_subdirectory(examples)
6491
endif()
6592

6693
# Tests
67-
if (NOT MSVC AND BUILD_TESTING)
94+
if(NOT MSVC AND CROW_BUILD_TESTS)
95+
if(NOT CROW_ENABLE_COMPRESSION)
96+
message(STATUS "Compression tests are omitted. (Configure with CROW_ENABLE_COMPRESSION=ON to enable them)")
97+
endif()
98+
if(NOT CROW_ENABLE_SSL)
99+
message(STATUS "SSL tests are omitted. (Configure with CROW_ENABLE_SSL=ON to enable them)")
100+
else()
101+
add_test(NAME ssl_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/ssl/ssltest)
102+
endif()
103+
68104
add_subdirectory(tests)
69105
enable_testing()
70106
add_test(NAME crow_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/unittest)
@@ -74,10 +110,35 @@ endif()
74110
#####################################
75111
# Install Files
76112
#####################################
77-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/crow_all.h DESTINATION include)
113+
if(CROW_INSTALL)
114+
install(TARGETS Crow EXPORT CrowTargets)
115+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include)
116+
117+
install(EXPORT CrowTargets
118+
FILE CrowTargets.cmake
119+
NAMESPACE Crow::
120+
DESTINATION lib/cmake/Crow
121+
)
122+
123+
include(CMakePackageConfigHelpers)
124+
configure_package_config_file(
125+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/CrowConfig.cmake.in"
126+
"${CMAKE_CURRENT_BINARY_DIR}/CrowConfig.cmake"
127+
INSTALL_DESTINATION lib/cmake/Crow
128+
)
129+
install(FILES
130+
"${CMAKE_CURRENT_BINARY_DIR}/CrowConfig.cmake"
131+
DESTINATION lib/cmake/Crow
132+
)
133+
endif()
78134

79135
set(CPACK_GENERATOR "DEB")
136+
set(CPACK_PACKAGE_NAME "Crow")
80137
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "CrowCpp")
138+
set(CPACK_PACKAGE_VENDOR "CrowCpp")
139+
set(CPACK_PACKAGE_DESCRIPTION "A Fast and Easy to use C++ microframework for the web.")
140+
set(CPACK_PACKAGE_HOMEPAGE_URL "https://crowcpp.org")
141+
set(CPACK_DEBIAN_PACKAGE_DEBUG OFF)
81142
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
82143

83144
include(CPack)

LICENSE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
BSD 3-Clause License
2+
13
Copyright (c) 2014-2017, ipkn
24
2020-2021, CrowCpp
35
All rights reserved.
@@ -27,4 +29,4 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2729
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2830
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2931

30-
The Crow logo and other graphic material (excluding third party logos) used are under Copyright (c) 2021, Farook Al-Sammarraie (The-EDev), All rights reserved.
32+
The Crow logo and other graphic material (excluding third party logos) used are under exclusive Copyright (c) 2021, Farook Al-Sammarraie (The-EDev), All rights reserved.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<a href="https://cloud.drone.io/CrowCpp/Crow"><img src="https://cloud.drone.io/api/badges/CrowCpp/Crow/status.svg" alt="Build Status"></a>
66
<a href="https://coveralls.io/github/CrowCpp/Crow?branch=master"><img src="https://coveralls.io/repos/github/CrowCpp/Crow/badge.svg?branch=master" alt="Coverage Status"></a>
77
<a href="https://crowcpp.org"><img src="https://img.shields.io/badge/-Documentation-informational" alt="Documentation"></a>
8-
<a href="https://gitter.im/crowfork/community?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge"><img src="https://badges.gitter.im/crowfork/community.svg" alt="Gitter"></a>
8+
<a href="https://gitter.im/crowfork/community?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge"><img src="https://img.shields.io/gitter/room/crowfork/community?color=8DDEC5&logo=gitter" alt="Gitter"></a>
99
<a href="https://opencollective.com/crow"><img alt="Open Collective" src="https://img.shields.io/opencollective/all/crow?label=Support%20Crow&logo=opencollective"></a>
1010
</p>
1111

cmake/CrowConfig.cmake.in

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@PACKAGE_INIT@
2+
3+
include(CMakeFindDependencyMacro)
4+
find_dependency(Boost 1.64 COMPONENTS system date_time)
5+
find_dependency(Threads)
6+
7+
if(CROW_ENABLE_COMPRESSION)
8+
find_dependency(ZLIB)
9+
endif()
10+
11+
if(CROW_ENABLE_SSL)
12+
find_dependency(OpenSSL)
13+
endif()
14+
15+
include("${CMAKE_CURRENT_LIST_DIR}/CrowTargets.cmake")
16+
check_required_components("@PROJECT_NAME@")
17+
18+
get_target_property(_CROW_ILL Crow::Crow INTERFACE_LINK_LIBRARIES)
19+
get_target_property(_CROW_ICD Crow::Crow INTERFACE_COMPILE_DEFINITIONS)
20+
21+
list(REMOVE_ITEM _CROW_ILL "ZLIB::ZLIB" "OpenSSL::SSL")
22+
list(REMOVE_ITEM _CROW_ICD "CROW_ENABLE_SSL" "CROW_ENABLE_COMPRESSION")
23+
24+
if(CROW_ENABLE_COMPRESSION)
25+
list(APPEND _CROW_ILL "ZLIB::ZLIB")
26+
list(APPEND _CROW_ICD "CROW_ENABLE_COMPRESSION")
27+
endif()
28+
29+
if(CROW_ENABLE_SSL)
30+
list(APPEND _CROW_ILL "OpenSSL::SSL")
31+
list(APPEND _CROW_ICD "CROW_ENABLE_SSL")
32+
endif()
33+
34+
set_target_properties(Crow::Crow PROPERTIES
35+
INTERFACE_COMPILE_DEFINITIONS "${_CROW_ICD}"
36+
INTERFACE_LINK_LIBRARIES "${_CROW_ILL}"
37+
)

0 commit comments

Comments
 (0)