-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
173 lines (143 loc) · 4.34 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
#--------------------------------------
# Hunter init
#--------------------------------------
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.24.16.tar.gz"
SHA1 "09668c254f01afeca1b3d3d2e4692ed5e0e39dcc"
LOCAL
)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
add_subdirectory(../core-cpp-api ${CMAKE_BINARY_DIR}/futoin_api EXCLUDE_FROM_ALL)
endif()
#--------------------------------------
# Project definition
#--------------------------------------
project(futoin_asyncsteps
VERSION "1.4.2" # AUTO-REPLACE
LANGUAGES CXX)
# Options
#-----
option(FUTOIN_WITH_TESTS "Build with tests" OFF)
option(FUTOIN_WITH_DOCS "Build documentation" OFF)
# Deps
#-----
hunter_add_package(Boost)
find_package(Boost CONFIG REQUIRED)
if (FUTOIN_WITH_TESTS)
hunter_add_package(Boost COMPONENTS test)
find_package(Boost CONFIG REQUIRED unit_test_framework)
endif()
# Sources
#-----
file(GLOB_RECURSE PROJECT_HDR
${CMAKE_CURRENT_LIST_DIR}/include/*.?pp
)
file(GLOB_RECURSE PROJECT_SRC
${CMAKE_CURRENT_LIST_DIR}/src/*.?pp
)
# Result objects
#-----
find_package(Threads REQUIRED)
add_library(${PROJECT_NAME} ${PROJECT_SRC})
add_library(futoin::asyncsteps ALIAS ${PROJECT_NAME})
target_sources(${PROJECT_NAME} PUBLIC ${PROJECT_HDR})
target_sources(
${PROJECT_NAME}
PUBLIC ${PROJECT_HDR}
PRIVATE ${PROJECT_SRC}
)
target_link_libraries(${PROJECT_NAME}
PUBLIC futoin::api Boost::boost
PRIVATE Threads::Threads)
target_include_directories(${PROJECT_NAME}
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include
)
# since CMake 3.8
#target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11 )
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
target_compile_options(${PROJECT_NAME} PRIVATE
# see target_compile_features
-std=c++11
-Wall
-Wextra
-Werror
)
endif()
#--------------------------------------
# Project testing
#--------------------------------------
if (FUTOIN_WITH_TESTS)
include(CTest)
enable_testing()
#---
set(PROJECT_TEST_NAME RIAsyncStepsTest)
file(GLOB_RECURSE PROJECT_TEST_SRC
${CMAKE_CURRENT_LIST_DIR}/tests/*.test.?pp
)
add_executable(${PROJECT_TEST_NAME} ${PROJECT_TEST_SRC})
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
target_compile_options(${PROJECT_TEST_NAME} PRIVATE
# see target_compile_features
-std=c++11
-Wall
-Wextra
-Werror
)
endif()
target_link_libraries(${PROJECT_TEST_NAME}
PRIVATE ${PROJECT_NAME} Boost::unit_test_framework)
if (FALSE)
find_library(LIB_PERFTOOLS libtcmalloc.so.4)
target_link_libraries(${PROJECT_TEST_NAME}
PRIVATE ${LIB_PERFTOOLS})
endif()
add_test(${PROJECT_NAME} ${PROJECT_TEST_NAME})
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/bench)
endif()
#--------------------------------------
# Static analysis & formatting
#--------------------------------------
if (FUTOIN_WITH_TESTS)
#---
add_custom_target(
clangtidy-${PROJECT_NAME} ALL
COMMAND /usr/bin/clang-tidy
-quiet
${PROJECT_SRC}
--
`echo
$<JOIN:$<TARGET_PROPERTY:${PROJECT_NAME},COMPILE_OPTIONS>,\ >
-I$<JOIN:$<TARGET_PROPERTY:${PROJECT_NAME},INCLUDE_DIRECTORIES>,\ -I>`
-DFUTOIN_IN_CLANG_TIDY
)
add_custom_target(
clangformat-${PROJECT_NAME} ALL
COMMAND /usr/bin/clang-format
-style=file
-i
`echo
$<JOIN:$<TARGET_PROPERTY:${PROJECT_NAME},SOURCES>,\ >
$<JOIN:$<TARGET_PROPERTY:${PROJECT_TEST_NAME},SOURCES>,\ >`
)
endif()
#--------------------------------------
# Build documentation
#--------------------------------------
if (FUTOIN_WITH_DOCS)
find_package(Doxygen REQUIRED dot)
add_custom_target(
docs-${PROJECT_NAME} ALL
COMMAND ${CMAKE_COMMAND} -E env "BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}" ${DOXYGEN_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
# prevent Doxygen segfault on invalid code
add_dependencies(docs-${PROJECT_NAME} ${PROJECT_NAME})
endif()
#--------------------------------------