summaryrefslogtreecommitdiffstats
path: root/server/CMakeLists.txt
blob: df4eb90fc1a669bf7eb2b89bf94522a2598b77e5 (about) (plain) (blame)
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
cmake_minimum_required(VERSION 4.3)

project(routemon LANGUAGES CXX)

# Hardening options from https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
add_compile_options(
  # -O2
  # -g
  -fno-omit-frame-pointer
  -Wall -Wextra -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough
  -Werror=format-security
  -U_FORTIFY_SOURCE # -D_FORTIFY_SOURCE=3 (unfortunately breaks the std module)
  -D_GLIBCXX_ASSERTIONS
  -fstrict-flex-arrays=3
  -fstack-clash-protection -fstack-protector-strong
  -fPIE -fcf-protection=full
  -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero
  -DBOOST_ASIO_NO_DEPRECATED
)
add_link_options(
  -pie
  -Wl,-z,nodlopen -Wl,-z,noexecstack
  -Wl,-z,relro -Wl,-z,now
  -Wl,--as-needed -Wl,--no-copy-dt-needed-entries
)

add_library(routemon_lib)
target_sources(routemon_lib
  PUBLIC FILE_SET CXX_MODULES FILES
    src/api.cppm
    src/api.cpp
    src/database.cppm
    src/config.cppm
    src/config.cpp
    src/datex2.cppm
    src/geo.cppm
    src/gpx.cppm
    src/gpx.cpp
    src/http_client.cppm
    src/http_common.cppm
    src/http_server.cppm
    src/locale.cppm
    src/log.cppm
    src/problem.cppm
    src/req_ctx.cppm
    src/routemon.cppm
    src/rwgps.cppm
    src/sqlite3.cppm
    src/srv.cppm
    src/time.cppm
    src/trace.cppm
    src/util.cppm
    src/xml.cppm
    src/xml.cpp
)

add_executable(routemon src/main.cpp)
target_link_libraries(routemon routemon_lib)
install(TARGETS routemon)

find_package(Boost 1.90 REQUIRED COMPONENTS json locale url)
target_link_libraries(routemon_lib Boost::headers Boost::json Boost::locale Boost::url)

# Already arranged via Boost::locale but this makes it more explicit, I guess
find_package(ICU REQUIRED COMPONENTS data i18n uc)
target_link_libraries(routemon_lib ICU::data ICU::i18n ICU::uc)

find_library(pugixml pugixml REQUIRED)
target_link_libraries(routemon_lib pugixml)

find_package(OpenSSL REQUIRED)
target_link_libraries(routemon_lib OpenSSL::SSL)

find_package(SQLite3 REQUIRED)
target_link_libraries(routemon_lib SQLite3::SQLite3)

find_package(Gettext REQUIRED)
gettext_create_translations(
  routemon.pot
  ALL
  locale/nl.po
  locale/en_US.po
)

find_package(expat REQUIRED)
target_link_libraries(routemon_lib expat::expat)