-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
199 lines (175 loc) · 6.08 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.21)
macro(unset_pc LIBNAME)
# clean broken PC_SPATIALITE variables causing
# clang: error: no such file or directory: 'Security'
# clang: error: no such file or directory: 'CoreFoundation'
unset(PC_${LIBNAME}_LDFLAGS_OTHER CACHE)
unset(PC_${LIBNAME}_STATIC_LDFLAGS CACHE)
unset(PC_${LIBNAME}_STATIC_LDFLAGS_OTHER CACHE)
unset(PC_${LIBNAME}_LDFLAGS CACHE)
unset(PC_${LIBNAME}_LIBRARY_DIRS CACHE)
unset(${LIBNAME}_LIBRARY CACHE)
endmacro()
unset_pc(SPATIALITE)
unset_pc(FREEXL)
#######################################
project(MerginMapsMobileSdk LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
find_package(Qt6
COMPONENTS
Qml
Xml
Concurrent
Positioning
Sensors
Network
Svg
Sql
Core
Gui
Core5Compat
Multimedia
Widgets
REQUIRED
)
find_package(Geodiff CONFIG REQUIRED)
find_package(unofficial-minizip CONFIG REQUIRED)
find_package(PROJ CONFIG REQUIRED)
find_package(GEOS CONFIG REQUIRED)
find_package(GDAL CONFIG REQUIRED)
find_package(ZXing CONFIG REQUIRED)
find_package(libzip REQUIRED)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_package(Protobuf REQUIRED)
find_package(Qca CONFIG REQUIRED)
find_package(Qt6Keychain CONFIG REQUIRED)
find_package(PostgreSQL REQUIRED)
find_package(exiv2 CONFIG REQUIRED)
find_package(expat CONFIG REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(Iconv)
find_package(WebP CONFIG REQUIRED)
unset_pc(SPATIALITE)
unset_pc(FREEXL)
find_library(SPATIALINDEX_LIBRARY spatialindex_i spatialindex spatialindex-64 PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib NO_DEFAULT_PATH REQUIRED)
find_library(SPATIALITE_LIBRARY spatialite PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib NO_DEFAULT_PATH REQUIRED)
find_library(ZLIB_LIBRARY z PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib NO_DEFAULT_PATH REQUIRED)
find_library(FREEXL_LIBRARY freexl PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib NO_DEFAULT_PATH REQUIRED)
if(APPLE)
find_library(LIBTASN1_LIBRARY tasn1 PATHS ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib NO_DEFAULT_PATH REQUIRED)
endif()
#######################################
add_executable(merginmapsmobilesdk main.cpp)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set_target_properties(
merginmapsmobilesdk
PROPERTIES MACOSX_BUNDLE TRUE
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" # disable signing
MACOSX_BUNDLE_GUI_IDENTIFIER MerginMaps.SDK
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE
)
endif ()
#######################################
#
# Linking order matters!
#
# 1/ QGIS
# at least on Linux qgis_core needs to be linked before Qt lib
find_path(QGIS_INCLUDE_DIR
NAMES qgis.h
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include"
PATH_SUFFIXES qgis
NO_DEFAULT_PATH
)
find_library(
QGIS_LIBRARY
NAMES qgis_core
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib"
PATH_SUFFIXES qgis
NO_DEFAULT_PATH
)
target_include_directories(merginmapsmobilesdk PRIVATE ${QGIS_INCLUDE_DIR})
target_link_libraries(merginmapsmobilesdk PRIVATE ${QGIS_LIBRARY})
# 2/ Qt
target_link_libraries(merginmapsmobilesdk PRIVATE
Qt6::Qml
Qt6::Xml
Qt6::Concurrent
Qt6::Positioning
Qt6::Sensors
Qt6::Network
Qt6::Svg
Qt6::Sql
Qt6::Core
Qt6::Gui
Qt6::Core5Compat
Qt6::Multimedia
Qt6::Widgets
)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS")
find_package(Qt6 COMPONENTS PrintSupport)
target_link_libraries(merginmapsmobilesdk PRIVATE
Qt6::PrintSupport
)
endif()
# 3/ next libs
target_link_libraries(merginmapsmobilesdk PRIVATE Geodiff::Geodiff)
target_link_libraries(merginmapsmobilesdk PRIVATE PROJ::proj)
target_link_libraries(merginmapsmobilesdk PRIVATE ZXing::Core ZXing::ZXing)
# 4/ QGIS providers
set(QGIS_PROVIDERS_LIST
authmethod_basic
authmethod_esritoken
authmethod_identcert
authmethod_oauth2
authmethod_pkcs12
authmethod_pkipaths
provider_arcgisfeatureserver
provider_arcgismapserver
provider_delimitedtext
provider_spatialite
provider_virtuallayer
provider_wcs
provider_wfs
provider_wms
provider_postgres
)
foreach (provider ${QGIS_PROVIDERS_LIST})
find_library(
QGIS_${provider}_LIBRARY
NAMES ${provider}_a
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib"
PATH_SUFFIXES qgis
NO_DEFAULT_PATH
)
target_link_libraries(merginmapsmobilesdk PRIVATE ${QGIS_${provider}_LIBRARY}
)
endforeach ()
# fix cycling dependencies between qgis_core and providers
target_link_libraries(merginmapsmobilesdk PRIVATE ${QGIS_LIBRARY})
# 5/ GDAL
target_link_libraries(merginmapsmobilesdk PRIVATE GDAL::GDAL)
# 6/ rest
target_link_libraries(merginmapsmobilesdk PRIVATE PostgreSQL::PostgreSQL)
target_link_libraries(merginmapsmobilesdk PRIVATE Qt6Keychain::Qt6Keychain)
target_link_libraries(merginmapsmobilesdk PRIVATE qca)
if(APPLE)
target_link_libraries(merginmapsmobilesdk PRIVATE ${LIBTASN1_LIBRARY})
endif()
target_link_libraries(merginmapsmobilesdk PRIVATE libzip::zip)
target_link_libraries(merginmapsmobilesdk PRIVATE protobuf::libprotobuf-lite)
target_link_libraries(merginmapsmobilesdk PRIVATE exiv2lib exiv2-xmp)
target_link_libraries(merginmapsmobilesdk PRIVATE CURL::libcurl)
target_link_libraries(merginmapsmobilesdk PRIVATE expat::expat)
target_link_libraries(merginmapsmobilesdk PRIVATE WebP::webp WebP::webpdemux WebP::libwebpmux WebP::webpdecoder)
target_link_libraries(merginmapsmobilesdk PRIVATE ${FREEXL_LIBRARY})
target_link_libraries(merginmapsmobilesdk PRIVATE unofficial::minizip::minizip)
target_link_libraries(merginmapsmobilesdk PRIVATE ${ZLIB_LIBRARY})
target_link_libraries(merginmapsmobilesdk PRIVATE ${SPATIALINDEX_LIBRARY})
target_link_libraries(merginmapsmobilesdk PRIVATE ${SPATIALITE_LIBRARY})
target_link_libraries(merginmapsmobilesdk PRIVATE GEOS::geos_c)
target_link_libraries(merginmapsmobilesdk PRIVATE Iconv::Iconv)
target_link_libraries(merginmapsmobilesdk PRIVATE unofficial::sqlite3::sqlite3)