-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
41 lines (32 loc) · 1.27 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
cmake_minimum_required(VERSION 3.17)
set(ASIOCHAN_VERSION 0.4.3)
project(AsioChan VERSION "${ASIOCHAN_VERSION}")
include(CheckCXXCompilerFlag)
option(ASIOCHAN_USE_STANDALONE_ASIO "Use standalone ASIO instead of Boost.ASIO" OFF)
add_library(asiochan INTERFACE)
add_library(asiochan::asiochan ALIAS asiochan)
target_compile_features(asiochan INTERFACE cxx_std_20)
target_include_directories(asiochan INTERFACE include)
set(COROUTINES_FLAG -fcoroutines)
check_cxx_compiler_flag("${COROUTINES_FLAG}" COMPILER_HAS_COROUTINES_FLAG)
if (COMPILER_HAS_COROUTINES_FLAG)
target_compile_options(asiochan INTERFACE "${COROUTINES_FLAG}")
endif()
if (ASIOCHAN_USE_STANDALONE_ASIO)
target_compile_definitions(asiochan INTERFACE ASIOCHAN_USE_STANDALONE_ASIO)
endif()
# Building the tests and examples requires Conan packages
set(CONAN_BUILD_INFO_PATH "${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake")
if (EXISTS "${CONAN_BUILD_INFO_PATH}")
include("${CONAN_BUILD_INFO_PATH}")
conan_basic_setup(TARGETS)
if (ASIOCHAN_USE_STANDALONE_ASIO)
target_link_libraries(asiochan INTERFACE CONAN_PKG::asio)
else()
target_link_libraries(asiochan INTERFACE CONAN_PKG::boost)
endif()
find_package(Threads REQUIRED)
enable_testing()
add_subdirectory(examples)
add_subdirectory(tests)
endif()