-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathCMakeLists.txt
189 lines (159 loc) · 4.5 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(COCAINE-CORE)
SET(COCAINE_VERSION_MAJOR 0)
SET(COCAINE_VERSION_MINOR 12)
SET(COCAINE_VERSION_RELEASE 14)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
IF(APPLE)
SET(CMAKE_MACOSX_RPATH ON)
ENDIF()
OPTION(COCAINE_ALLOW_TESTS "Build Tests" OFF)
OPTION(COCAINE_ALLOW_BENCHMARKS "Build Benchmarking Tools" OFF)
# Import our CMake modules.
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/foreign/modules )
INCLUDE(locate_library)
INCLUDE(AddCXXCompilerFlag)
IF(NOT APPLE)
LOCATE_LIBRARY(LIBBFD "bfd.h" "bfd")
SET(LIBBFD_LIBRARY "bfd" "dl")
ENDIF()
FIND_PACKAGE(Boost 1.46.0 REQUIRED COMPONENTS
filesystem
program_options
system
thread)
LOCATE_LIBRARY(LIBLTDL "ltdl.h" "ltdl")
LOCATE_LIBRARY(LIBMSGPACK "msgpack.hpp" "msgpack")
LOCATE_LIBRARY(LIBMHASH "mhash.h" "mhash")
IF(NOT APPLE)
LOCATE_LIBRARY(LIBUUID "uuid/uuid.h" "uuid")
SET(LIBUUID_LIBRARY "uuid")
ENDIF()
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/config.hpp.in"
"${PROJECT_SOURCE_DIR}/include/cocaine/config.hpp")
INCLUDE_DIRECTORIES(SYSTEM
${Boost_INCLUDE_DIRS}
${LIBMHASH_INCLUDE_DIRS}
${LIBMSGPACK_INCLUDE_DIRS}
${LIBLTDL_INCLUDE_DIRS}
# Bundled third-party libraries.
${PROJECT_SOURCE_DIR}/foreign/asio/asio/include
${PROJECT_SOURCE_DIR}/foreign/backward-cpp
${PROJECT_SOURCE_DIR}/foreign/rapidjson/include)
INCLUDE_DIRECTORIES(BEFORE
${PROJECT_SOURCE_DIR}/include)
LINK_DIRECTORIES(
${Boost_LIBRARY_DIRS}
${LIBMHASH_LIBRARY_DIRS}
${LIBMSGPACK_LIBRARY_DIRS}
${LIBLTDL_LIBRARY_DIRS})
ADD_LIBRARY(cocaine-io-util SHARED
src/encoder.cpp
src/errors.cpp
src/header.cpp
src/trace.cpp)
ADD_LIBRARY(cocaine-core SHARED
src/actor.cpp
src/api/authentication.cpp
src/api/authorization.cpp
src/api/storage.cpp
src/api/unicorn.cpp
src/auth/uid.cpp
src/authorization/event.cpp
src/authorization/storage.cpp
src/authorization/unicorn.cpp
src/chamber.cpp
src/cluster/multicast.cpp
src/cluster/predefine.cpp
src/context.cpp
src/context/config.cpp
src/context/mapper.cpp
src/crypto.cpp
src/decoder.cpp
src/defaults.cpp
src/dispatch.cpp
src/dynamic.cpp
src/engine.cpp
src/essentials.cpp
src/executor/asio.cpp
src/gateway/adhoc.cpp
src/logging.cpp
src/repository.cpp
src/service/locator.cpp
src/service/locator/routing.cpp
src/service/logging.cpp
src/service/storage.cpp
src/session.cpp
src/signal.cpp
src/storage/files.cpp
src/trace/logger.cpp
src/unicorn/value.cpp
src/unique_id.cpp
)
TARGET_LINK_LIBRARIES(cocaine-io-util
blackhole
${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(cocaine-core
cocaine-io-util
${Boost_LIBRARIES}
${LIBBFD_LIBRARY}
ltdl
mhash
msgpack
blackhole
metrics
${LIBUUID_LIBRARY})
SET_TARGET_PROPERTIES(cocaine-io-util PROPERTIES
VERSION 3)
SET_TARGET_PROPERTIES(cocaine-core PROPERTIES
VERSION 3)
IF (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_TARGET_PROPERTIES(cocaine-core PROPERTIES
LINK_FLAGS -Wl,--version-script=${PROJECT_SOURCE_DIR}/libcocaine-core3.version)
ENDIF()
ADD_EXECUTABLE(cocaine-runtime
src/runtime/logging.cpp
src/runtime/pid_file.cpp
src/runtime/runtime.cpp)
TARGET_LINK_LIBRARIES(cocaine-runtime
${Boost_LIBRARIES}
blackhole
cocaine-core)
# Try and enable C++11.
ADD_CXX_COMPILER_FLAG(-std=c++11)
IF(NOT HAVE_CXX_FLAG_STD_CXX11)
ADD_CXX_COMPILER_FLAG(-std=c++0x)
ENDIF()
# Turn compiler warnings.
ADD_CXX_COMPILER_FLAG(-Wall)
ADD_CXX_COMPILER_FLAG(-Wextra)
ADD_CXX_COMPILER_FLAG(-Werror RELEASE)
ADD_CXX_COMPILER_FLAG(-Woverloaded-virtual)
ADD_CXX_COMPILER_FLAG(-pedantic)
ADD_CXX_COMPILER_FLAG(-pedantic-errors)
IF(COCAINE_ALLOW_TESTS OR COCAINE_ALLOW_BENCHMARKS)
ADD_CUSTOM_TARGET(unittest
COMMAND ${CMAKE_BINARY_DIR}/tests/cocaine-core-unit
DEPENDS cocaine-core-unit
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
ADD_SUBDIRECTORY(tests)
ENDIF()
IF(NOT COCAINE_LIBDIR)
SET(COCAINE_LIBDIR lib)
ENDIF()
INSTALL(
TARGETS
cocaine-io-util
cocaine-core
cocaine-runtime
RUNTIME DESTINATION bin COMPONENT runtime
LIBRARY DESTINATION ${COCAINE_LIBDIR} COMPONENT runtime
ARCHIVE DESTINATION ${COCAINE_LIBDIR} COMPONENT development)
INSTALL(
DIRECTORY
include/
DESTINATION include
COMPONENT development
PATTERN "detail" EXCLUDE)