forked from mapsme/geocore
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
173 lines (134 loc) · 4.19 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
cmake_minimum_required(VERSION 3.2)
project(geocore C CXX)
set(CMAKE_CXX_STANDARD 14)
get_filename_component(GEOCORE_ROOT . ABSOLUTE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GEOCORE_ROOT}/cmake")
include(GeoCoreHelpers)
if (NOT SKIP_TESTS)
set(SKIP_TESTS FALSE)
ENABLE_TESTING()
configure_gtest()
endif()
# TCMalloc Linking
add_library(tcmalloc_config INTERFACE)
option(USE_TCMALLOC "Link TCMalloc memory allocator" ON)
if (USE_TCMALLOC)
find_package(tcmalloc)
target_link_libraries(tcmalloc_config INTERFACE tcmalloc)
endif()
# Code Coverage Configuration
add_library(coverage_config INTERFACE)
option(CODE_COVERAGE "Enable coverage reporting" OFF)
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Add required flags (GCC & LLVM/Clang)
target_compile_options(coverage_config INTERFACE
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(coverage_config INTERFACE --coverage)
else()
target_link_libraries(coverage_config INTERFACE --coverage)
endif()
endif()
# Set build type:
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_definitions(-DDEBUG)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
add_definitions(-DRELEASE)
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
add_definitions(-DRELEASE)
add_compile_options(
"-fno-omit-frame-pointer"
)
else()
message(FATAL_ERROR "Unknown build type: " ${CMAKE_BUILD_TYPE})
endif()
message("Build type: " ${CMAKE_BUILD_TYPE})
# End of setting build type
option(USE_ASAN "Enable Address Sanitizer" OFF)
option(USE_TSAN "Enable Thread Sanitizer" OFF)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
message(FATAL_ERROR "Minimum supported g++ version is 7.0 yours is ${CMAKE_CXX_COMPILER_VERSION}")
endif()
if (PLATFORM_LINUX)
option(USE_PPROF "Enable Google Profiler" OFF)
endif()
if (USE_ASAN)
message("Address Sanitizer is enabled")
endif()
if (USE_TSAN)
message("Thread Sanitizer is enabled")
endif()
if (USE_ASAN AND USE_TSAN)
message(FATAL_ERROR "Can't use two different sanitizers together")
endif()
if (USE_PPROF)
message("Google Profiler is enabled")
add_definitions(-DUSE_PPROF)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Set environment variables
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
# End of setting environment variables
# Find installed packages
find_package(Threads)
# TODO: Uncomment these lines when XCode project is finally generated by CMake.
#init_boost()
#install_boost_headers()
find_package(Boost ${BOOST_VERSION} EXACT COMPONENTS system filesystem serialization iostreams program_options REQUIRED)
set(Boost_USE_MULTITHREADED ON)
include_directories(${CMAKE_HOME_DIRECTORY})
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (USE_ASAN)
add_compile_options(
"-fsanitize=address"
"-fno-omit-frame-pointer"
)
endif()
if (USE_TSAN)
add_compile_options(
"-fsanitize=thread"
"-fno-omit-frame-pointer"
)
endif()
# Include subdirectories
add_subdirectory(3party/expat)
add_subdirectory(3party/icu)
add_subdirectory(3party/jansson)
add_subdirectory(3party/protobuf)
add_subdirectory(3party/succinct)
# Only options related to warnings should be placed here.
# Other options should be set before all add_subdirectory calls.
add_compile_options(
"-Wall"
"-Wextra"
"-Werror"
)
add_clang_compile_options("-Wshorten-64-to-32")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
add_gcc_cpp_compile_options("-Wno-noexcept-type")
endif()
add_subdirectory(base)
add_subdirectory(coding)
add_subdirectory(geometry)
add_subdirectory(indexer)
add_subdirectory(platform)
add_subdirectory(generator)
add_subdirectory(geocoder)
add_custom_target(BuildVersion ALL
COMMAND ${CMAKE_COMMAND}
ARGS
-D MAPSME_CURRENT_PROJECT_ROOT=${GEOCORE_ROOT}
-D PATH_WITH_BUILD_VERSION_HPP=${GEOCORE_ROOT}
-D PROJECT_NAME=${PROJECT_NAME}
-P ${GEOCORE_ROOT}/cmake/BuildVersion.cmake
)