Skip to content

Commit 2b45f02

Browse files
authored
Merge pull request ipkn#384 from CrowCpp/crow-features
ipkn#380: Update CMake config.
2 parents 391bd2d + 6ffaf23 commit 2b45f02

File tree

7 files changed

+30
-27
lines changed

7 files changed

+30
-27
lines changed

.drone.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ steps:
3434
- export CXX=/usr/bin/g++
3535
- mkdir build
3636
- cd build
37-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
37+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
3838
- make -j4
3939
- ctest -V -j4
4040
- cd ..
@@ -48,7 +48,7 @@ steps:
4848
- export CXX=/usr/bin/clang++
4949
- mkdir build-clang
5050
- cd build-clang
51-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
51+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
5252
- make -j4
5353
- ctest -V -j4
5454

@@ -77,15 +77,15 @@ steps:
7777
- mkdir build
7878
- cd build
7979
- cmake --version
80-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
80+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
8181
- make -j4
8282
- ctest -V -j4
8383
- cd ..
8484
- export CC=/usr/bin/clang
8585
- export CXX=/usr/bin/clang++
8686
- mkdir build-clang
8787
- cd build-clang
88-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
88+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
8989
- make -j4
9090
- ctest -V -j4
9191

@@ -133,7 +133,7 @@ steps:
133133
- export CXX=/usr/bin/g++
134134
- mkdir build
135135
- cd build
136-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
136+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
137137
- make -j4
138138
- ctest -V -j4
139139
- cd ..
@@ -142,7 +142,7 @@ steps:
142142
- export CXX=/usr/bin/clang++
143143
- mkdir build-clang
144144
- cd build-clang
145-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
145+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
146146
- make -j4
147147
- ctest -V -j4
148148
- cd ..
@@ -174,15 +174,15 @@ steps:
174174
- mkdir build
175175
- cd build
176176
- cmake --version
177-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
177+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
178178
- make -j4
179179
- ctest -V -j4
180180
- cd ..
181181
- export CC=/usr/bin/clang
182182
- export CXX=/usr/bin/clang++
183183
- mkdir build-clang
184184
- cd build-clang
185-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
185+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
186186
- make -j4
187187
- ctest -V -j4
188188

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ before_script:
4646
- mkdir build
4747
- cd build
4848
- cmake --version
49-
- cmake .. -DCROW_ENABLE_COMPRESSION=ON -DCROW_ENABLE_SSL=ON -DCROW_AMALGAMATE=ON
49+
- cmake .. -DCROW_FEATURES="ssl;compression" -DCROW_AMALGAMATE=ON
5050

5151
script: make -j4 && ctest -V -j4
5252

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ option(CROW_BUILD_TESTS "Build the tests in the project" ${CROW_I
3737
option(CROW_AMALGAMATE "Combine all headers into one" OFF)
3838
option(CROW_INSTALL "Add install step for Crow" ON )
3939

40-
option(CROW_ENABLE_SSL "Enable SSL capabilities (OpenSSL)" OFF)
41-
option(CROW_ENABLE_COMPRESSION "Enable compression capabilities (ZLIB)" OFF)
40+
# Possible values: ssl, compression
41+
option(CROW_FEATURES "Enable features extending Crow's abilities" "")
4242

4343
#####################################
4444
# Define Targets
@@ -61,13 +61,13 @@ target_link_libraries(Crow
6161
Threads::Threads
6262
)
6363

64-
if(CROW_ENABLE_COMPRESSION)
64+
if("compression" IN_LIST CROW_FEATURES)
6565
find_package(ZLIB REQUIRED)
6666
target_link_libraries(Crow INTERFACE ZLIB::ZLIB)
6767
target_compile_definitions(Crow INTERFACE CROW_ENABLE_COMPRESSION)
6868
endif()
6969

70-
if(CROW_ENABLE_SSL)
70+
if("ssl" IN_LIST CROW_FEATURES)
7171
find_package(OpenSSL REQUIRED)
7272
target_link_libraries(Crow INTERFACE OpenSSL::SSL)
7373
target_compile_definitions(Crow INTERFACE CROW_ENABLE_SSL)
@@ -92,11 +92,11 @@ endif()
9292

9393
# Tests
9494
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)")
95+
if(NOT "compression" IN_LIST CROW_FEATURES)
96+
message(STATUS "Compression tests are omitted. (Configure with CROW_FEATURES containing 'compression' to enable them)")
9797
endif()
98-
if(NOT CROW_ENABLE_SSL)
99-
message(STATUS "SSL tests are omitted. (Configure with CROW_ENABLE_SSL=ON to enable them)")
98+
if(NOT "ssl" IN_LIST CROW_FEATURES)
99+
message(STATUS "SSL tests are omitted. (Configure with CROW_FEATURES containing 'ssl' to enable them)")
100100
else()
101101
add_test(NAME ssl_test COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tests/ssl/ssltest)
102102
endif()

cmake/CrowConfig.cmake.in

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ include(CMakeFindDependencyMacro)
44
find_dependency(Boost 1.64 COMPONENTS system date_time)
55
find_dependency(Threads)
66

7-
if(CROW_ENABLE_COMPRESSION)
7+
set(CROW_INSTALLED_FEATURES "@CROW_FEATURES@")
8+
9+
if(NOT DEFINED CROW_FEATURES)
10+
set(CROW_FEATURES ${CROW_INSTALLED_FEATURES})
11+
endif()
12+
13+
if("compression" IN_LIST CROW_FEATURES)
814
find_dependency(ZLIB)
915
endif()
1016

11-
if(CROW_ENABLE_SSL)
17+
if("ssl" IN_LIST CROW_FEATURES)
1218
find_dependency(OpenSSL)
1319
endif()
1420

@@ -21,12 +27,12 @@ get_target_property(_CROW_ICD Crow::Crow INTERFACE_COMPILE_DEFINITIONS)
2127
list(REMOVE_ITEM _CROW_ILL "ZLIB::ZLIB" "OpenSSL::SSL")
2228
list(REMOVE_ITEM _CROW_ICD "CROW_ENABLE_SSL" "CROW_ENABLE_COMPRESSION")
2329

24-
if(CROW_ENABLE_COMPRESSION)
30+
if("compression" IN_LIST CROW_FEATURES)
2531
list(APPEND _CROW_ILL "ZLIB::ZLIB")
2632
list(APPEND _CROW_ICD "CROW_ENABLE_COMPRESSION")
2733
endif()
2834

29-
if(CROW_ENABLE_SSL)
35+
if("ssl" IN_LIST CROW_FEATURES)
3036
list(APPEND _CROW_ILL "OpenSSL::SSL")
3137
list(APPEND _CROW_ICD "CROW_ENABLE_SSL")
3238
endif()

examples/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ add_warnings_optimizations(helloworld)
88
target_link_libraries(helloworld PUBLIC Crow::Crow)
99

1010
# If compression is enabled, the example will be built
11-
if(CROW_ENABLE_COMPRESSION)
11+
if("compression" IN_LIST CROW_FEATURES)
1212
add_executable(example_compression example_compression.cpp)
1313
add_warnings_optimizations(example_compression)
1414
target_link_libraries(example_compression Crow::Crow)
@@ -17,7 +17,7 @@ else()
1717
endif()
1818

1919
# If SSL is enabled, the example will be built
20-
if(CROW_ENABLE_SSL)
20+
if("ssl" IN_LIST CROW_FEATURES)
2121
add_executable(example_ssl ssl/example_ssl.cpp)
2222
add_warnings_optimizations(example_ssl)
2323
target_link_libraries(example_ssl PUBLIC Crow::Crow)

include/crow/settings.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
/* #ifdef - enables logging */
99
#define CROW_ENABLE_LOGGING
1010

11-
/* #ifdef - enables ssl */
12-
//#define CROW_ENABLE_SSL
13-
1411
/* #ifdef - enforces section 5.2 and 6.1 of RFC6455 (only accepting masked messages from clients) */
1512
//#define CROW_ENFORCE_WS_SPEC
1613

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ endif()
1818

1919
add_subdirectory(template)
2020
add_subdirectory(multi_file)
21-
if (CROW_ENABLE_SSL)
21+
if ("ssl" IN_LIST CROW_FEATURES)
2222
add_subdirectory(ssl)
2323
endif()
2424
add_subdirectory(img)

0 commit comments

Comments
 (0)