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 -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, see https://github.com/llvm/llvm-project/issues/121709) -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/database.cpp src/config.cppm src/config.cpp src/datex2.cppm src/datex2.cpp src/gpx.cppm src/gpx.cpp src/http_client.cppm src/http_client.cpp src/http_common.cppm src/http_common.cpp src/http_server.cppm src/http_server.cpp src/locale.cppm src/locale.cpp src/log.cppm src/log.cpp src/problem.cppm src/problem.cpp src/routemon.cppm src/rwgps.cppm src/rwgps.cpp src/sqlite3.cppm src/sqlite3.cpp src/srv.cppm src/srv.cpp src/time.cppm src/time.cpp src/trace.cppm src/trace.cpp src/util.cppm src/util.cpp src/xml.cppm src/xml.cpp src/geo/geo.cppm src/geo/multizonal.cppm src/geo/utm.cppm src/geo/utm_zone_local.cppm src/geo/wgs84.cppm ) 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)