mirror of
https://github.com/boostorg/cobalt.git
synced 2026-01-19 04:02:16 +00:00
130 lines
4.2 KiB
CMake
130 lines
4.2 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
|
|
set(BOOST_REQUESTS_VERSION 1)
|
|
if(BOOST_SUPERPROJECT_VERSION)
|
|
set(BOOST_REQUESTS_VERSION ${BOOST_SUPERPROJECT_VERSION})
|
|
endif()
|
|
|
|
project(boost_cobalt VERSION "${BOOST_COBALT_VERSION}" LANGUAGES CXX)
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(BOOST_COBALT_IS_ROOT OFF)
|
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
set(BOOST_COBALT_IS_ROOT ON)
|
|
endif()
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../boost.css)
|
|
set(BOOST_COBALT_SHOULD_BE_INLINE ON)
|
|
else()
|
|
set(BOOST_COBALT_SHOULD_BE_INLINE OFF)
|
|
endif()
|
|
|
|
option(BOOST_COBALT_BUILD_INLINE "Configure as if part of the boost source tree" ${BOOST_COBALT_SHOULD_BE_INLINE})
|
|
|
|
file(GLOB_RECURSE ADOC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.adoc)
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html
|
|
COMMAND asciidoctor ${CMAKE_CURRENT_SOURCE_DIR}/doc/index.adoc --require asciidoctor-diagram --require asciidoctor-multipage -b multipage_html5 -o ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html
|
|
DEPENDS ${ADOC_FILES})
|
|
|
|
add_custom_target(boost_cobalt_doc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html)
|
|
|
|
|
|
if(BOOST_COBALT_IS_ROOT)
|
|
#include(CTest)
|
|
endif()
|
|
if(NOT BOOST_SUPERPROJECT_VERSION)
|
|
option(BOOST_COBALT_INSTALL "Install boost::cobalt files" ON)
|
|
option(BOOST_COBALT_BUILD_TESTS "Build boost::cobalt tests" ${BUILD_TESTING})
|
|
option(BOOST_COBALT_BUILD_EXAMPLES "Build boost::cobalt examples" ${BOOST_COBALT_IS_ROOT})
|
|
option(BOOST_COBALT_BUILD_BENCHMARKS "Build boost::cobalt benchmarks" OFF)
|
|
else()
|
|
set(BOOST_COBALT_BUILD_TESTS ${BUILD_TESTING})
|
|
endif()
|
|
|
|
set(BOOST_COBALT_SHOULD_USE_CONTAINER OFF)
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CLANG_VERSION_MAJOR LESS 16)
|
|
set(BOOST_COBALT_SHOULD_USE_CONTAINER ON)
|
|
endif()
|
|
|
|
option(BOOST_COBALT_USE_BOOST_CONTAINER "Use boost.container instead of std::pmr" ${BOOST_COBALT_SHOULD_USE_CONTAINER})
|
|
|
|
|
|
if(BOOST_COBALT_IS_ROOT AND BOOST_COBALT_BUILD_INLINE)
|
|
#
|
|
# Building inside Boost tree, but as a separate project e.g. on Travis or
|
|
# other CI, or when producing Visual Studio Solution and Projects.
|
|
|
|
set(BOOST_INCLUDE_LIBRARIES COBALT)
|
|
set(BOOST_EXCLUDE_LIBRARIES COBALT)
|
|
|
|
set(CMAKE_FOLDER _deps)
|
|
add_subdirectory(../.. _deps/boost EXCLUDE_FROM_ALL)
|
|
unset(CMAKE_FOLDER)
|
|
endif()
|
|
|
|
if (NOT BOOST_COBALT_BUILD_INLINE)
|
|
find_package(Threads REQUIRED)
|
|
# Boost 1.82 is the first with a Boost.ASIO with necessary support
|
|
find_package(Boost 1.82 REQUIRED COMPONENTS system OPTIONAL_COMPONENTS json context url)
|
|
if (BOOST_COBALT_USE_BOOST_CONTAINER)
|
|
find_package(Boost REQUIRED container)
|
|
endif()
|
|
include_directories(include)
|
|
endif()
|
|
|
|
find_package(OpenSSL)
|
|
if (NOT MSVC)
|
|
link_libraries(${OPENSSL_LIBRARIES})
|
|
endif()
|
|
|
|
add_library(boost_cobalt
|
|
src/detail/exception.cpp
|
|
src/detail/util.cpp
|
|
src/error.cpp
|
|
src/channel.cpp
|
|
src/main.cpp
|
|
src/this_thread.cpp
|
|
src/thread.cpp)
|
|
target_include_directories(boost_cobalt PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
target_link_libraries(boost_cobalt PUBLIC
|
|
Boost::system
|
|
Threads::Threads)
|
|
target_compile_definitions(boost_cobalt PRIVATE BOOST_COBALT_SOURCE=1 )
|
|
|
|
if (BOOST_COBALT_USE_BOOST_CONTAINER)
|
|
target_link_libraries(boost_cobalt PUBLIC Boost::container)
|
|
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_USE_BOOST_CONTAINER_PMR=1 )
|
|
endif()
|
|
|
|
add_library(Boost::cobalt ALIAS boost_cobalt)
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_DYN_LINK=1)
|
|
else()
|
|
target_compile_definitions(boost_cobalt PUBLIC BOOST_COBALT_STATIC_LINK=1)
|
|
endif()
|
|
|
|
if(BOOST_COBALT_INSTALL AND NOT BOOST_SUPERPROJECT_VERSION)
|
|
install(TARGETS boost_cobalt
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
)
|
|
endif()
|
|
|
|
|
|
if(BOOST_COBALT_BUILD_TESTS)
|
|
add_subdirectory(test)
|
|
endif()
|
|
|
|
|
|
if(BOOST_COBALT_BUILD_EXAMPLES)
|
|
add_subdirectory(example)
|
|
set_target_properties(boost_cobalt PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
endif()
|
|
|
|
if(BOOST_COBALT_BUILD_BENCHMARKS)
|
|
add_subdirectory(bench)
|
|
endif()
|