-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
86 lines (65 loc) · 2.26 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
cmake_minimum_required(VERSION 3.12)
project(cpool)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
set(CMAKE_CXX_STANDARD 20)
include(CheckCXXCompilerFlag)
include(conan.cmake)
# include source directories
include_directories(
"${CMAKE_SOURCE_DIR}/"
)
check_cxx_compiler_flag(-std=c++20 HAVE_FLAG_STD_CXX20)
if(HAVE_FLAG_STD_CXX20)
set( THREAD_CXX_FLAGS "-pthread")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines-ts")
message(FATAL_ERROR "Clang coroutines is not supported in asio. Please add support")
endif()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${THREAD_CXX_FLAGS}" )
if(NOT CMAKE_INSTALL_INCLUDEDIR)
set( CMAKE_INSTALL_INCLUDEDIR "/usr/include" )
endif()
if(NOT CMAKE_INSTALL_LIBDIR)
set( CMAKE_INSTALL_LIBDIR "/usr/lib" )
endif()
else()
message(FATAL_ERROR "This library requires C++20")
endif()
# integrate conan build process
if(NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_cmake_run(CONANFILE conanfile.py
BASIC_SETUP CMAKE_TARGETS
BUILD missing)
conan_cmake_autodetect(settings)
endif()
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else()
message(FATAL_ERROR "The file conanbuildinfo.cmake could not be generated")
endif()
# install headers
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cpool/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/cpool"
)
# create and configure the example targets
option(BUILD_EXAMPLES "Build examples" OFF)
message("-- Examples is ${BUILD_EXAMPLES}")
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif(BUILD_EXAMPLES)
# create and configure the test targets
option(BUILD_TESTING "Build Unit Tests" ON)
message("-- Testing is ${BUILD_TESTING}")
if(BUILD_TESTING)
if(CPOOL_TRACE_LOGGING)
add_compile_definitions(CPOOL_TRACE_LOGGING)
endif(CPOOL_TRACE_LOGGING)
enable_testing()
add_subdirectory(test)
endif(BUILD_TESTING)