Update CMake scripts for finding packages:

These changes require CMake version 3.7.2 or later.
This commit is contained in:
Sergey Lyubimov
2017-03-31 08:54:12 +03:00
committed by Vinnie Falco
parent ed906adc35
commit 3641521af7
9 changed files with 43 additions and 9 deletions

View File

@ -1,6 +1,7 @@
1.0.0-b32
* Add io_service completion invariants test
* Update CMake scripts for finding packages
API Changes:

View File

@ -4,12 +4,13 @@ cmake_minimum_required (VERSION 3.2)
project (Beast)
option(Boost_USE_STATIC_LIBS "Use static libraries for boost" ON)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
if (MSVC)
# /wd4244 /wd4127
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4100 /wd4244 /wd4251 /MP /W4 /bigobj /D BOOST_COROUTINES_NO_DEPRECATION_WARNING=1 /D _WIN32_WINNT=0x0601 /D _SCL_SECURE_NO_WARNINGS=1 /D _CRT_SECURE_NO_WARNINGS=1")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT")
@ -19,17 +20,12 @@ if (MSVC)
# for RelWithDebInfo builds, disable incremental linking
# since CMake sets it ON by default for that build type and it
# causes warnings
#
string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags})
else()
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED COMPONENTS coroutine context thread filesystem program_options system)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIR})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
@ -37,6 +33,12 @@ else()
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter -DBOOST_COROUTINES_NO_DEPRECATION_WARNING=1")
endif()
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED COMPONENTS coroutine context thread filesystem program_options system)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIR})
add_definitions ("-DBOOST_COROUTINES_NO_DEPRECATION_WARNING")
if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR})

View File

@ -73,9 +73,15 @@ The library has been submitted to the
## Requirements
* Boost 1.58 or higher
* C++11 or greater
* Boost 1.58 or later
* C++11 or later
These components are optionally required in order to build the
tests and examples:
* OpenSSL (optional)
* CMake 3.7.2 or later (optional)
* Properly configured bjam/b2 (optional)
## Building

View File

@ -15,6 +15,8 @@ add_executable (http-crawl
if (NOT WIN32)
target_link_libraries(http-crawl ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(http-crawl ${Boost_LIBRARIES})
endif()
add_executable (http-server
@ -29,8 +31,11 @@ add_executable (http-server
if (NOT WIN32)
target_link_libraries(http-server ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(http-server ${Boost_LIBRARIES})
endif()
add_executable (http-example
${BEAST_INCLUDES}
${EXTRAS_INCLUDES}
@ -39,8 +44,11 @@ add_executable (http-example
if (NOT WIN32)
target_link_libraries(http-example ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(http-example ${Boost_LIBRARIES})
endif()
add_executable (websocket-echo
${BEAST_INCLUDES}
websocket_async_echo_server.hpp
@ -50,8 +58,11 @@ add_executable (websocket-echo
if (NOT WIN32)
target_link_libraries(websocket-echo ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(websocket-echo ${Boost_LIBRARIES})
endif()
add_executable (websocket-example
${BEAST_INCLUDES}
${EXTRAS_INCLUDES}
@ -60,4 +71,6 @@ add_executable (websocket-example
if (NOT WIN32)
target_link_libraries(websocket-example ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(websocket-example ${Boost_LIBRARIES})
endif()

View File

@ -16,6 +16,8 @@ add_executable (lib-tests
)
if (NOT WIN32)
target_link_libraries(lib-tests ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(lib-tests ${Boost_LIBRARIES})
endif()

View File

@ -39,4 +39,6 @@ add_executable (core-tests
if (NOT WIN32)
target_link_libraries(core-tests ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(core-tests ${Boost_LIBRARIES})
endif()

View File

@ -32,6 +32,8 @@ add_executable (http-tests
if (NOT WIN32)
target_link_libraries(http-tests ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(http-tests ${Boost_LIBRARIES})
endif()
add_executable (bench-tests
@ -44,5 +46,7 @@ add_executable (bench-tests
)
if (NOT WIN32)
target_link_libraries(bench-tests ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(bench-tests ${Boost_LIBRARIES})
endif()

View File

@ -22,6 +22,8 @@ add_executable (websocket-tests
if (NOT WIN32)
target_link_libraries(websocket-tests ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(websocket-tests ${Boost_LIBRARIES})
endif()
if (MINGW)

View File

@ -21,4 +21,6 @@ add_executable (zlib-tests
if (NOT WIN32)
target_link_libraries(zlib-tests ${Boost_LIBRARIES} Threads::Threads)
else()
target_link_libraries(zlib-tests ${Boost_LIBRARIES})
endif()