forked from motis-project/motis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
233 lines (210 loc) · 7.17 KB
/
CMakeLists.txt
File metadata and controls
233 lines (210 loc) · 7.17 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
cmake_minimum_required(VERSION 3.20)
project(motis LANGUAGES C CXX ASM)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
option(MOTIS_MIMALLOC "use mimalloc" OFF)
if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if (MOTIS_MIMALLOC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
set(protobuf_MSVC_STATIC_RUNTIME OFF)
else ()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(protobuf_MSVC_STATIC_RUNTIME ON)
endif ()
endif ()
if (MOTIS_MIMALLOC)
set(CISTA_USE_MIMALLOC ON)
set(PPR_MIMALLOC ON)
set(ADR_MIMALLOC ON)
set(OSR_MIMALLOC ON)
set(TILES_MIMALLOC ON)
if(WIN32)
set(MI_BUILD_SHARED ON)
endif()
endif()
include(cmake/buildcache.cmake)
include(cmake/pkg.cmake)
if (MOTIS_MIMALLOC)
if(WIN32)
set(motis-mimalloc-lib mimalloc)
target_link_libraries(cista INTERFACE mimalloc)
else()
set(motis-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(ICC_LINT "Run clang-tidy with the compiler." OFF)
if (ICC_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(motis-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-c++20-extensions
-Wno-switch-default
-Wno-unused-template
-Wno-shadow-uncaptured-local
-Wno-documentation-deprecated-sync
-Wno-float-equal
-Wno-deprecated-declarations
-Wno-reserved-identifier
-Wno-implicit-int-float-conversion
-Werror)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(motis-compile-options -Wall -Wextra -Werror -Wno-unknown-pragmas -Wno-deprecated-declarations)
elseif (MSVC)
set(motis-compile-options /WX /bigobj)
else ()
set(motis-compile-options
-Wall
-Wextra
-Wno-mismatched-new-delete
-Wno-maybe-uninitialized)
if (NOT CMAKE_CROSSCOMPILING)
set(motis-compile-options ${motis-compile-options} -Werror)
endif ()
endif ()
# --- OPENAPI ---
openapi_generate(openapi.yaml motis-api motis::api)
# --- LIB ---
file(GLOB_RECURSE motislib-files src/*.cc)
add_library(motislib ${motislib-files})
target_include_directories(motislib PUBLIC include)
target_compile_features(motislib PUBLIC cxx_std_23)
target_compile_options(motislib PRIVATE ${motis-compile-options})
target_link_libraries(motislib
nigiri
osr
adr
ctx
boost-json
motis-api
reflectcpp
web-server
tiles
pbf_sdf_fonts_res
ssl
crypto
tg
lz4_static
web-server
prometheus-cpp::core
opentelemetry_trace
opentelemetry_exporter_otlp_http
)
# --- EXE ---
execute_process(
COMMAND git describe --always --tags --dirty=-dirty
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE motis-git-tag
OUTPUT_STRIP_TRAILING_WHITESPACE
)
file(GLOB_RECURSE motis-files exe/*.cc)
add_executable(motis ${motis-files})
target_compile_features(motis PUBLIC cxx_std_23)
target_compile_options(motis PRIVATE ${motis-compile-options})
set_source_files_properties(exe/main.cc PROPERTIES COMPILE_DEFINITIONS MOTIS_VERSION="${motis-git-tag}")
target_link_libraries(motis
motislib
ianatzdb-res
pbf_sdf_fonts_res-res
tiles_server_res-res
address_formatting_res-res
)
# --- TEST ---
add_library(motis-generated INTERFACE)
target_include_directories(motis-generated INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/test/test_dir.h.in
${CMAKE_CURRENT_BINARY_DIR}/generated/test_dir.h
)
file(GLOB_RECURSE motis-test-files test/*.cc)
add_executable(motis-test ${motis-test-files})
target_link_libraries(motis-test motislib gtest web-server ianatzdb-res motis-generated)
target_compile_options(motis-test PRIVATE ${motis-compile-options})
# --- TILES ---
set_property(
TARGET motis tiles tiles-import-library
APPEND PROPERTY COMPILE_DEFINITIONS TILES_GLOBAL_PROGRESS_TRACKER=1)
file (CREATE_LINK ${CMAKE_SOURCE_DIR}/deps/tiles/profile ${CMAKE_BINARY_DIR}/tiles-profiles SYMBOLIC)
# --- MIMALLOC ---
if (MOTIS_MIMALLOC)
target_link_libraries(motis ${motis-mimalloc-lib})
target_compile_definitions(motis PUBLIC USE_MIMALLOC=1)
if(WIN32)
add_custom_command(
TARGET motis POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
$<TARGET_FILE:mimalloc>
$<TARGET_FILE_DIR:motis>
COMMENT "Copy mimalloc.dll to output directory"
)
add_custom_command(
TARGET motis POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"${CMAKE_SOURCE_DIR}/deps/mimalloc/bin/mimalloc-redirect.dll"
$<TARGET_FILE_DIR:motis>
COMMENT "Copy mimalloc-redirect.dll to output directory"
)
add_custom_command(
TARGET motis POST_BUILD
COMMAND "${CMAKE_SOURCE_DIR}/deps/mimalloc/bin/minject.exe"
--force --inplace
$<$<CONFIG:Debug>:--postfix=debug>
$<TARGET_FILE:motis>
COMMENT "Ensure mimalloc.dll is loaded first"
)
add_custom_command(
TARGET motis-test POST_BUILD
COMMAND "${CMAKE_SOURCE_DIR}/deps/mimalloc/bin/minject.exe"
--force --inplace
$<$<CONFIG:Debug>:--postfix=debug>
$<TARGET_FILE:motis-test>
COMMENT "Ensure mimalloc.dll is loaded first"
)
endif()
if (MSVC)
target_link_options(motis PUBLIC "/include:mi_version")
endif ()
endif()
# --- UI ---
add_custom_target(motis-web-ui
COMMAND pnpm install && pnpm build
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ui"
VERBATIM
)
file (CREATE_LINK ${CMAKE_SOURCE_DIR}/ui/build ${CMAKE_BINARY_DIR}/ui SYMBOLIC)
foreach(t adr osr nigiri gtfsrt
geo tiles tiles-import-library
motis motis-api motislib)
target_compile_options(${t} PUBLIC ${MOTIS_TARGET_FLAGS})
endforeach()
if (MOTIS_MIMALLOC)
target_compile_options(mimalloc PUBLIC ${MOTIS_TARGET_FLAGS})
endif()