-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
129 lines (100 loc) · 2.98 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
cmake_minimum_required (VERSION 2.8.12)
project (statsdcc CXX)
set(DISABLE_PAL_FLAGS TRUE)
find_package(catkin REQUIRED
COMPONENTS
pal_statistics_msgs
roscpp
)
find_package(Boost REQUIRED regex)
catkin_package()
include(CheckIncludeFileCXX)
include (CheckCXXCompilerFlag)
set (PROJECT_VERSION_MAJOR 0)
set (PROJECT_VERSION_MINOR 14)
set (PROJECT_VERSION_PATCH 0)
set (PROJECT_VERSION
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
execute_process (
COMMAND git log -1 --format=%h
OUTPUT_VARIABLE BUILD
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT debug)
set (debug "false")
endif()
configure_file (include/statsdcc/version.h.in
${CATKIN_DEVEL_PREFIX}/include/statsdcc/version.h)
# set compiler flags
check_cxx_compiler_flag ('-std=c++11' COMPILER_SUPPORTS_CXX11)
check_cxx_compiler_flag ('-std=c++0x' COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
add_compile_options (-std=c++11)
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
add_compile_options (-std=c++0x)
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
else()
message(STATUS
"The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler."
)
endif()
add_compile_options (-Wall -Wextra)
add_definitions (-D_GLIBCXX_USE_NANOSLEEP)
add_definitions (-D_GLIBCXX_USE_SCHED_YIELD)
#if (debug)
# add_compile_options(-g)
#else(debug)
# add_compile_options(-O3)
#endif()
include_directories (
include
${Boost_INCLUDE_DIRS}
${CATKIN_DEVEL_PREFIX}/include
build/include
# vendor/gtest-1.7.0/include
)
include_directories(SYSTEM ${catkin_INCLUDE_DIRS})
# check if atomic.h exists
check_include_file_cxx (atomic HAVE_ATOMIC)
check_include_file_cxx (cstdatomic HAVE_CSTDATOMIC)
if (HAVE_ATOMIC)
add_definitions(-DHAVE_ATOMIC)
endif()
if (HAVE_CSTDATOMIC)
add_definitions(-DHAVE_CSTDATOMIC)
endif()
# find libraries
function (lib_not_found library_name)
message (FATAL_ERROR
"Unable to find ${library_name}. "
"Try setting the path to ${library_name} in environment variable CMAKE_LIBRARY_PATH."
)
endfunction(lib_not_found)
find_library (CRYPTO NAMES libcrypto.a crypto)
if (NOT CRYPTO)
lib_not_found("libcrypto.a")
endif()
find_library (JSONCPP NAMES libjsoncpp.a jsoncpp)
if (NOT JSONCPP)
lib_not_found("libjsoncpp.a")
endif()
find_library (TCMALLOC_MINIMAL NAMES libtcmalloc_minimal.a tcmalloc_minimal)
if (NOT TCMALLOC_MINIMAL)
lib_not_found("libtcmalloc_minimal.a")
endif()
find_library (MICROHTTPD NAMES libmicrohttpd.so microhttpd)
if (NOT MICROHTTPD)
lib_not_found("libmicrohttpd.so")
endif()
add_subdirectory (lib)
add_subdirectory (src)
if(CATKIN_ENABLE_TESTING)
# enable_testing()
add_subdirectory (test)
# using version packaged with catkin
# add_subdirectory (vendor/gtest-1.7.0)
# add_test (ledger_test test/ledger_test)
if (RUN_NODE_HASHRING_TESTS)
add_test (hashring_test test/hashring_test)
endif()
endif()