-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
95 lines (69 loc) · 2.72 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
87
88
89
90
91
92
93
# ----------------------------------------------------------------------------------------
# Module setup
# ----------------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(asyncly CXX)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(CMake/AsynclyBuild.cmake)
option(BUILD_SHARED_LIBS "Build libraries as shared ones" OFF)
option(ENABLE_TESTING "Build tests" ON)
if(WIN32)
add_definitions("-DNOMINMAX")
add_definitions("-DWIN32_LEAN_AND_MEAN")
add_definitions("-D_WIN32_WINNT=0x0601")
add_compile_options("/bigobj")
add_compile_options("/Zc:__cplusplus")
endif()
find_package(function2 CONFIG REQUIRED)
find_package(prometheus-cpp CONFIG REQUIRED)
find_package(Boost REQUIRED)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)
if(ENABLE_TESTING)
find_package(benchmark CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)
enable_testing()
endif()
# ----------------------------------------------------------------------------------------
# Targets
# ----------------------------------------------------------------------------------------
add_library(asyncly
Source/executor/CurrentExecutor.cpp
Source/executor/AsioExecutorController.cpp
Source/executor/ExceptionShield.cpp
Source/executor/ExternalEventExecutorController.cpp
Source/executor/InlineExecutor.cpp
Source/executor/MetricsWrapper.cpp
Source/executor/Strand.cpp
Source/executor/ThreadPoolExecutorController.cpp
Source/executor/detail/AsioExecutor.cpp
Source/executor/detail/ExecutorMetrics.cpp
Source/executor/detail/ExternalEventExecutor.cpp
Source/executor/detail/MetricsTask.cpp
Source/executor/detail/MetricsTask.h
Source/executor/detail/StrandImpl.cpp
Source/executor/detail/StrandImpl.h
Source/task/detail/PeriodicTask.cpp
Source/task/detail/TaskCurrentExecutorGuard.cpp
)
target_compile_features(asyncly PUBLIC cxx_std_20)
target_include_directories(asyncly PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>)
target_link_libraries(asyncly PUBLIC Boost::boost prometheus-cpp::core function2::function2)
if(ENABLE_TESTING)
add_subdirectory(Test)
endif()
# ----------------------------------------------------------------------------------------
# Installation
# ----------------------------------------------------------------------------------------
install(DIRECTORY Include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS asyncly
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
asyncly_install_export(
EXPORT ${PROJECT_NAME}-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
NAMESPACE ${PROJECT_NAME}::
)