-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
170 lines (153 loc) · 5.44 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
cmake_minimum_required(VERSION 3.10)
project(osr)
cmake_policy(SET CMP0079 NEW)
if (MSVC)
# PDB debug information is not supported by buildcache.
# Store debug info in the object files.
option(OSR_DEBUG_SYMBOLS "generate debug symbols (debug builds)" ON)
if (OSR_DEBUG_SYMBOLS)
set(OSR_MSVC_DEBUG_FLAGS "/Z7")
else ()
set(OSR_MSVC_DEBUG_FLAGS "")
endif ()
string(REPLACE "/Zi" "${OSR_MSVC_DEBUG_FLAGS}" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "/Zi" "${OSR_MSVC_DEBUG_FLAGS}" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/Zi" "${OSR_MSVC_DEBUG_FLAGS}" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "${OSR_MSVC_DEBUG_FLAGS}" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") # ignore deprecated fileno in tiles
endif ()
option(OSR_MIMALLOC "use mimalloc" OFF)
if (OSR_MIMALLOC)
set(CISTA_USE_MIMALLOC ON)
set(TILES_MIMALLOC ON)
endif()
if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if (OSR_MIMALLOC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
else ()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif ()
endif ()
if (OSR_MIMALLOC AND WIN32)
set(MI_BUILD_SHARED ON)
endif ()
include(cmake/buildcache.cmake)
include(cmake/pkg.cmake)
if (OSR_MIMALLOC)
if (WIN32)
set(osr-mimalloc-lib mimalloc)
target_link_libraries(cista INTERFACE mimalloc)
else ()
set(osr-mimalloc-lib mimalloc-obj)
target_link_libraries(cista INTERFACE mimalloc-static)
endif ()
target_compile_definitions(cista INTERFACE CISTA_USE_MIMALLOC=1)
target_compile_definitions(boost INTERFACE BOOST_ASIO_DISABLE_STD_ALIGNED_ALLOC=1)
endif ()
# --- LINT ---
option(OSR_LINT "Run clang-tidy with the compiler." OFF)
if (OSR_LINT)
# clang-tidy will be run on all targets defined hereafter
include(cmake/clang-tidy.cmake)
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(osr-compile-options
-Weverything
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-newline-eof
-Wno-missing-prototypes
-Wno-padded
-Wno-double-promotion
-Wno-undef
-Wno-undefined-reinterpret-cast
-Wno-float-conversion
-Wno-global-constructors
-Wno-exit-time-destructors
-Wno-switch-enum
-Wno-c99-designator
-Wno-zero-as-null-pointer-constant
-Wno-missing-noreturn
-Wno-undefined-func-template
-Wno-unsafe-buffer-usage
-Wno-c++20-compat
-Wno-reserved-macro-identifier
-Wno-documentation-unknown-command
-Wno-duplicate-enum
-Wno-ctad-maybe-unsupported
-Wno-unknown-pragmas
-Wno-switch-default
-Werror)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(osr-compile-options -Wall -Wextra -Werror -Wno-unknown-pragmas)
elseif (MSVC)
set(osr-compile-options /WX)
else ()
set(osr-compile-options
-Wall
-Wextra
-Wno-changes-meaning
-Wno-maybe-uninitialized)
if (NOT CMAKE_CROSSCOMPILING)
set(osr-compile-options ${osr-compile-options} -Werror)
endif ()
endif ()
# --- LIB ---
file(GLOB_RECURSE osr-src src/*.cc)
add_library(osr ${osr-src})
target_include_directories(osr PUBLIC include)
target_compile_features(osr PUBLIC cxx_std_23)
target_compile_options(osr PRIVATE ${osr-compile-options})
target_link_libraries(osr
osmium
zlibstatic
protozero
expat
geo
cista
utl
tiles-import-library
rtree
unordered_dense
boost-thread
)
# --- MAIN ---
add_executable(osr-extract exe/extract.cc)
target_link_libraries(osr-extract osr)
add_executable(osr-benchmark exe/benchmark.cc)
target_link_libraries(osr-benchmark osr)
file(GLOB_RECURSE osr-backend-src exe/backend/*.cc)
add_executable(osr-backend ${osr-backend-src})
target_link_libraries(osr-backend osr web-server conf boost-json TBB::tbb)
target_include_directories(osr-backend PRIVATE exe/backend/include)
# --- TEST ---
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/test/test_dir.h.in
${CMAKE_CURRENT_BINARY_DIR}/generated/test_dir.h
)
file(GLOB_RECURSE osr-test-files test/*cc)
add_executable(osr-test ${osr-test-files})
target_include_directories(osr-test PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated)
target_link_libraries(osr-test gtest osr boost-json)
# --- MIMALLOC ---
if (OSR_MIMALLOC)
target_link_libraries(osr-extract ${osr-mimalloc-lib})
target_link_libraries(osr-backend ${osr-mimalloc-lib})
if (WIN32)
add_custom_command(
TARGET osr-extract POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
$<TARGET_FILE:mimalloc>
$<TARGET_FILE_DIR:osr>
COMMENT "Copy mimalloc.dll to output directory"
)
add_custom_command(
TARGET osr-extract POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"${CMAKE_BINARY_DIR}/deps/mimalloc/mimalloc-redirect.dll"
$<TARGET_FILE_DIR:osr>
COMMENT "Copy mimalloc-redirect.dll to output directory"
)
endif ()
endif ()