From b38901887b024eefcc33c7c4afee3662a1a53e07 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 23 Mar 2019 15:57:24 -0700 Subject: [PATCH] cmake: Use static libs to speed up builds --- CHANGELOG.md | 6 + CMakeLists.txt | 117 ++++++++++++------ Jamfile | 4 +- example/advanced/server-flex/CMakeLists.txt | 3 + example/advanced/server/CMakeLists.txt | 4 + example/echo-op/CMakeLists.txt | 4 + example/http/client/async-ssl/CMakeLists.txt | 3 + example/http/client/async/CMakeLists.txt | 4 + example/http/client/coro-ssl/CMakeLists.txt | 3 + example/http/client/coro/CMakeLists.txt | 4 + example/http/client/crawl/CMakeLists.txt | 4 + example/http/client/sync-ssl/CMakeLists.txt | 3 + example/http/client/sync/CMakeLists.txt | 4 + example/http/server/async-ssl/CMakeLists.txt | 3 + example/http/server/async/CMakeLists.txt | 5 + example/http/server/coro-ssl/CMakeLists.txt | 3 + example/http/server/coro/CMakeLists.txt | 4 + example/http/server/fast/CMakeLists.txt | 4 + example/http/server/flex/CMakeLists.txt | 3 + example/http/server/small/CMakeLists.txt | 4 + .../http/server/stackless-ssl/CMakeLists.txt | 3 + example/http/server/stackless/CMakeLists.txt | 4 + example/http/server/sync-ssl/CMakeLists.txt | 3 + example/http/server/sync/CMakeLists.txt | 5 + .../websocket/client/async-ssl/CMakeLists.txt | 3 + example/websocket/client/async/CMakeLists.txt | 4 + .../websocket/client/coro-ssl/CMakeLists.txt | 3 + example/websocket/client/coro/CMakeLists.txt | 4 + .../websocket/client/sync-ssl/CMakeLists.txt | 3 + example/websocket/client/sync/CMakeLists.txt | 4 + .../websocket/server/async-ssl/CMakeLists.txt | 3 + example/websocket/server/async/CMakeLists.txt | 4 + .../server/chat-multi/CMakeLists.txt | 6 +- .../websocket/server/coro-ssl/CMakeLists.txt | 3 + example/websocket/server/coro/CMakeLists.txt | 4 + example/websocket/server/fast/CMakeLists.txt | 4 + .../server/stackless-ssl/CMakeLists.txt | 3 + .../websocket/server/stackless/CMakeLists.txt | 4 + .../websocket/server/sync-ssl/CMakeLists.txt | 3 + example/websocket/server/sync/CMakeLists.txt | 4 + test/CMakeLists.txt | 10 ++ test/_lib_beast.cpp | 22 ++++ test/{lib_ssl.cpp => _lib_ssl.cpp} | 0 test/beast/CMakeLists.txt | 11 +- test/beast/_experimental/CMakeLists.txt | 9 +- test/beast/core/CMakeLists.txt | 10 +- test/beast/http/CMakeLists.txt | 8 +- test/beast/ssl/CMakeLists.txt | 8 +- test/beast/websocket/CMakeLists.txt | 8 +- test/beast/zlib/CMakeLists.txt | 9 +- test/bench/buffers/CMakeLists.txt | 9 +- test/bench/parser/CMakeLists.txt | 9 +- test/bench/utf8_checker/CMakeLists.txt | 9 +- test/bench/wsload/CMakeLists.txt | 13 +- test/bench/zlib/CMakeLists.txt | 8 +- test/doc/CMakeLists.txt | 10 +- test/example/common/CMakeLists.txt | 8 +- test/lib_asio.cpp | 12 ++ test/lib_asio_ssl.cpp | 12 ++ test/lib_beast.cpp | 12 +- 60 files changed, 369 insertions(+), 91 deletions(-) create mode 100644 test/_lib_beast.cpp rename test/{lib_ssl.cpp => _lib_ssl.cpp} (100%) create mode 100644 test/lib_asio.cpp create mode 100644 test/lib_asio_ssl.cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d2bb845..80638f68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 237: + +* cmake: Use static libs to speed up builds + +-------------------------------------------------------------------------------- + Version 236: * root_certificates.hpp: brought in the server certificate diff --git a/CMakeLists.txt b/CMakeLists.txt index e66df20f..a6745ff5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,33 @@ cmake_minimum_required (VERSION 3.5.1) cmake_policy (SET CMP0074 NEW) +#------------------------------------------------------------------------------- + +function (DoGroupSources curdir rootdir folder) + file (GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*) + foreach (child ${children}) + if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child}) + DoGroupSources (${curdir}/${child} ${rootdir} ${folder}) + elseif (${child} STREQUAL "CMakeLists.txt") + source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child}) + else() + string (REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir}) + string (REPLACE "/" "\\" groupname ${groupname}) + source_group (${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child}) + endif() + endforeach() +endfunction() + +function (GroupSources curdir folder) + DoGroupSources (${curdir} ${curdir} ${folder}) +endfunction() + +#------------------------------------------------------------------------------- +# +# Beast +# +#------------------------------------------------------------------------------- + project (Beast VERSION 236) set_property (GLOBAL PROPERTY USE_FOLDERS ON) @@ -69,10 +96,28 @@ endif() # IDE sees the wrong file due to boost/ symlinks. include_directories (include) +#------------------------------------------------------------------------------- +# +# OpenSSL +# +#------------------------------------------------------------------------------- + +if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR}) + find_program(HOMEBREW brew) + if (NOT HOMEBREW STREQUAL "HOMEBREW-NOTFOUND") + execute_process(COMMAND brew --prefix openssl + OUTPUT_VARIABLE OPENSSL_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() +endif() + +find_package(OpenSSL) + #------------------------------------------------------------------------------- # # Boost # +#------------------------------------------------------------------------------- get_filename_component (BOOST_ROOT ../../ ABSOLUTE) @@ -94,44 +139,6 @@ if (MINGW) link_libraries(ws2_32 mswsock) endif() -#------------------------------------------------------------------------------- -# -# OpenSSL -# - -if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR}) - find_program(HOMEBREW brew) - if (NOT HOMEBREW STREQUAL "HOMEBREW-NOTFOUND") - execute_process(COMMAND brew --prefix openssl - OUTPUT_VARIABLE OPENSSL_ROOT_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - endif() -endif() - -find_package(OpenSSL) - -# -#------------------------------------------------------------------------------- - -function (DoGroupSources curdir rootdir folder) - file (GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*) - foreach (child ${children}) - if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child}) - DoGroupSources (${curdir}/${child} ${rootdir} ${folder}) - elseif (${child} STREQUAL "CMakeLists.txt") - source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child}) - else() - string (REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir}) - string (REPLACE "/" "\\" groupname ${groupname}) - source_group (${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child}) - endif() - endforeach() -endfunction() - -function (GroupSources curdir folder) - DoGroupSources (${curdir} ${curdir} ${folder}) -endfunction() - #------------------------------------------------------------------------------- if ("${VARIANT}" STREQUAL "coverage") @@ -159,6 +166,40 @@ elseif ("${VARIANT}" STREQUAL "release") endif() +#------------------------------------------------------------------------------- +# +# Static Libraries +# +#------------------------------------------------------------------------------- + +add_definitions (-DBOOST_ASIO_SEPARATE_COMPILATION=1) +add_definitions (-DBOOST_BEAST_SPLIT_COMPILATION=1) + +GroupSources (test "/") + +add_library ( + lib-asio STATIC + test/lib_asio.cpp +) + +set_property(TARGET lib-asio PROPERTY FOLDER "static-libs") + +add_library ( + lib-asio-ssl STATIC + test/lib_asio_ssl.cpp +) + +set_property(TARGET lib-asio-ssl PROPERTY FOLDER "static-libs") + +add_library ( + lib-beast STATIC + test/lib_beast.cpp +) + +set_property(TARGET lib-beast PROPERTY FOLDER "static-libs") + +target_link_libraries(lib-asio lib-beast) + #------------------------------------------------------------------------------- # # Tests and examples diff --git a/Jamfile b/Jamfile index 0df080ea..86ad3187 100644 --- a/Jamfile +++ b/Jamfile @@ -97,7 +97,7 @@ local defines = ; lib static_beast - : test/lib_beast.cpp + : test/_lib_beast.cpp : requirements $(defines) ./test/extras/include @@ -107,7 +107,7 @@ lib static_beast ; lib static_ssl_asio - : test/lib_ssl.cpp + : test/_lib_ssl.cpp : requirements /boost/beast//static_beast/static [ ac.check-library /boost/beast//ssl : /boost/beast//ssl/shared : no ] diff --git a/example/advanced/server-flex/CMakeLists.txt b/example/advanced/server-flex/CMakeLists.txt index 15c92b4b..d6075b27 100644 --- a/example/advanced/server-flex/CMakeLists.txt +++ b/example/advanced/server-flex/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (advanced-server-flex OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/advanced/server/CMakeLists.txt b/example/advanced/server/CMakeLists.txt index 5d0b710c..08014afe 100644 --- a/example/advanced/server/CMakeLists.txt +++ b/example/advanced/server/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (advanced-server advanced_server.cpp ) +target_link_libraries(advanced-server + lib-asio + lib-beast) + set_property(TARGET advanced-server PROPERTY FOLDER "example-advanced-server") diff --git a/example/echo-op/CMakeLists.txt b/example/echo-op/CMakeLists.txt index 2f01a601..d0e086b6 100644 --- a/example/echo-op/CMakeLists.txt +++ b/example/echo-op/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (echo-op echo_op.cpp ) +target_link_libraries(echo-op + lib-asio + lib-beast) + set_property(TARGET echo-op PROPERTY FOLDER "example") diff --git a/example/http/client/async-ssl/CMakeLists.txt b/example/http/client/async-ssl/CMakeLists.txt index f7c88a12..a64fbf61 100644 --- a/example/http/client/async-ssl/CMakeLists.txt +++ b/example/http/client/async-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (http-client-async-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/http/client/async/CMakeLists.txt b/example/http/client/async/CMakeLists.txt index 6bde0bf4..3847ce61 100644 --- a/example/http/client/async/CMakeLists.txt +++ b/example/http/client/async/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (http-client-async http_client_async.cpp ) +target_link_libraries(http-client-async + lib-asio + lib-beast) + set_property(TARGET http-client-async PROPERTY FOLDER "example-http-client") diff --git a/example/http/client/coro-ssl/CMakeLists.txt b/example/http/client/coro-ssl/CMakeLists.txt index f8ed33ed..54fe3ae2 100644 --- a/example/http/client/coro-ssl/CMakeLists.txt +++ b/example/http/client/coro-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (http-client-coro-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/http/client/coro/CMakeLists.txt b/example/http/client/coro/CMakeLists.txt index 073cce5d..1a791ab1 100644 --- a/example/http/client/coro/CMakeLists.txt +++ b/example/http/client/coro/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (http-client-coro http_client_coro.cpp ) +target_link_libraries(http-client-coro + lib-asio + lib-beast) + set_property(TARGET http-client-coro PROPERTY FOLDER "example-http-client") diff --git a/example/http/client/crawl/CMakeLists.txt b/example/http/client/crawl/CMakeLists.txt index dc87484c..b502c7d7 100644 --- a/example/http/client/crawl/CMakeLists.txt +++ b/example/http/client/crawl/CMakeLists.txt @@ -18,5 +18,9 @@ add_executable (http-crawl http_crawl.cpp ) +target_link_libraries(http-crawl + lib-asio + lib-beast) + set_property(TARGET http-crawl PROPERTY FOLDER "example-http-client") diff --git a/example/http/client/sync-ssl/CMakeLists.txt b/example/http/client/sync-ssl/CMakeLists.txt index 0997d37f..0e0fbea0 100644 --- a/example/http/client/sync-ssl/CMakeLists.txt +++ b/example/http/client/sync-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (http-client-sync-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/http/client/sync/CMakeLists.txt b/example/http/client/sync/CMakeLists.txt index 399e61ce..ea877ec4 100644 --- a/example/http/client/sync/CMakeLists.txt +++ b/example/http/client/sync/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (http-client-sync http_client_sync.cpp ) +target_link_libraries(http-client-sync + lib-asio + lib-beast) + set_property(TARGET http-client-sync PROPERTY FOLDER "example-http-client") diff --git a/example/http/server/async-ssl/CMakeLists.txt b/example/http/server/async-ssl/CMakeLists.txt index 40d52195..4c1e2cd0 100644 --- a/example/http/server/async-ssl/CMakeLists.txt +++ b/example/http/server/async-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (http-server-async-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/http/server/async/CMakeLists.txt b/example/http/server/async/CMakeLists.txt index dda889b7..b94c0521 100644 --- a/example/http/server/async/CMakeLists.txt +++ b/example/http/server/async/CMakeLists.txt @@ -16,4 +16,9 @@ add_executable (http-server-async http_server_async.cpp ) +target_link_libraries(http-server-async + lib-asio + lib-asio-ssl + lib-beast) + set_property(TARGET http-server-async PROPERTY FOLDER "example-http-server") diff --git a/example/http/server/coro-ssl/CMakeLists.txt b/example/http/server/coro-ssl/CMakeLists.txt index 63322bfe..9bbf294c 100644 --- a/example/http/server/coro-ssl/CMakeLists.txt +++ b/example/http/server/coro-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (http-server-coro-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/http/server/coro/CMakeLists.txt b/example/http/server/coro/CMakeLists.txt index 46d3c235..6cc8244a 100644 --- a/example/http/server/coro/CMakeLists.txt +++ b/example/http/server/coro/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (http-server-coro http_server_coro.cpp ) +target_link_libraries(http-server-coro + lib-asio + lib-beast) + set_property(TARGET http-server-coro PROPERTY FOLDER "example-http-server") diff --git a/example/http/server/fast/CMakeLists.txt b/example/http/server/fast/CMakeLists.txt index f041eb40..ecc8f7bd 100644 --- a/example/http/server/fast/CMakeLists.txt +++ b/example/http/server/fast/CMakeLists.txt @@ -19,4 +19,8 @@ add_executable (http-server-fast http_server_fast.cpp ) +target_link_libraries(http-server-fast + lib-asio + lib-beast) + set_property(TARGET http-server-fast PROPERTY FOLDER "example-http-server") diff --git a/example/http/server/flex/CMakeLists.txt b/example/http/server/flex/CMakeLists.txt index 46bf8498..0920953b 100644 --- a/example/http/server/flex/CMakeLists.txt +++ b/example/http/server/flex/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (http-server-flex OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/http/server/small/CMakeLists.txt b/example/http/server/small/CMakeLists.txt index b6eb7f25..c443dec5 100644 --- a/example/http/server/small/CMakeLists.txt +++ b/example/http/server/small/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (http-server-small http_server_small.cpp ) +target_link_libraries(http-server-small + lib-asio + lib-beast) + set_property(TARGET http-server-small PROPERTY FOLDER "example-http-server") diff --git a/example/http/server/stackless-ssl/CMakeLists.txt b/example/http/server/stackless-ssl/CMakeLists.txt index fe7102d0..f25b9b3d 100644 --- a/example/http/server/stackless-ssl/CMakeLists.txt +++ b/example/http/server/stackless-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (http-server-stackless-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/http/server/stackless/CMakeLists.txt b/example/http/server/stackless/CMakeLists.txt index c1ee6ecb..1f82d391 100644 --- a/example/http/server/stackless/CMakeLists.txt +++ b/example/http/server/stackless/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (http-server-stackless http_server_stackless.cpp ) +target_link_libraries(http-server-stackless + lib-asio + lib-beast) + set_property(TARGET http-server-stackless PROPERTY FOLDER "example-http-server") diff --git a/example/http/server/sync-ssl/CMakeLists.txt b/example/http/server/sync-ssl/CMakeLists.txt index 7dae7367..4142e2c9 100644 --- a/example/http/server/sync-ssl/CMakeLists.txt +++ b/example/http/server/sync-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (http-server-sync-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/http/server/sync/CMakeLists.txt b/example/http/server/sync/CMakeLists.txt index ced30da8..250add77 100644 --- a/example/http/server/sync/CMakeLists.txt +++ b/example/http/server/sync/CMakeLists.txt @@ -16,4 +16,9 @@ add_executable (http-server-sync http_server_sync.cpp ) +target_link_libraries(http-server-sync + lib-asio + lib-asio-ssl + lib-beast) + set_property(TARGET http-server-sync PROPERTY FOLDER "example-http-server") diff --git a/example/websocket/client/async-ssl/CMakeLists.txt b/example/websocket/client/async-ssl/CMakeLists.txt index 84a09c9c..a2198280 100644 --- a/example/websocket/client/async-ssl/CMakeLists.txt +++ b/example/websocket/client/async-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (websocket-client-async-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/websocket/client/async/CMakeLists.txt b/example/websocket/client/async/CMakeLists.txt index 73f2c07b..cc643407 100644 --- a/example/websocket/client/async/CMakeLists.txt +++ b/example/websocket/client/async/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (websocket-client-async websocket_client_async.cpp ) +target_link_libraries(websocket-client-async + lib-asio + lib-beast) + set_property(TARGET websocket-client-async PROPERTY FOLDER "example-websocket-client") diff --git a/example/websocket/client/coro-ssl/CMakeLists.txt b/example/websocket/client/coro-ssl/CMakeLists.txt index 78db6890..fe9db75c 100644 --- a/example/websocket/client/coro-ssl/CMakeLists.txt +++ b/example/websocket/client/coro-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (websocket-client-coro-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/websocket/client/coro/CMakeLists.txt b/example/websocket/client/coro/CMakeLists.txt index 1bdcf6c6..2bfeef28 100644 --- a/example/websocket/client/coro/CMakeLists.txt +++ b/example/websocket/client/coro/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (websocket-client-coro websocket_client_coro.cpp ) +target_link_libraries(websocket-client-coro + lib-asio + lib-beast) + set_property(TARGET websocket-client-coro PROPERTY FOLDER "example-websocket-client") diff --git a/example/websocket/client/sync-ssl/CMakeLists.txt b/example/websocket/client/sync-ssl/CMakeLists.txt index 435996da..b8449570 100644 --- a/example/websocket/client/sync-ssl/CMakeLists.txt +++ b/example/websocket/client/sync-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (websocket-client-sync-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/websocket/client/sync/CMakeLists.txt b/example/websocket/client/sync/CMakeLists.txt index 8196f0da..d8606ab5 100644 --- a/example/websocket/client/sync/CMakeLists.txt +++ b/example/websocket/client/sync/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (websocket-client-sync websocket_client_sync.cpp ) +target_link_libraries(websocket-client-sync + lib-asio + lib-beast) + set_property(TARGET websocket-client-sync PROPERTY FOLDER "example-websocket-client") diff --git a/example/websocket/server/async-ssl/CMakeLists.txt b/example/websocket/server/async-ssl/CMakeLists.txt index 62ec5219..8f1055d2 100644 --- a/example/websocket/server/async-ssl/CMakeLists.txt +++ b/example/websocket/server/async-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (websocket-server-async-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/websocket/server/async/CMakeLists.txt b/example/websocket/server/async/CMakeLists.txt index d9fb1093..0e1ceb8b 100644 --- a/example/websocket/server/async/CMakeLists.txt +++ b/example/websocket/server/async/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (websocket-server-async websocket_server_async.cpp ) +target_link_libraries(websocket-server-async + lib-asio + lib-beast) + set_property(TARGET websocket-server-async PROPERTY FOLDER "example-websocket-server") diff --git a/example/websocket/server/chat-multi/CMakeLists.txt b/example/websocket/server/chat-multi/CMakeLists.txt index 4617821f..a256b000 100644 --- a/example/websocket/server/chat-multi/CMakeLists.txt +++ b/example/websocket/server/chat-multi/CMakeLists.txt @@ -8,7 +8,7 @@ # GroupSources(include/boost/beast beast) -GroupSources(example/cppcon2018 "/") +GroupSources(example/websocket/server/chat-multi "/") file (GLOB APP_FILES beast.hpp @@ -34,4 +34,8 @@ add_executable (websocket-chat-multi ${BOOST_BEAST_FILES} ) +target_link_libraries(websocket-chat-multi + lib-asio + lib-beast) + set_property(TARGET websocket-chat-multi PROPERTY FOLDER "example-websocket-server") diff --git a/example/websocket/server/coro-ssl/CMakeLists.txt b/example/websocket/server/coro-ssl/CMakeLists.txt index 292669c2..a302a2f5 100644 --- a/example/websocket/server/coro-ssl/CMakeLists.txt +++ b/example/websocket/server/coro-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (websocket-server-coro-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/websocket/server/coro/CMakeLists.txt b/example/websocket/server/coro/CMakeLists.txt index bf4c5a36..c8e408d1 100644 --- a/example/websocket/server/coro/CMakeLists.txt +++ b/example/websocket/server/coro/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (websocket-server-coro websocket_server_coro.cpp ) +target_link_libraries(websocket-server-coro + lib-asio + lib-beast) + set_property(TARGET websocket-server-coro PROPERTY FOLDER "example-websocket-server") diff --git a/example/websocket/server/fast/CMakeLists.txt b/example/websocket/server/fast/CMakeLists.txt index df44e5e9..93d469e9 100644 --- a/example/websocket/server/fast/CMakeLists.txt +++ b/example/websocket/server/fast/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (websocket-server-fast websocket_server_fast.cpp ) +target_link_libraries(websocket-server-fast + lib-asio + lib-beast) + set_property(TARGET websocket-server-fast PROPERTY FOLDER "example-websocket-server") diff --git a/example/websocket/server/stackless-ssl/CMakeLists.txt b/example/websocket/server/stackless-ssl/CMakeLists.txt index 6dca1e84..7ae66a07 100644 --- a/example/websocket/server/stackless-ssl/CMakeLists.txt +++ b/example/websocket/server/stackless-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (websocket-server-stackless-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/websocket/server/stackless/CMakeLists.txt b/example/websocket/server/stackless/CMakeLists.txt index b5f51b21..b260ca48 100644 --- a/example/websocket/server/stackless/CMakeLists.txt +++ b/example/websocket/server/stackless/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (websocket-server-stackless websocket_server_stackless.cpp ) +target_link_libraries(websocket-server-stackless + lib-asio + lib-beast) + set_property(TARGET websocket-server-stackless PROPERTY FOLDER "example-websocket-server") diff --git a/example/websocket/server/sync-ssl/CMakeLists.txt b/example/websocket/server/sync-ssl/CMakeLists.txt index 01498af4..0ad254ce 100644 --- a/example/websocket/server/sync-ssl/CMakeLists.txt +++ b/example/websocket/server/sync-ssl/CMakeLists.txt @@ -23,6 +23,9 @@ if (OPENSSL_FOUND) target_link_libraries (websocket-server-sync-ssl OpenSSL::SSL OpenSSL::Crypto + lib-asio + lib-asio-ssl + lib-beast ) endif() diff --git a/example/websocket/server/sync/CMakeLists.txt b/example/websocket/server/sync/CMakeLists.txt index 357a3b6a..48699861 100644 --- a/example/websocket/server/sync/CMakeLists.txt +++ b/example/websocket/server/sync/CMakeLists.txt @@ -16,4 +16,8 @@ add_executable (websocket-server-sync websocket_server_sync.cpp ) +target_link_libraries(websocket-server-sync + lib-asio + lib-beast) + set_property(TARGET websocket-server-sync PROPERTY FOLDER "example-websocket-server") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e5d1149f..1260a09c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,6 +13,7 @@ include_directories (./extras/include) file (GLOB_RECURSE EXTRAS_FILES ${PROJECT_SOURCE_DIR}/test/extras/include/*.hpp ${PROJECT_SOURCE_DIR}/test/extras/include/*.ipp + ${PROJECT_SOURCE_DIR}/test/lib_ssl.cpp ) if (OPENSSL_FOUND) @@ -44,6 +45,15 @@ set (ZLIB_SOURCES set (TEST_MAIN ${PROJECT_SOURCE_DIR}/test/lib_beast.cpp) +GroupSources (. "/") + +add_library ( + lib-test STATIC + ${PROJECT_SOURCE_DIR}/include/boost/beast/_experimental/unit_test/main.cpp +) + +set_property(TARGET lib-test PROPERTY FOLDER "static-libs") + add_definitions (-DBOOST_BEAST_INCLUDE_TEST_MAIN) add_definitions (-DBOOST_ASIO_SEPARATE_COMPILATION) add_definitions (-DBOOST_BEAST_SPLIT_COMPILATION) diff --git a/test/_lib_beast.cpp b/test/_lib_beast.cpp new file mode 100644 index 00000000..489284f9 --- /dev/null +++ b/test/_lib_beast.cpp @@ -0,0 +1,22 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +// This file is used to build a static library with +// asio and beast definitions, to reduce compilation time. + +// BOOST_ASIO_SEPARATE_COMPILATION for asio +#include + +// BOOST_BEAST_SPLIT_COMPILATION for beast +#include +//#include + +#ifdef BOOST_BEAST_INCLUDE_TEST_MAIN +#include +#endif diff --git a/test/lib_ssl.cpp b/test/_lib_ssl.cpp similarity index 100% rename from test/lib_ssl.cpp rename to test/_lib_ssl.cpp diff --git a/test/beast/CMakeLists.txt b/test/beast/CMakeLists.txt index 8fd08765..325d1e5f 100644 --- a/test/beast/CMakeLists.txt +++ b/test/beast/CMakeLists.txt @@ -8,8 +8,9 @@ # add_definitions (-DBOOST_BEAST_ALLOW_DEPRECATED) -add_definitions (-DBOOST_BEAST_TESTS) +# For buffers_cat +add_definitions (-DBOOST_BEAST_TESTS) add_subdirectory (_experimental) add_subdirectory (core) @@ -21,13 +22,11 @@ add_subdirectory (zlib) #------------------------------------------------------------------------------- GroupSources (include/boost/beast beast) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/beast "/") add_executable (tests-beast ${BOOST_BEAST_FILES} ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile core.cpp http.cpp @@ -37,4 +36,10 @@ add_executable (tests-beast zlib.cpp ) +target_link_libraries(tests-beast + lib-asio + lib-asio-ssl + lib-beast + lib-test) + set_property(TARGET tests-beast PROPERTY FOLDER "tests") diff --git a/test/beast/_experimental/CMakeLists.txt b/test/beast/_experimental/CMakeLists.txt index ced4b54f..b588874a 100644 --- a/test/beast/_experimental/CMakeLists.txt +++ b/test/beast/_experimental/CMakeLists.txt @@ -8,17 +8,20 @@ # GroupSources (include/boost/beast beast) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/beast/_experimental "/") add_executable (tests-beast-_experimental ${BOOST_BEAST_FILES} - ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile error.cpp icy_stream.cpp stream.cpp ) +target_link_libraries(tests-beast-_experimental + lib-asio + lib-beast + lib-test + ) + set_property(TARGET tests-beast-_experimental PROPERTY FOLDER "tests") diff --git a/test/beast/core/CMakeLists.txt b/test/beast/core/CMakeLists.txt index c81d48c9..8c0844c4 100644 --- a/test/beast/core/CMakeLists.txt +++ b/test/beast/core/CMakeLists.txt @@ -8,13 +8,10 @@ # GroupSources (include/boost/beast beast) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/beast/core "/") add_executable (tests-beast-core ${BOOST_BEAST_FILES} - ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile test_buffer.hpp file_test.hpp @@ -69,4 +66,11 @@ add_executable (tests-beast-core tcp_stream.cpp ) +target_link_libraries(tests-beast-core + lib-asio + lib-asio-ssl + lib-beast + lib-test + ) + set_property(TARGET tests-beast-core PROPERTY FOLDER "tests") diff --git a/test/beast/http/CMakeLists.txt b/test/beast/http/CMakeLists.txt index b1a70d4e..ac48fd36 100644 --- a/test/beast/http/CMakeLists.txt +++ b/test/beast/http/CMakeLists.txt @@ -14,7 +14,6 @@ GroupSources (test/beast/http "/") add_executable (tests-beast-http ${BOOST_BEAST_FILES} ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile message_fuzz.hpp test_parser.hpp @@ -43,4 +42,11 @@ add_executable (tests-beast-http write.cpp ) +target_link_libraries(tests-beast-http + lib-asio + lib-asio-ssl + lib-beast + lib-test + ) + set_property(TARGET tests-beast-http PROPERTY FOLDER "tests") diff --git a/test/beast/ssl/CMakeLists.txt b/test/beast/ssl/CMakeLists.txt index 84fb22a1..0a6c1a12 100644 --- a/test/beast/ssl/CMakeLists.txt +++ b/test/beast/ssl/CMakeLists.txt @@ -12,9 +12,15 @@ GroupSources (test/beast/ssl "/") add_executable (tests-beast-ssl ${BOOST_BEAST_FILES} - ${TEST_MAIN} Jamfile ssl_stream.cpp ) +target_link_libraries(tests-beast-ssl + lib-asio + lib-asio-ssl + lib-beast + lib-test + ) + set_property(TARGET tests-beast-ssl PROPERTY FOLDER "tests") diff --git a/test/beast/websocket/CMakeLists.txt b/test/beast/websocket/CMakeLists.txt index 21685116..50036eeb 100644 --- a/test/beast/websocket/CMakeLists.txt +++ b/test/beast/websocket/CMakeLists.txt @@ -14,7 +14,6 @@ GroupSources (test/beast/websocket "/") add_executable (tests-beast-websocket ${BOOST_BEAST_FILES} ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile _detail_decorator.cpp _detail_prng.cpp @@ -43,4 +42,11 @@ add_executable (tests-beast-websocket write.cpp ) +target_link_libraries(tests-beast-websocket + lib-asio + lib-asio-ssl + lib-beast + lib-test + ) + set_property(TARGET tests-beast-websocket PROPERTY FOLDER "tests") diff --git a/test/beast/zlib/CMakeLists.txt b/test/beast/zlib/CMakeLists.txt index c061a43c..ecb9898a 100644 --- a/test/beast/zlib/CMakeLists.txt +++ b/test/beast/zlib/CMakeLists.txt @@ -8,7 +8,6 @@ # GroupSources (include/boost/beast beast) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/extern/zlib-1.2.11 zlib) GroupSources (test/beast/zlib "/") @@ -18,9 +17,7 @@ endif() add_executable (tests-beast-zlib ${BOOST_BEAST_FILES} - ${EXTRAS_FILES} ${ZLIB_SOURCES} - ${TEST_MAIN} Jamfile error.cpp deflate_stream.cpp @@ -28,4 +25,10 @@ add_executable (tests-beast-zlib zlib.cpp ) +target_link_libraries(tests-beast-zlib + lib-asio + lib-beast + lib-test + ) + set_property(TARGET tests-beast-zlib PROPERTY FOLDER "tests") diff --git a/test/bench/buffers/CMakeLists.txt b/test/bench/buffers/CMakeLists.txt index a4991aef..d05db11f 100644 --- a/test/bench/buffers/CMakeLists.txt +++ b/test/bench/buffers/CMakeLists.txt @@ -8,15 +8,18 @@ # GroupSources (include/boost/beast beast) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/bench/buffers "/") add_executable (bench-buffers ${BOOST_BEAST_FILES} - ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile bench_buffers.cpp ) +target_link_libraries(bench-buffers + lib-asio + lib-beast + lib-test + ) + set_property(TARGET bench-buffers PROPERTY FOLDER "tests-bench") diff --git a/test/bench/parser/CMakeLists.txt b/test/bench/parser/CMakeLists.txt index 49574964..4a4eb2ce 100644 --- a/test/bench/parser/CMakeLists.txt +++ b/test/bench/parser/CMakeLists.txt @@ -8,14 +8,11 @@ # GroupSources (include/boost/beast beast) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/beast/http "/") GroupSources (test/bench/parser "/") add_executable (bench-parser ${BOOST_BEAST_FILES} - ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile ${PROJECT_SOURCE_DIR}/test/beast/http/message_fuzz.hpp nodejs_parser.hpp @@ -23,4 +20,10 @@ add_executable (bench-parser bench_parser.cpp ) +target_link_libraries(bench-parser + lib-asio + lib-beast + lib-test + ) + set_property(TARGET bench-parser PROPERTY FOLDER "tests-bench") diff --git a/test/bench/utf8_checker/CMakeLists.txt b/test/bench/utf8_checker/CMakeLists.txt index 0139b6b8..6164127a 100644 --- a/test/bench/utf8_checker/CMakeLists.txt +++ b/test/bench/utf8_checker/CMakeLists.txt @@ -8,15 +8,18 @@ # GroupSources (include/boost/beast beast) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/bench/utf8_checker "/") add_executable (bench-utf8-checker ${BOOST_BEAST_FILES} - ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile bench_utf8_checker.cpp ) +target_link_libraries(bench-utf8-checker + lib-asio + lib-beast + lib-test + ) + set_property(TARGET bench-utf8-checker PROPERTY FOLDER "tests-bench") diff --git a/test/bench/wsload/CMakeLists.txt b/test/bench/wsload/CMakeLists.txt index 59e9398b..7a6c5876 100644 --- a/test/bench/wsload/CMakeLists.txt +++ b/test/bench/wsload/CMakeLists.txt @@ -8,20 +8,17 @@ # GroupSources (include/boost/beast beast) -GroupSources (example/common common) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/bench/wsload "/") -remove_definitions (-DBOOST_BEAST_INCLUDE_TEST_MAIN) -remove_definitions (-DBOOST_ASIO_SEPARATE_COMPILATION) -remove_definitions (-DBOOST_BEAST_SPLIT_COMPILATION) - add_executable (bench-wsload ${BOOST_BEAST_FILES} - ${COMMON_FILES} - ${EXTRAS_FILES} Jamfile wsload.cpp ) +target_link_libraries(bench-wsload + lib-asio + lib-beast + ) + set_property(TARGET bench-wsload PROPERTY FOLDER "tests-bench") diff --git a/test/bench/zlib/CMakeLists.txt b/test/bench/zlib/CMakeLists.txt index 7dcc94be..a030ed93 100644 --- a/test/bench/zlib/CMakeLists.txt +++ b/test/bench/zlib/CMakeLists.txt @@ -8,7 +8,6 @@ # GroupSources (include/boost/beast beast) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/extern/zlib-1.2.11 zlib) GroupSources (test/bench/zlib "/") @@ -18,12 +17,15 @@ endif() add_executable (bench-zlib ${BOOST_BEAST_FILES} - ${EXTRAS_FILES} ${ZLIB_SOURCES} - ${TEST_MAIN} Jamfile deflate_stream.cpp inflate_stream.cpp ) +target_link_libraries(bench-zlib + lib-asio + lib-beast + lib-test + ) set_property(TARGET bench-zlib PROPERTY FOLDER "tests-bench") diff --git a/test/doc/CMakeLists.txt b/test/doc/CMakeLists.txt index b52400e3..8d42bfbf 100644 --- a/test/doc/CMakeLists.txt +++ b/test/doc/CMakeLists.txt @@ -9,13 +9,10 @@ GroupSources (include/boost/beast beast) GroupSources (example example) -GroupSources (test/extras/include/boost/beast extras) GroupSources (test/doc "/") add_executable (tests-doc ${BOOST_BEAST_FILES} - ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile snippets.hpp snippets.ipp @@ -39,4 +36,11 @@ add_executable (tests-doc exemplars.cpp ) +target_link_libraries(tests-doc + lib-asio + lib-asio-ssl + lib-beast + lib-test + ) + set_property(TARGET tests-doc PROPERTY FOLDER "tests") diff --git a/test/example/common/CMakeLists.txt b/test/example/common/CMakeLists.txt index 4b7bf6de..a2c6dfe1 100644 --- a/test/example/common/CMakeLists.txt +++ b/test/example/common/CMakeLists.txt @@ -16,10 +16,16 @@ add_executable (tests-example-common ${BOOST_BEAST_FILES} ${COMMON_FILES} ${EXTRAS_FILES} - ${TEST_MAIN} Jamfile root_certificates.cpp server_certificate.cpp ) +target_link_libraries(tests-example-common + lib-asio + lib-asio-ssl + lib-beast + lib-test + ) + set_property(TARGET tests-example-common PROPERTY FOLDER "tests") \ No newline at end of file diff --git a/test/lib_asio.cpp b/test/lib_asio.cpp new file mode 100644 index 00000000..e7874331 --- /dev/null +++ b/test/lib_asio.cpp @@ -0,0 +1,12 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +// This file is used to build a static library + +#include diff --git a/test/lib_asio_ssl.cpp b/test/lib_asio_ssl.cpp new file mode 100644 index 00000000..21200319 --- /dev/null +++ b/test/lib_asio_ssl.cpp @@ -0,0 +1,12 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/boostorg/beast +// + +// This file is used to build a static library + +#include diff --git a/test/lib_beast.cpp b/test/lib_beast.cpp index 489284f9..a9523a4e 100644 --- a/test/lib_beast.cpp +++ b/test/lib_beast.cpp @@ -7,16 +7,6 @@ // Official repository: https://github.com/boostorg/beast // -// This file is used to build a static library with -// asio and beast definitions, to reduce compilation time. +// This file is used to build a static library -// BOOST_ASIO_SEPARATE_COMPILATION for asio -#include - -// BOOST_BEAST_SPLIT_COMPILATION for beast #include -//#include - -#ifdef BOOST_BEAST_INCLUDE_TEST_MAIN -#include -#endif