forked from janbar/osmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
253 lines (222 loc) · 8.79 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
cmake_minimum_required(VERSION 3.8.2)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
project(osmin C CXX)
option(INSTALL_TESTS "Install the tests on make install" OFF)
option(BUILD_DEVICE_MOBILE "Enable behaviors for mobile devices" OFF)
set(APP_VERSION "1.9.6")
set(APP_VERSION_CODE 53)
set(APP_ID "io.github.janbar.osmin")
set(APP_NAME "osmin")
set(EXEC "osmin")
set(ICON_NAME "${EXEC}")
set(APP_DESKTOP_ID "${EXEC}")
set(DESKTOP_FILE_NAME "osmin.desktop")
set(APPDATA_FILE_NAME "osmin.appdata.xml")
# Components PATH
execute_process(
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
OUTPUT_VARIABLE ARCH_TRIPLET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Set install paths
include(GNUInstallDirs)
set(APPDATA_DIR ${CMAKE_INSTALL_DATADIR}/metainfo)
set(DESKTOP_DIR ${CMAKE_INSTALL_DATADIR}/applications)
set(PLUGINS_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${EXEC})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${APP_DESKTOP_ID}.desktop "[Desktop Entry]
Name=${APP_NAME}
Exec=${EXEC}
Icon=${ICON_NAME}
Terminal=false
Type=Application
Categories=Maps;")
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${APP_DESKTOP_ID}.desktop
DESTINATION ${DESKTOP_DIR}
)
install(FILES "gui/icons/${ICON_NAME}-8x8.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/8x8/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-16x16.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/16x16/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-22x22.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/22x22/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-24x24.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/24x24/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-32x32.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/32x32/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-36x36.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/36x36/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-42x42.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/42x42/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-48x48.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-64x64.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/64x64/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-72x72.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/72x72/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-80x80.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/80x80/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-96x96.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/96x96/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-128x128.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-192x192.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/192x192/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-256x256.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/256x256/apps RENAME "${ICON_NAME}.png")
install(FILES "gui/icons/${ICON_NAME}-512x512.png"
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/512x512/apps RENAME "${ICON_NAME}.png")
configure_file(
${APPDATA_FILE_NAME}.in
${CMAKE_CURRENT_BINARY_DIR}/${APPDATA_FILE_NAME}
)
if(NOT APPLE)
# Provides OpenMP
find_package(OpenMP REQUIRED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
# force build all backend dependencies on apple
set(BUILD_DEPENDENCIES ON CACHE BOOL "Build dependencies" FORCE)
# ignore macports
set(CMAKE_IGNORE_PATH "/opt/local/bin;/opt/local/include;/opt/local/lib")
endif()
# Workaround for QTBUG-87863 before calling add_subirectory
find_package(Qt5 COMPONENTS Core REQUIRED)
add_subdirectory(backend)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5Quick REQUIRED)
set(QT_MIN_VERSION 5.12.0)
find_package(Qt5QuickControls2 ${QT_MIN_VERSION} REQUIRED)
if(ANDROID)
find_package(Qt5AndroidExtras REQUIRED)
endif()
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Sensors REQUIRED)
find_package(Qt5Multimedia REQUIRED)
find_package(Qt5RemoteObjects REQUIRED)
find_package(Qt5Positioning REQUIRED)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(osmin_SOURCES src/osmin.cpp src/converter.cpp src/platformextras.cpp
src/utils.cpp
src/csvparser.cpp
src/qmlfilterbehavior.cpp
src/qmlsortbehavior.cpp
src/qmlsortfiltermodel.cpp
src/favoritesmodel.cpp
src/gpxlistmodel.cpp
src/gpxfilemodel.cpp
src/tracker.cpp
src/compass/genericcompass.cpp
src/compass/plugin.cpp
src/service.cpp
src/servicefrontend.cpp
src/remoteservice.cpp
src/remotecompass.cpp
src/remotepositionsource.cpp
src/remotetracker.cpp
src/mapextras.cpp
)
set(osmin_HEADERS src/converter.h src/platformextras.h
src/locked.h
src/utils.h
src/csvparser.h
src/qmlfilterbehavior.h
src/qmlsortbehavior.h
src/qmlsortfiltermodel.h
src/favoritesmodel.h
src/gpxlistmodel.h
src/gpxlistmodel.h
src/tracker.h
src/compass/genericcompass.h
src/compass/plugin.h
src/service.h
src/servicefrontend.h
src/remote.h
src/remoteservice.h
src/remotecompass.h
src/remotepositionsource.h
src/remotetracker.h
src/mapextras.h
)
if(UNIX)
list(APPEND osmin_SOURCES src/signalhandler.cpp)
list(APPEND osmin_HEADERS src/signalhandler.h)
endif()
add_definitions(-DAPP_VERSION="${APP_VERSION}")
if(Qt5Core_VERSION VERSION_LESS 5.15.0)
qt5_add_resources(osmin-resources gui/osmin_controls2_509.qrc)
else()
qt5_add_resources(osmin-resources gui/osmin_controls2_515.qrc)
endif()
qt5_generate_repc(osmin_SOURCES src/servicemessenger.rep SOURCE)
qt5_generate_repc(osmin_SOURCES src/servicemessenger.rep REPLICA)
include_directories(${PROJECT_BINARY_DIR} ${LIBOSMSCOUT_INCLUDE_DIRS})
if(ANDROID)
add_library(osmin SHARED ${osmin_SOURCES} ${osmin_HEADERS} ${osmin-resources})
else()
add_executable(osmin ${osmin_SOURCES} ${osmin_HEADERS} ${osmin-resources})
endif()
target_link_libraries(osmin ${LIBOSMSCOUT_LIBRARIES})
add_definitions(-DQT_STATICPLUGIN)
if(ANDROID)
add_definitions(-DDEVICE_MOBILE)
add_definitions(-frtti) # dynamic_cast: https://github.com/android/ndk/issues/519
target_link_libraries(osmin Qt5::QuickControls2 Qt5::AndroidExtras android log Qt5::RemoteObjects Qt5::Positioning
Qt5::Qml Qt5::Quick Qt5::Widgets Qt5::Gui Qt5::Xml Qt5::Svg Qt5::Network Qt5::Sensors Qt5::Multimedia Qt5::Core)
else()
if(BUILD_DEVICE_MOBILE)
add_definitions(-DDEVICE_MOBILE)
endif()
target_link_libraries(osmin Qt5::QuickControls2 Qt5::RemoteObjects Qt5::Positioning
Qt5::Qml Qt5::Quick Qt5::Widgets Qt5::Gui Qt5::Xml Qt5::Svg Qt5::Network Qt5::Sensors Qt5::Multimedia Qt5::Core)
endif()
if(ANDROID)
# Fix import of shared omp with android ndk rev 21
if(OpenMP_CXX_LIBRARIES MATCHES libomp.so)
set(SHARED_LIBOMP ${OpenMP_CXX_LIBRARIES})
endif()
add_dependencies(osmin ssl crypto)
include(android/AddQtAndroidApk.cmake)
add_qt_android_apk(osmin-apk osmin
NAME ${APP_NAME}
VERSION_CODE ${APP_VERSION_CODE}
PACKAGE_NAME ${APP_ID}
PACKAGE_SOURCES ${CMAKE_SOURCE_DIR}/android/package-sources
BUILDTOOLS_REVISION ${QT_ANDROID_SDK_BUILDTOOLS_REVISION}
DEPENDS ssl crypto ${SHARED_LIBOMP}
PLUGINS ${CMAKE_SOURCE_DIR}/resources
KEYSTORE ${KEYSTORE_FILE} ${KEYSTORE_ALIAS}
KEYSTORE_PASSWORD ${KEYSTORE_PASSWORD}
)
else()
set_target_properties(osmin PROPERTIES OUTPUT_NAME "${EXEC}")
install(TARGETS osmin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
file(COPY "resources" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/resources
DESTINATION ${CMAKE_INSTALL_DATADIR}/${EXEC}
)
endif()
add_custom_target(
"run"
QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/backend/qml ${CMAKE_BINARY_DIR}/${EXEC} --debug
DEPENDS osmin
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY
)
add_custom_target(
"uninstall"
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)