-
Notifications
You must be signed in to change notification settings - Fork 26
/
qt.cmake
191 lines (177 loc) · 8.04 KB
/
qt.cmake
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
# Qt selection: external, system or embedded
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
if (DEFINED ENV{OSMAND_EXTERNAL_QT})
# External
set(OSMAND_EXTERNAL_QT ON)
message("Using external Qt5: $ENV{OSMAND_EXTERNAL_QT}")
list(APPEND CMAKE_PREFIX_PATH "$ENV{OSMAND_EXTERNAL_QT}/lib/cmake")
elseif (DEFINED ENV{OSMAND_SYSTEM_QT})
# System
set(OSMAND_SYSTEM_QT ON)
message("Using system Qt5.")
else()
# Embedded: shared and static
set(OSMAND_OWN_SHIPPED_QT ON)
# Flavour: desktop, iOS or etc.
if (CMAKE_TARGET_OS STREQUAL "linux" OR
CMAKE_TARGET_OS STREQUAL "macosx" OR
CMAKE_TARGET_OS STREQUAL "windows" OR
CMAKE_TARGET_OS STREQUAL "cygwin")
set(OSMAND_QT_FLAVOUR "desktop")
elseif (CMAKE_TARGET_OS STREQUAL "ios")
set(OSMAND_QT_FLAVOUR "ios")
elseif (CMAKE_TARGET_OS STREQUAL "android")
set(OSMAND_QT_FLAVOUR "android")
else()
message(FATAL_ERROR "Failed to determine Qt flavour")
endif()
# Debug suffix
set(QT_DEBUG_SUFFIX "d")
if (CMAKE_TARGET_OS STREQUAL "macosx" OR CMAKE_TARGET_OS STREQUAL "ios")
set(QT_DEBUG_SUFFIX "_debug")
endif()
# Since Qt is also an upstream, configure it and build
prepare_upstream_ex("${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}" QT_WAS_CONFIGURED)
build_upstream_ex("${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}")
# If shared libs are allowed, they need shared Qt
if (CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
if (EXISTS "${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}/upstream.patched.${CMAKE_TARGET_OS}.${CMAKE_COMPILER_FAMILY}-${CMAKE_TARGET_CPU_ARCH}.shared/lib/cmake")
set(OSMAND_OWN_SHIPPED_QT_SHARED "${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}/upstream.patched.${CMAKE_TARGET_OS}.${CMAKE_COMPILER_FAMILY}-${CMAKE_TARGET_CPU_ARCH}.shared")
elseif (EXISTS "${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}/upstream.patched.${CMAKE_TARGET_OS}.${CMAKE_COMPILER_FAMILY}.shared/lib/cmake")
set(OSMAND_OWN_SHIPPED_QT_SHARED "${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}/upstream.patched.${CMAKE_TARGET_OS}.${CMAKE_COMPILER_FAMILY}.shared")
endif()
if (NOT DEFINED OSMAND_OWN_SHIPPED_QT_SHARED)
message(FATAL_ERROR "Embedded shared Qt not found")
else()
message("Using embedded Qt5 (shared): ${OSMAND_OWN_SHIPPED_QT_SHARED}")
endif()
find_library(Qt5Core_SHARED_LIBRARY "Qt5Core" PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib" NO_DEFAULT_PATH)
find_library(Qt5Cored_SHARED_LIBRARY "Qt5Core${QT_DEBUG_SUFFIX}" PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib" NO_DEFAULT_PATH)
set(Qt5Core_SHARED_LIBRARIES "")
if (Qt5Core_SHARED_LIBRARY AND Qt5Cored_SHARED_LIBRARY)
set(Qt5Core_SHARED_LIBRARIES ${Qt5Core_SHARED_LIBRARIES}
optimized ${Qt5Core_SHARED_LIBRARY}
)
else()
set(Qt5Core_SHARED_LIBRARIES ${Qt5Core_SHARED_LIBRARIES}
${Qt5Core_SHARED_LIBRARY}
)
endif()
if (Qt5Cored_SHARED_LIBRARY)
set(Qt5Core_SHARED_LIBRARIES ${Qt5Core_SHARED_LIBRARIES}
debug ${Qt5Cored_SHARED_LIBRARY}
)
endif()
find_library(Qt5Network_SHARED_LIBRARY "Qt5Network" PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib" NO_DEFAULT_PATH)
find_library(Qt5Networkd_SHARED_LIBRARY "Qt5Network${QT_DEBUG_SUFFIX}" PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib" NO_DEFAULT_PATH)
set(Qt5Network_SHARED_LIBRARIES "")
if (Qt5Network_SHARED_LIBRARY AND Qt5Networkd_SHARED_LIBRARY)
set(Qt5Network_SHARED_LIBRARIES ${Qt5Network_SHARED_LIBRARIES}
optimized ${Qt5Network_SHARED_LIBRARY}
)
else()
set(Qt5Network_SHARED_LIBRARIES ${Qt5Network_SHARED_LIBRARIES}
${Qt5Network_SHARED_LIBRARY}
)
endif()
if (Qt5Networkd_SHARED_LIBRARY)
set(Qt5Network_SHARED_LIBRARIES ${Qt5Network_SHARED_LIBRARIES}
debug ${Qt5Networkd_SHARED_LIBRARY}
)
endif()
find_library(qtpcre_SHARED_LIBRARY "qtpcre2" PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib" NO_DEFAULT_PATH)
if (NOT qtpcre_SHARED_LIBRARY)
find_library(qtpcre_SHARED_LIBRARY "qtpcre" PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib" NO_DEFAULT_PATH)
endif()
find_library(qtpcred_SHARED_LIBRARY "qtpcre2${QT_DEBUG_SUFFIX}" PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib" NO_DEFAULT_PATH)
if (NOT qtpcred_SHARED_LIBRARY)
find_library(qtpcred_SHARED_LIBRARY "qtpcre${QT_DEBUG_SUFFIX}" PATHS "${OSMAND_OWN_SHIPPED_QT_SHARED}/lib" NO_DEFAULT_PATH)
endif()
set(qtpcre_SHARED_LIBRARIES "")
if (qtpcre_SHARED_LIBRARY AND qtpcred_SHARED_LIBRARY)
set(qtpcre_SHARED_LIBRARIES ${qtpcre_SHARED_LIBRARIES}
optimized ${qtpcre_SHARED_LIBRARY}
)
else()
set(qtpcre_SHARED_LIBRARIES ${qtpcre_SHARED_LIBRARIES}
${qtpcre_SHARED_LIBRARY}
)
endif()
if (qtpcred_SHARED_LIBRARY)
set(qtpcre_SHARED_LIBRARIES ${qtpcre_SHARED_LIBRARIES}
debug ${qtpcred_SHARED_LIBRARY}
)
endif()
endif()
# If static libs are allowed, they need static Qt
if (CMAKE_STATIC_LIBS_ALLOWED_ON_TARGET)
if (EXISTS "${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}/upstream.patched.${CMAKE_TARGET_OS}.${CMAKE_COMPILER_FAMILY}-${CMAKE_TARGET_CPU_ARCH}.static/lib/cmake")
set(OSMAND_OWN_SHIPPED_QT_STATIC "${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}/upstream.patched.${CMAKE_TARGET_OS}.${CMAKE_COMPILER_FAMILY}-${CMAKE_TARGET_CPU_ARCH}.static")
elseif (EXISTS "${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}/upstream.patched.${CMAKE_TARGET_OS}.${CMAKE_COMPILER_FAMILY}.static/lib/cmake")
set(OSMAND_OWN_SHIPPED_QT_STATIC "${OSMAND_ROOT}/core/externals/qtbase-${OSMAND_QT_FLAVOUR}/upstream.patched.${CMAKE_TARGET_OS}.${CMAKE_COMPILER_FAMILY}.static")
endif()
if (NOT DEFINED OSMAND_OWN_SHIPPED_QT_STATIC)
message(FATAL_ERROR "Embedded static Qt not found")
else()
message("Using embedded Qt5 (static): ${OSMAND_OWN_SHIPPED_QT_STATIC}")
endif()
find_library(Qt5Core_STATIC_LIBRARY "Qt5Core" PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib" NO_DEFAULT_PATH)
find_library(Qt5Cored_STATIC_LIBRARY "Qt5Core${QT_DEBUG_SUFFIX}" PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib" NO_DEFAULT_PATH)
set(Qt5Core_STATIC_LIBRARIES "")
if (Qt5Core_STATIC_LIBRARY AND Qt5Cored_STATIC_LIBRARY)
set(Qt5Core_STATIC_LIBRARIES ${Qt5Core_STATIC_LIBRARIES}
optimized ${Qt5Core_STATIC_LIBRARY}
)
else()
set(Qt5Core_STATIC_LIBRARIES ${Qt5Core_STATIC_LIBRARIES}
${Qt5Core_STATIC_LIBRARY}
)
endif()
if (Qt5Cored_STATIC_LIBRARY)
set(Qt5Core_STATIC_LIBRARIES ${Qt5Core_STATIC_LIBRARIES}
debug ${Qt5Cored_STATIC_LIBRARY}
)
endif()
find_library(Qt5Network_STATIC_LIBRARY "Qt5Network" PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib" NO_DEFAULT_PATH)
find_library(Qt5Networkd_STATIC_LIBRARY "Qt5Network${QT_DEBUG_SUFFIX}" PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib" NO_DEFAULT_PATH)
set(Qt5Network_STATIC_LIBRARIES "")
if (Qt5Network_STATIC_LIBRARY AND Qt5Networkd_STATIC_LIBRARY)
set(Qt5Network_STATIC_LIBRARIES ${Qt5Network_STATIC_LIBRARIES}
optimized ${Qt5Network_STATIC_LIBRARY}
)
else()
set(Qt5Network_STATIC_LIBRARIES ${Qt5Network_STATIC_LIBRARIES}
${Qt5Network_STATIC_LIBRARY}
)
endif()
if (Qt5Networkd_STATIC_LIBRARY)
set(Qt5Network_STATIC_LIBRARIES ${Qt5Network_STATIC_LIBRARIES}
debug ${Qt5Networkd_STATIC_LIBRARY}
)
endif()
find_library(qtpcre_STATIC_LIBRARY "qtpcre2" PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib" NO_DEFAULT_PATH)
if (NOT qtpcre_STATIC_LIBRARY)
find_library(qtpcre_STATIC_LIBRARY "qtpcre" PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib" NO_DEFAULT_PATH)
endif()
find_library(qtpcred_STATIC_LIBRARY "qtpcre2${QT_DEBUG_SUFFIX}" PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib" NO_DEFAULT_PATH)
if (NOT qtpcred_STATIC_LIBRARY)
find_library(qtpcred_STATIC_LIBRARY "qtpcre${QT_DEBUG_SUFFIX}" PATHS "${OSMAND_OWN_SHIPPED_QT_STATIC}/lib" NO_DEFAULT_PATH)
endif()
set(qtpcre_STATIC_LIBRARIES "")
if (qtpcre_STATIC_LIBRARY AND qtpcred_STATIC_LIBRARY)
set(qtpcre_STATIC_LIBRARIES ${qtpcre_STATIC_LIBRARIES}
optimized ${qtpcre_STATIC_LIBRARY}
)
else()
set(qtpcre_STATIC_LIBRARIES ${qtpcre_STATIC_LIBRARIES}
${qtpcre_STATIC_LIBRARY}
)
endif()
if (qtpcred_STATIC_LIBRARY)
set(qtpcre_STATIC_LIBRARIES ${qtpcre_STATIC_LIBRARIES}
debug ${qtpcred_STATIC_LIBRARY}
)
endif()
endif()
endif()