-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
155 lines (142 loc) · 6.4 KB
/
Copy pathCMakeLists.txt
File metadata and controls
155 lines (142 loc) · 6.4 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
cmake_minimum_required(VERSION 3.20)
project(OpenADS
VERSION 1.0.0
LANGUAGES C CXX
DESCRIPTION "Open-source ADS-compatible engine"
)
# Resolve the public version string the binary reports through
# `--version`. Prefer `git describe --tags` so a build straight off
# tag v1.0.0-rc13 reports "1.0.0-rc13", a build off main (between
# tags) reports "1.0.0-rc13-7-g<sha>[-dirty]", and a tarball without
# a .git tree falls back to ${PROJECT_VERSION} from project() above.
# The previous hard-coded "1.0.0-rc1" string drifted six releases
# behind reality and surprised users running rc12.
set(OPENADS_VERSION_STR "${PROJECT_VERSION}")
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE _git_describe
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
RESULT_VARIABLE _git_rc)
if(_git_rc EQUAL 0 AND NOT _git_describe STREQUAL "")
# Strip a leading "v" so tags v1.0.0-rc13 surface as 1.0.0-rc13.
string(REGEX REPLACE "^v" "" OPENADS_VERSION_STR "${_git_describe}")
endif()
endif()
message(STATUS "OpenADS version: ${OPENADS_VERSION_STR}")
add_compile_definitions(OPENADS_VERSION_STR="${OPENADS_VERSION_STR}")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# openads_core is a STATIC library that gets linked into both an
# executable (openads_serverd, tests) and a SHARED library
# (openads_ace -> ace64.dll / libace64.so). On Linux / macOS the
# shared-library link path requires every translation unit pulled
# in to be position-independent, otherwise we hit
# `R_X86_64_TPOFF32 ... can not be used when making a shared
# object; recompile with -fPIC`. Force PIC globally — Windows
# silently ignores the flag, so this is a no-op there.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
endif()
option(OPENADS_BUILD_TESTS "Build OpenADS unit tests" ON)
option(OPENADS_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
# M12.12 — real TLS transport via vendored mbedtls (Apache-2.0).
# Off by default so existing builds don't pull a network dependency
# at configure time. When ON, FetchContent downloads mbedtls 3.6 LTS
# at configure time and links it into openads_core; AdsConnect60
# with a `tls://` URI then opens a TlsTransport instead of returning
# AE_FUNCTION_NOT_AVAILABLE.
option(OPENADS_WITH_TLS "Enable TLS transport (vendors mbedtls 3.6 LTS via FetchContent)" OFF)
# studio.web — embedded HTTP web console inside openads_serverd.
# When ON, serverd gains a `--http-port N` flag that exposes a
# single-page admin UI + REST API on top of the running engine,
# so the database can be administered from any browser on the LAN
# without installing a desktop client. Vendors cpp-httplib (MIT)
# and nlohmann/json (MIT) at configure time via FetchContent.
option(OPENADS_WITH_HTTP "Enable embedded HTTP web console (Studio) in openads_serverd / ace64.dll" ON)
# Pull in mbedtls FIRST so our strict /WX -Werror flags don't bleed
# into the upstream sources (C4200 zero-sized arrays etc). Each
# OpenADS target adds the strict flags target-locally below via
# `apply_openads_warnings(<target>)`.
if(OPENADS_WITH_TLS)
include(FetchContent)
set(ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(ENABLE_PROGRAMS OFF CACHE BOOL "" FORCE)
set(MBEDTLS_FATAL_WARNINGS OFF CACHE BOOL "" FORCE)
# Force a STATIC mbedtls so the OpenADS DLL / server binary
# has no runtime dependency on a system OpenSSL. Reported by
# downstream users: a release ZIP without those system DLLs
# fails to launch on a clean Windows / macOS box. Static
# linking sidesteps that whole class of "missing libssl/
# libcrypto" deployment errors.
set(USE_STATIC_MBEDTLS_LIBRARY ON CACHE BOOL "" FORCE)
set(USE_SHARED_MBEDTLS_LIBRARY OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
mbedtls
GIT_REPOSITORY https://github.com/Mbed-TLS/mbedtls.git
GIT_TAG v3.6.2
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(mbedtls)
message(STATUS "OpenADS: TLS enabled via vendored mbedtls 3.6.2 (statically linked)")
endif()
if(OPENADS_WITH_HTTP)
include(FetchContent)
# cpp-httplib auto-detects OpenSSL / zlib / brotli on the host
# and pulls them in as link libraries on its INTERFACE target.
# That collides with the OpenADS no-runtime-DLL deployment
# promise (the shipped DLL must not depend on libssl /
# libcrypto). Force-disable the auto-link so Linux/macOS
# builds match the Windows side: plain HTTP only, no system
# OpenSSL pulled into ace64.dll / libace64.so.
set(HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
set(HTTPLIB_USE_ZLIB_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
set(HTTPLIB_USE_BROTLI_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
set(HTTPLIB_REQUIRE_OPENSSL OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
cpp_httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
GIT_TAG v0.18.5
GIT_SHALLOW TRUE
)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
GIT_SHALLOW TRUE
)
set(JSON_BuildTests OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(cpp_httplib nlohmann_json)
message(STATUS "OpenADS: HTTP web console enabled (cpp-httplib + nlohmann/json)")
endif()
if(MSVC)
add_compile_options(/W4 /permissive-)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
if(OPENADS_WARNINGS_AS_ERRORS)
add_compile_options(/WX)
endif()
else()
add_compile_options(-Wall -Wextra -Wpedantic -Wshadow -Wconversion)
# _CRT_SECURE_NO_WARNINGS: needed when clang-cl targets MSVC CRT on Windows;
# harmless on Linux/macOS where this define has no effect.
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
if(OPENADS_WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif()
endif()
add_subdirectory(src)
add_subdirectory(tools/serverd)
add_subdirectory(tools/bench)
add_subdirectory(tools/stress)
add_subdirectory(tools/mgprobe)
add_subdirectory(tools/import_dd)
if(OPENADS_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()