forked from AliceO2Group/Monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
185 lines (151 loc) · 5.14 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
####################################
# General project definition
####################################
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.2 FATAL_ERROR)
### CMP0025 Compiler id for Apple Clang is now AppleClang.
### CMP0042 MACOSX_RPATH is enabled by default.
FOREACH (p
CMP0025 # CMake 3.0
CMP0042 # CMake 3.0
)
IF (POLICY ${p})
cmake_policy(SET ${p} NEW)
ENDIF ()
endforeach ()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
project(Monitoring)
# Load some basic macros which are needed later on
include(O2Utils)
include(MonitoringDependencies)
# Set the default build type to "RelWithDebInfo"
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo"
CACHE
STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Coverage."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0)
set(VERSION_MAJOR "0")
set(VERSION_MINOR "0")
set(VERSION_PATCH "0")
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# C++14
IF (CMAKE_VERSION VERSION_LESS 3.1)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=c++14 COMPILER_SUPPORTS_CXX14)
if (COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else ()
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
endif ()
ELSE ()
set(CMAKE_CXX_STANDARD 14) # proper way in CMake >= 3.1
ENDIF ()
# Add compiler flags for warnings and (more importantly) fPIC and debug symbols
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -fPIC")
add_subdirectory(doc)
####################################
# Module, library and executable definition
####################################
set(MODULE_NAME "Monitoring")
O2_SETUP(NAME ${MODULE_NAME})
set(SRCS
src/Monitoring.cxx
src/Metric.cxx
src/Backends/InfoLoggerBackend.cxx
src/Backends/Flume.cxx
src/DerivedMetrics.cxx
src/ProcessMonitor.cxx
src/ProcessDetails.cxx
src/MonitoringFactory.cxx
src/Transports/UDP.cxx
src/Transports/TCP.cxx
src/Transports/HTTP.cxx
src/Exceptions/MonitoringException.cxx
src/Exceptions/MonitoringInternalException.cxx
)
# Detect operating system
if (UNIX AND NOT APPLE)
message(STATUS "Detected Linux OS: Process monitor enabled")
add_definitions(-D_OS_LINUX)
endif()
if (WIN32)
message(STATUS "Detected Windows OS: Process monitor disabled")
add_definitions(-D_OS_WINDOWS)
endif()
if (APPLE)
message(STATUS "Detected Mac OS: Process monitor disabled")
add_definitions(-D_OS_MAC)
endif()
# Backends
message(STATUS "Backends")
message(STATUS " Compiling InfoLoggerBackend backend")
message(STATUS " Compiling Flume UDP/JSON backend")
if(APMON_FOUND)
message(STATUS " Compiling ApMon backend")
list(APPEND SRCS src/Backends/ApMonBackend.cxx)
add_definitions(-D_WITH_APPMON)
else()
message(WARNING " ApMon not found, skipping ApMon backend")
endif()
if(CURL_FOUND)
message(STATUS " Compiling InfluxDB HTTP and UDP backend")
add_definitions(-D_WITH_INFLUX)
list(APPEND SRCS src/Backends/InfluxDB.cxx)
else()
message(WARNING " libcurl not found, skipping InfluxDB backend")
endif()
# Produce the final Version.h using template Version.h.in and substituting variables.
# We don't want to polute our source tree with it, thus putting it in binary tree.
configure_file("include/${MODULE_NAME}/Version.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/include/${MODULE_NAME}/Version.h"
@ONLY
)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/include
)
set(LIBRARY_NAME Monitoring)
set(BUCKET_NAME o2_monitoring_bucket)
O2_GENERATE_LIBRARY()
enable_testing()
set(TEST_SRCS
test/testMonitoring.cxx
test/testDerived.cxx
test/testFlume.cxx
test/testMetric.cxx
test/testProcessDetails.cxx
test/testProcessMonitor.cxx
test/testInfluxDb.cxx
)
if(APMON_FOUND)
list(APPEND TEST_SRCS test/testApMon.cxx)
configure_file(test/ApMon.conf ApMon.conf COPYONLY)
endif()
O2_GENERATE_TESTS(
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
BUCKET_NAME ${BUCKET_NAME}
TEST_SRCS ${TEST_SRCS}
)
set(EXAMPLES
examples/1-Basic.cxx
examples/2-TaggedMetrics.cxx
examples/3-UserDefinedTimestamp
examples/4-RateDerivedMetric.cxx
examples/5-Benchmark.cxx
examples/6-Increment.cxx
examples/7-Latency.cxx
examples/8-Multiple.cxx
examples/9-Timer.cxx
examples/10-Buffering.cxx
)
foreach (example ${EXAMPLES})
get_filename_component(example_name ${example} NAME)
string(REGEX REPLACE ".cxx" "" example_name ${example_name})
O2_GENERATE_EXECUTABLE(
EXE_NAME ${example_name}
SOURCES ${example}
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
BUCKET_NAME ${BUCKET_NAME}
)
endforeach()