mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 23:04:35 +02:00
Add a Beast CMake interface target:
fix #461 This target allows other CMake projects to acquire the Beast headers and link libraries easily.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
Version 55:
|
Version 55:
|
||||||
|
|
||||||
* Don't allocate memory to handle obs-fold
|
* Don't allocate memory to handle obs-fold
|
||||||
|
* Add Beast CMake interface target
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -1,8 +1,12 @@
|
|||||||
# Part of Beast
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Beast
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 3.5.2)
|
cmake_minimum_required (VERSION 3.5.2)
|
||||||
|
|
||||||
project (Beast)
|
project (Beast VERSION 1.0.0)
|
||||||
|
|
||||||
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
@@ -40,30 +44,25 @@ endif()
|
|||||||
#
|
#
|
||||||
# Boost
|
# Boost
|
||||||
#
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
option (Boost_USE_STATIC_LIBS "Use static libraries for boost" ON)
|
option (Boost_USE_STATIC_LIBS "Use static libraries for boost" ON)
|
||||||
|
|
||||||
set (Boost_NO_SYSTEM_PATHS ON)
|
set (Boost_NO_SYSTEM_PATHS ON)
|
||||||
set (Boost_USE_MULTITHREADED ON)
|
set (Boost_USE_MULTITHREADED ON)
|
||||||
add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING=1) # for asio
|
|
||||||
|
|
||||||
unset (Boost_INCLUDE_DIR CACHE)
|
unset (Boost_INCLUDE_DIR CACHE)
|
||||||
unset (Boost_LIBRARY_DIRS CACHE)
|
unset (Boost_LIBRARY_DIRS CACHE)
|
||||||
if (MSVC)
|
set (BOOST_COMPONENTS coroutine context filesystem program_options system thread)
|
||||||
find_package (Boost REQUIRED)
|
find_package (Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
||||||
else()
|
|
||||||
find_package (Boost REQUIRED COMPONENTS
|
|
||||||
coroutine
|
|
||||||
context
|
|
||||||
filesystem
|
|
||||||
program_options
|
|
||||||
system
|
|
||||||
thread
|
|
||||||
)
|
|
||||||
link_libraries (${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories (SYSTEM ${Boost_INCLUDE_DIRS})
|
# Workaround for Jenkins incomplete install
|
||||||
|
if (NOT TARGET Boost::atomic)
|
||||||
|
add_library(Boost::atomic INTERFACE IMPORTED)
|
||||||
|
endif()
|
||||||
|
if (NOT TARGET Boost::date_time)
|
||||||
|
add_library(Boost::date_time INTERFACE IMPORTED)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
link_libraries(ws2_32 mswsock)
|
link_libraries(ws2_32 mswsock)
|
||||||
@@ -73,6 +72,7 @@ endif()
|
|||||||
#
|
#
|
||||||
# OpenSSL
|
# OpenSSL
|
||||||
#
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR})
|
if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR})
|
||||||
find_program(HOMEBREW brew)
|
find_program(HOMEBREW brew)
|
||||||
@@ -129,6 +129,25 @@ elseif ("${VARIANT}" STREQUAL "release")
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Library interface
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE Boost::system Boost::disable_autolinking)
|
||||||
|
if (NOT MSVC)
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE Threads::Threads)
|
||||||
|
endif()
|
||||||
|
target_compile_definitions(${PROJECT_NAME} INTERFACE BOOST_COROUTINES_NO_DEPRECATION_WARNING=1)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Tests and Examples
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
include_directories (.)
|
include_directories (.)
|
||||||
include_directories (extras)
|
include_directories (extras)
|
||||||
include_directories (include)
|
include_directories (include)
|
||||||
@@ -170,6 +189,12 @@ file(GLOB_RECURSE EXTRAS_INCLUDES
|
|||||||
${PROJECT_SOURCE_DIR}/extras/beast/*.ipp
|
${PROJECT_SOURCE_DIR}/extras/beast/*.ipp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_subdirectory (test)
|
||||||
|
add_subdirectory (test/core)
|
||||||
|
add_subdirectory (test/http)
|
||||||
|
add_subdirectory (test/websocket)
|
||||||
|
add_subdirectory (test/zlib)
|
||||||
|
|
||||||
add_subdirectory (examples)
|
add_subdirectory (examples)
|
||||||
if (NOT OPENSSL_FOUND)
|
if (NOT OPENSSL_FOUND)
|
||||||
message("OpenSSL not found. Not building SSL tests and examples")
|
message("OpenSSL not found. Not building SSL tests and examples")
|
||||||
@@ -177,9 +202,3 @@ else()
|
|||||||
add_subdirectory (examples/ssl)
|
add_subdirectory (examples/ssl)
|
||||||
add_subdirectory (test/websocket/ssl)
|
add_subdirectory (test/websocket/ssl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory (test)
|
|
||||||
add_subdirectory (test/core)
|
|
||||||
add_subdirectory (test/http)
|
|
||||||
add_subdirectory (test/websocket)
|
|
||||||
add_subdirectory (test/zlib)
|
|
||||||
|
@@ -10,11 +10,7 @@ add_executable (echo-op
|
|||||||
echo_op.cpp
|
echo_op.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(echo-op Beast)
|
||||||
target_link_libraries(echo-op ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(echo-op ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable (http-crawl
|
add_executable (http-crawl
|
||||||
${BEAST_INCLUDES}
|
${BEAST_INCLUDES}
|
||||||
@@ -24,11 +20,7 @@ add_executable (http-crawl
|
|||||||
http_crawl.cpp
|
http_crawl.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(http-crawl Beast)
|
||||||
target_link_libraries(http-crawl ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(http-crawl ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable (http-server
|
add_executable (http-server
|
||||||
${BEAST_INCLUDES}
|
${BEAST_INCLUDES}
|
||||||
@@ -40,11 +32,7 @@ add_executable (http-server
|
|||||||
http_server.cpp
|
http_server.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(http-server Beast Boost::program_options Boost::filesystem)
|
||||||
target_link_libraries(http-server ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(http-server ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
add_executable (http-example
|
add_executable (http-example
|
||||||
@@ -53,11 +41,7 @@ add_executable (http-example
|
|||||||
http_example.cpp
|
http_example.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(http-example Beast)
|
||||||
target_link_libraries(http-example ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(http-example ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
add_executable (websocket-echo
|
add_executable (websocket-echo
|
||||||
@@ -67,11 +51,7 @@ add_executable (websocket-echo
|
|||||||
websocket_echo.cpp
|
websocket_echo.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(websocket-echo Beast)
|
||||||
target_link_libraries(websocket-echo ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(websocket-echo ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
add_executable (websocket-example
|
add_executable (websocket-example
|
||||||
@@ -80,8 +60,4 @@ add_executable (websocket-example
|
|||||||
websocket_example.cpp
|
websocket_example.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(websocket-example Beast)
|
||||||
target_link_libraries(websocket-example ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(websocket-example ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
@@ -5,19 +5,13 @@ GroupSources(include/beast beast)
|
|||||||
|
|
||||||
GroupSources(examples/ssl "/")
|
GroupSources(examples/ssl "/")
|
||||||
|
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_executable (http-ssl-example
|
add_executable (http-ssl-example
|
||||||
${BEAST_INCLUDES}
|
${BEAST_INCLUDES}
|
||||||
${EXTRAS_INCLUDES}
|
${EXTRAS_INCLUDES}
|
||||||
http_ssl_example.cpp
|
http_ssl_example.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(http-ssl-example ${OPENSSL_LIBRARIES})
|
target_link_libraries(http-ssl-example Beast OpenSSL::SSL)
|
||||||
|
|
||||||
if (NOT WIN32)
|
|
||||||
target_link_libraries(http-ssl-example ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable (websocket-ssl-example
|
add_executable (websocket-ssl-example
|
||||||
${BEAST_INCLUDES}
|
${BEAST_INCLUDES}
|
||||||
@@ -25,8 +19,4 @@ add_executable (websocket-ssl-example
|
|||||||
websocket_ssl_example.cpp
|
websocket_ssl_example.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(websocket-ssl-example ${OPENSSL_LIBRARIES})
|
target_link_libraries(websocket-ssl-example Beast OpenSSL::SSL)
|
||||||
|
|
||||||
if (NOT WIN32)
|
|
||||||
target_link_libraries(websocket-ssl-example ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
endif()
|
|
||||||
|
@@ -16,11 +16,7 @@ add_executable (lib-tests
|
|||||||
zlib.cpp
|
zlib.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(lib-tests Beast Boost::program_options)
|
||||||
target_link_libraries(lib-tests ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(lib-tests ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
set_target_properties(lib-tests PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj")
|
set_target_properties(lib-tests PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj")
|
||||||
|
@@ -39,6 +39,4 @@ add_executable (core-tests
|
|||||||
sha1.cpp
|
sha1.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(core-tests Beast Boost::program_options Boost::filesystem Boost::coroutine Boost::thread Boost::context)
|
||||||
target_link_libraries(core-tests ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
endif()
|
|
||||||
|
@@ -33,11 +33,7 @@ add_executable (http-tests
|
|||||||
write.cpp
|
write.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(http-tests Beast Boost::program_options Boost::filesystem Boost::coroutine Boost::thread Boost::context)
|
||||||
target_link_libraries(http-tests ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(http-tests ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable (http-bench
|
add_executable (http-bench
|
||||||
${BEAST_INCLUDES}
|
${BEAST_INCLUDES}
|
||||||
@@ -49,8 +45,4 @@ add_executable (http-bench
|
|||||||
parser_bench.cpp
|
parser_bench.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(http-bench Beast Boost::program_options Boost::filesystem)
|
||||||
target_link_libraries(http-bench ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(http-bench ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
@@ -21,11 +21,7 @@ add_executable (websocket-tests
|
|||||||
utf8_checker.cpp
|
utf8_checker.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(websocket-tests Beast Boost::program_options Boost::filesystem Boost::coroutine Boost::thread Boost::context)
|
||||||
target_link_libraries(websocket-tests ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(websocket-tests ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (MINGW)
|
if (MINGW)
|
||||||
set_target_properties(websocket-tests PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj -Og")
|
set_target_properties(websocket-tests PROPERTIES COMPILE_FLAGS "-Wa,-mbig-obj -Og")
|
||||||
|
@@ -5,8 +5,6 @@ GroupSources(include/beast beast)
|
|||||||
|
|
||||||
GroupSources(test/websocket/ssl "/")
|
GroupSources(test/websocket/ssl "/")
|
||||||
|
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_executable (websocket-ssl-tests
|
add_executable (websocket-ssl-tests
|
||||||
${BEAST_INCLUDES}
|
${BEAST_INCLUDES}
|
||||||
${EXTRAS_INCLUDES}
|
${EXTRAS_INCLUDES}
|
||||||
@@ -16,8 +14,4 @@ add_executable (websocket-ssl-tests
|
|||||||
ssl_server.cpp
|
ssl_server.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(websocket-ssl-tests ${OPENSSL_LIBRARIES})
|
target_link_libraries(websocket-ssl-tests Beast Boost::program_options Boost::filesystem OpenSSL::SSL)
|
||||||
|
|
||||||
if (NOT WIN32)
|
|
||||||
target_link_libraries(websocket-ssl-tests ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
endif()
|
|
||||||
|
@@ -19,8 +19,4 @@ add_executable (zlib-tests
|
|||||||
inflate_stream.cpp
|
inflate_stream.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT WIN32)
|
target_link_libraries(zlib-tests Beast Boost::program_options Boost::filesystem)
|
||||||
target_link_libraries(zlib-tests ${Boost_LIBRARIES} Threads::Threads)
|
|
||||||
else()
|
|
||||||
target_link_libraries(zlib-tests ${Boost_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
Reference in New Issue
Block a user