-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
172 lines (155 loc) · 4.4 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
cmake_minimum_required(VERSION 3.7.0)
project(dcos-mesos-modules)
set(MESOS_ROOT "../mesos" CACHE PATH "Mesos root directory.")
get_filename_component(MESOS_ROOT ${MESOS_ROOT} ABSOLUTE)
set(BOOST_ROOT_DIR "" CACHE PATH "Boost libs root directory.")
message("MESOS_ROOT is ${MESOS_ROOT}")
# CMAKE MODULE SETUP.
#####################
# Paths that are searched when `include(...)` is called.
list(APPEND CMAKE_MODULE_PATH ${MESOS_ROOT}/cmake)
list(APPEND CMAKE_MODULE_PATH ${MESOS_ROOT}/3rdparty/cmake)
list(APPEND CMAKE_MODULE_PATH ${MESOS_ROOT}/src/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# Macros.
include(CTest)
include(Dependencies)
# Set the default standard to C++11 for all targets.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Do not use, for example, `-std=gnu++11`.
set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND DEPENDENCIES_INC
"${BOOST_INCL}"
"${CURL_INCL}"
"${GLOG_INCL}"
"${MESOS_ROOT}/build/include"
"${MESOS_ROOT}/include"
"${PICOJSON_INCL}"
"${PROCESS_INCL}"
"${PROTOBUF_INCL}"
"${RAPIDJSON_INCL}"
"${STOUT_INCL}"
"${ZOOKEEPER_INCL}"
)
list(APPEND DEPENDENCIES_LIB
glog
mesos
mesos_protobufs
process
protobuf
$<$<PLATFORM_ID:Linux>:pthread>
)
# TODO(akornatskyy): Agreed to have CMakeLists.txt in each directory (per
# module), however, right now that is not possible because corresponding
# changes require some changes to source code (that would break
# autotools build).
add_subdirectory(dockercfg)
add_subdirectory(logsink)
add_subdirectory(journald)
# overlay
add_library(overlay SHARED
overlay/messages.pb.cc
overlay/overlay.pb.cc
overlay/agent_metrics.cpp
overlay/agent.cpp
overlay/supervisor_metrics.cpp
overlay/master_metrics.cpp
overlay/master.cpp
)
install(TARGETS overlay LIBRARY DESTINATION lib/mesos)
add_custom_command(
OUTPUT overlay/messages.pb.cc overlay/overlay.pb.cc
COMMAND protoc
-I${CMAKE_CURRENT_SOURCE_DIR}
--cpp_out=${CMAKE_CURRENT_BINARY_DIR}
overlay/messages.proto overlay/overlay.proto
DEPENDS overlay/messages.proto overlay/overlay.proto
)
target_include_directories(overlay PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
${DEPENDENCIES_INC}
)
# metrics
add_library(metrics SHARED
metrics/messages.pb.cc
metrics/isolator.cpp
)
install(TARGETS metrics
ARCHIVE DESTINATION lib/mesos
LIBRARY DESTINATION lib/mesos
)
add_custom_command(
OUTPUT metrics/messages.pb.cc
COMMAND protoc
-I${CMAKE_CURRENT_SOURCE_DIR}
--cpp_out=${CMAKE_CURRENT_BINARY_DIR}
metrics/messages.proto
DEPENDS metrics/messages.proto
)
target_include_directories(metrics PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
${DEPENDENCIES_INC}
)
if (BUILD_TESTING)
list(APPEND TEST_DEPENDENCIES_INC
${DEPENDENCIES_INC}
"${GMOCK_INCL}"
"${GTEST_INCL}"
"${MESOS_ROOT}/build/src"
"${MESOS_ROOT}/src"
"${NVML_INCL}"
)
list(APPEND TEST_DEPENDENCIES_LIB
${DEPENDENCIES_LIB}
gmock
)
add_subdirectory(tests)
# Test binary for metrics
add_executable(test-metrics
metrics/messages.pb.cc
tests/metrics_tests.cpp
)
# TODO(akornatskyy): Paths defined as "nowhere" are needed to build Mesos
# test utils (https://github.com/apache/mesos/blob/master/src/tests/utils.cpp).
# These definitions can be dropped if the test utilities we need here are
# split from the path-dependent utilities into a separate file.
add_definitions(
-DMODULES_BUILD_DIR="${PROJECT_BINARY_DIR}"
-DSOURCE_DIR="${MESOS_ROOT}"
-DBUILD_DIR="${MESOS_ROOT}/build"
-DPKGMODULEDIR="nowhere"
-DLIBDIR="nowhere"
-DPKGLIBEXECDIR="nowhere"
-DTESTLIBEXECDIR="nowhere"
-DSBINDIR="nowhere"
-DPKGDATADIR="nowhere"
-DVERSION="1.10.0"
)
target_include_directories(test-metrics PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
${TEST_DEPENDENCIES_INC}
)
target_link_libraries(test-metrics PRIVATE
metrics
mesos-tests
${TEST_DEPENDENCIES_LIB}
)
add_test(NAME Metrics_Tests COMMAND test-metrics)
# Test binary for overlay
add_executable(test-overlay tests/overlay_tests.cpp)
target_include_directories(test-overlay PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
${TEST_DEPENDENCIES_INC}
)
target_link_libraries(test-overlay PRIVATE
overlay
mesos-tests
${TEST_DEPENDENCIES_LIB}
)
add_test(NAME Overlay_Tests COMMAND test-overlay)
endif()