-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
149 lines (122 loc) · 4.29 KB
/
Copy pathCMakeLists.txt
File metadata and controls
149 lines (122 loc) · 4.29 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
cmake_minimum_required(VERSION 3.20)
cmake_policy(VERSION 3.20)
cmake_policy(SET CMP0117 NEW)
project(mapget LANGUAGES CXX C)
# Allow version to be set from command line for CI/CD
# For local development, use the default version
if(NOT DEFINED MAPGET_VERSION)
set(MAPGET_VERSION 2026.4.1)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (WIN32)
add_compile_definitions(NOMINMAX)
endif()
include(FetchContent)
include(GNUInstallDirs)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(MAPGET_WITH_WHEEL ON CACHE BOOL "Enable mapget Python wheel (output to WHEEL_DEPLOY_DIRECTORY).")
set(MAPGET_WITH_SERVICE ON CACHE BOOL "Enable mapget-service library. Requires threads.")
set(MAPGET_WITH_HTTPLIB ON CACHE BOOL "Enable mapget-http-datasource and mapget-http-service libraries.")
set(MAPGET_ENABLE_TESTING ON CACHE BOOL "Enable testing.")
set(MAPGET_BUILD_EXAMPLES ON CACHE BOOL "Build examples.")
# Prevent CPM dependencies (e.g. Drogon/Trantor) from registering their own
# tests into this project's ctest run.
set(BUILD_TESTING OFF CACHE BOOL "Disable dependency tests" FORCE)
endif()
option(MAPGET_WITH_WHEEL "Enable mapget Python wheel (output to WHEEL_DEPLOY_DIRECTORY).")
option(MAPGET_WITH_SERVICE "Enable mapget-service library. Requires threads.")
option(MAPGET_WITH_HTTPLIB "Enable mapget-http-datasource and mapget-http-service libraries.")
if (MAPGET_ENABLE_TESTING)
# Enable testing before adding CPM dependencies so stale/third-party CTest
# files don't linger in the build tree.
enable_testing()
endif()
set(Python3_FIND_STRATEGY LOCATION)
if (NOT MSVC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_FLAGS -fPIC)
endif()
if (NOT MAPGET_DEPLOY_DIR)
set (MAPGET_DEPLOY_DIR "${CMAKE_BINARY_DIR}/bin")
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${MAPGET_DEPLOY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${MAPGET_DEPLOY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${MAPGET_DEPLOY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${MAPGET_DEPLOY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${MAPGET_DEPLOY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${MAPGET_DEPLOY_DIR}")
set(MAPGET_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/mapget/")
option(WITH_COVERAGE "Enable gcovr coverage" NO)
if (NOT CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(WITH_COVERAGE NO)
endif()
find_program(GCOVR_BIN gcovr)
if (WITH_COVERAGE AND NOT GCOVR_BIN)
set(WITH_COVERAGE NO)
message(WARNING "Could not find gcovr binary. Disabling coverage report!")
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if (MAPGET_WITH_SERVICE OR MAPGET_WITH_HTTPLIB OR MAPGET_ENABLE_TESTING)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
endif()
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules")
if (WITH_COVERAGE)
include(CodeCoverage)
endif()
##############
# deps
set(CPM_DOWNLOAD_ALL ON)
set(CPM_USE_LOCAL_PACKAGES OFF)
# Include CPM.cmake
if (NOT CPM_INITIALIZED)
add_subdirectory(cmake/CPM.cmake)
endif ()
include(cmake/deps.cmake)
if (MAPGET_WITH_WHEEL)
if (NOT TARGET wheel)
list(APPEND CMAKE_MODULE_PATH "${python-cmake-wheel_SOURCE_DIR}")
include(python-wheel)
set(WHEEL_DEPLOY_DIRECTORY "${MAPGET_DEPLOY_DIR}/wheel")
endif()
endif()
##############
# libs
add_subdirectory(libs/logging)
add_subdirectory(libs/model)
if (MAPGET_WITH_SERVICE OR MAPGET_WITH_HTTPLIB OR MAPGET_ENABLE_TESTING)
add_subdirectory(libs/service)
add_subdirectory(libs/geojsonsource)
add_subdirectory(libs/gridsource)
add_subdirectory(libs/location)
endif()
if (MAPGET_WITH_HTTPLIB OR MAPGET_ENABLE_TESTING)
add_subdirectory(libs/http-datasource)
add_subdirectory(libs/http-service)
add_subdirectory(apps/mapget)
endif()
if (MAPGET_WITH_WHEEL)
add_subdirectory(libs/pymapget)
endif()
##############
# tests
if (MAPGET_ENABLE_TESTING)
add_subdirectory(test/unit)
if (MAPGET_WITH_WHEEL)
add_subdirectory(test/integration)
endif()
if (WITH_COVERAGE)
setup_target_for_coverage_gcovr_html(
NAME coverage
EXECUTABLE test.mapget
BASE_DIRECTORY "${CMAKE_SOURCE_DIR}/src"
EXCLUDE "*catch2*")
endif()
endif()
##############
# examples
if (MAPGET_BUILD_EXAMPLES OR MAPGET_ENABLE_TESTING)
add_subdirectory(examples)
endif()