-
Notifications
You must be signed in to change notification settings - Fork 540
/
CMakeLists.txt
279 lines (248 loc) · 8.79 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
cmake_minimum_required(VERSION 2.4)
project(cppa CXX)
set(LIBCPPA_VERSION_MAJOR 0)
set(LIBCPPA_VERSION_MINOR 4)
set(LIBCPPA_VERSION_PATCH 1)
# prohibit in-source builds
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed. Please use "
"./configure to choose a build directory and "
"initialize the build configuration.")
endif ()
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# check if the user provided CXXFLAGS on the command line
if (CMAKE_CXX_FLAGS)
set(CXXFLAGS_PROVIDED true)
endif ()
if (CXXFLAGS_PROVIDED)
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_CXX_FLAGS_MINSIZEREL "")
set(CMAKE_CXX_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "")
else ()
set(CMAKE_CXX_FLAGS "-std=c++11 -Wextra -Wall -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-O4")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
endif ()
# check for g++ >= 4.7 or clang++ > = 3.2
try_run(ProgramResult
CompilationSucceeded
${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src/get_compiler_version.cpp
RUN_OUTPUT_VARIABLE CompilerVersion)
if (NOT CompilationSucceeded OR NOT ProgramResult EQUAL 0)
message(FATAL_ERROR "Cannot determine compiler version")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
if (CompilerVersion VERSION_GREATER 4.6)
message(STATUS "Found g++ version ${CompilerVersion}")
else ()
message(FATAL_ERROR "g++ >= 4.7 required (found: ${CompilerVersion}.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if (CompilerVersion VERSION_GREATER 3.1)
message(STATUS "Found clang++ version ${CompilerVersion}")
else ()
message(FATAL_ERROR "clang++ >= 3.2 required (found: ${CompilerVersion}.")
endif ()
if (NOT CXXFLAGS_PROVIDED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif ()
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()
# set build type (evaluate ENABLE_DEBUG flag)
if (ENABLE_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DEBUG")
#else ()
# set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ()
# set build default build type if not set
if (CMAKE_BUILD_TYPE)
else (CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif (CMAKE_BUILD_TYPE)
if (DISABLE_CONTEXT_SWITCHING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DISABLE_CONTEXT_SWITCHING")
endif ()
set(LIBCPPA_SRC
src/abstract_tuple.cpp
src/actor.cpp
src/actor_count.cpp
src/actor_proxy.cpp
src/actor_proxy_cache.cpp
src/actor_registry.cpp
src/addressed_message.cpp
src/any_tuple.cpp
src/atom.cpp
src/attachable.cpp
src/behavior_stack.cpp
src/binary_deserializer.cpp
src/binary_serializer.cpp
src/buffer.cpp
src/channel.cpp
src/thread_mapped_actor.cpp
src/demangle.cpp
src/deserializer.cpp
src/duration.cpp
src/empty_tuple.cpp
src/event_based_actor.cpp
src/exception.cpp
src/factory.cpp
src/fd_util.cpp
src/fiber.cpp
src/group.cpp
src/group_manager.cpp
src/ipv4_acceptor.cpp
src/ipv4_io_stream.cpp
src/local_actor.cpp
src/middleman.cpp
src/network_manager.cpp
src/object.cpp
src/object_array.cpp
src/opt.cpp
src/partial_function.cpp
src/pattern.cpp
src/primitive_variant.cpp
src/process_information.cpp
src/receive.cpp
src/ripemd_160.cpp
src/scheduled_actor.cpp
src/scheduled_actor_dummy.cpp
src/scheduler.cpp
src/self.cpp
src/serializer.cpp
src/shared_spinlock.cpp
src/singleton_manager.cpp
src/string_serialization.cpp
src/thread_pool_scheduler.cpp
src/to_uniform_name.cpp
src/unicast_network.cpp
src/uniform_type_info.cpp
src/yield_interface.cpp
src/context_switching_actor.cpp
)
set(boost_context third_party/boost_context)
# add third party Boost.Context sources if context-switching is enabled
if (NOT DISABLE_CONTEXT_SWITCHING)
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
if (APPLE)
set(fcontext_asm ${boost_context}/src/asm/fcontext_i386_sysv_macho_gas.S)
else ()
set(fcontext_asm ${boost_context}/src/asm/fcontext_i386_sysv_elf_gas.S)
endif ()
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (APPLE)
set(fcontext_asm ${boost_context}/src/asm/fcontext_x86_64_sysv_macho_gas.S)
else ()
set(fcontext_asm ${boost_context}/src/asm/fcontext_x86_64_sysv_elf_gas.S)
endif ()
else ()
message(FATAL_ERROR "Unsupported platform (neither 32 nor 64 bit)")
endif ()
set_property(SOURCE ${fcontext_asm} PROPERTY LANGUAGE CXX)
set(LIBCPPA_SRC
${LIBCPPA_SRC}
${fcontext_asm}
${boost_context}/src/stack_utils_posix.cpp
${boost_context}/src/stack_allocator_posix.cpp
${boost_context}/src/fcontext.cpp
)
endif ()
if (BOOST_ROOT)
# Prevent falling back to system paths when using a custom Boost prefix.
set(Boost_NO_SYSTEM_PATHS true)
endif ()
find_package(Boost REQUIRED)
find_package(PTHREAD REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(. ${Boost_INCLUDE_DIRS} ${boost_context}/include ${PTHREAD_INCLUDE_DIR})
add_library(libcppa SHARED ${LIBCPPA_SRC})
target_link_libraries(libcppa ${CMAKE_LD_LIBS} ${Boost_THREAD_LIBRARY} ${PTHREAD_LIBRARIES})
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})
set_target_properties(libcppa
PROPERTIES
SOVERSION ${LIBRARY_SOVERSION}
VERSION ${LIBRARY_VERSION}
OUTPUT_NAME cppa)
# install shared library
install(TARGETS libcppa LIBRARY DESTINATION lib)
# install includes
install(DIRECTORY cppa/ DESTINATION include/cppa FILES_MATCHING PATTERN "*.hpp")
# process cmake_uninstall.cmake.in
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
# add uninstall target
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
if (LIBRARY_OUTPUT_PATH)
set (CPPA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
set (CPPA_LIBRARY_PATH ${LIBRARY_OUTPUT_PATH})
else ()
set (CPPA_LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
set (CPPA_LIBRARY_PATH ${CPPA_LIBRARY_OUTPUT_PATH})
set (LIBRARY_OUTPUT_PATH ${CPPA_LIBRARY_OUTPUT_PATH} CACHE PATH "Single directory for all libraries")
endif ()
# setting path to cppa headers and libcppa
set (CPPA_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/libcppa)
set (CPPA_INCLUDE ${CPPA_INCLUDE_PATH})
if (APPLE)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.dylib)
elseif (UNIX)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.so)
else ()
message (SEND_FATAL "Host platform not supported ...")
endif ()
if (EXECUTABLE_OUTPUT_PATH)
else ()
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single directory for all executables")
endif ()
enable_testing()
# set up subdirectories
add_subdirectory(unit_testing)
add_subdirectory(examples)
add_subdirectory(benchmarks)
add_dependencies(all_examples libcppa)
add_dependencies(all_unit_tests libcppa)
add_dependencies(all_benchmarks libcppa)
# set optional flags
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
set(CONTEXT_SWITCHING true)
if (DISABLE_CONTEXT_SWITCHING)
set(CONTEXT_SWITCHING false)
endif ()
# check for doxygen and add custom "doc" target to Makefile
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_SOURCE_DIR}/Doxyfile
@ONLY)
add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/Doxyfile
WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif ()
# done (print summary)
message("\n====================| Build Summary |===================="
"\n"
"\nLibcppa version: ${LIBRARY_VERSION}"
"\n"
"\nBuild type: ${CMAKE_BUILD_TYPE}"
"\nDebug mode: ${ENABLE_DEBUG}"
"\nContext switching: ${CONTEXT_SWITCHING}"
"\n"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${build_type}}"
"\n"
"\nSource directory: ${CMAKE_SOURCE_DIR}"
"\nBuild directory: ${CMAKE_BINARY_DIR}"
"\nExecutable path: ${EXECUTABLE_OUTPUT_PATH}"
"\nLibrary path: ${LIBRARY_OUTPUT_PATH}"
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
"\n"
"\nBoost: ${Boost_INCLUDE_DIR}"
"\n"
"\n===========================================================\n")