-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
CMakeLists.txt
184 lines (151 loc) · 4.9 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
#############################################################
# locate native libs
SET(NATIVE_LINK_LIBS)
IF(UNIX AND NOT APPLE AND NOT ANDROID)
FIND_PACKAGE(Qt5DBus REQUIRED)
ENDIF(UNIX AND NOT APPLE AND NOT ANDROID)
IF(APPLE)
SET(APPLE_LIB_LIST ApplicationServices CoreFoundation IOKit AppKit)
FOREACH(_lib ${APPLE_LIB_LIST})
STRING(TOUPPER ${_lib} _lib_var)
# prefer /System/Library/Frameworks, in case CMAKE_FIND_FRAMEWORK=LAST, etc.
FIND_LIBRARY(APPLE_${_lib_var}_LIBRARY
NAMES ${_lib}
PATHS /System/Library/Frameworks
NO_DEFAULT_PATH
)
# if not found, drop back to standard find paths
FIND_LIBRARY(APPLE_${_lib_var}_LIBRARY ${_lib})
IF(NOT APPLE_${_lib_var}_LIBRARY)
MESSAGE(FATAL_ERROR "Couldn't find Apple's '${_lib}' framework or library")
ENDIF(NOT APPLE_${_lib_var}_LIBRARY)
LIST(APPEND NATIVE_LINK_LIBS "-framework ${_lib}")
ENDFOREACH(_lib ${APPLE_LIB_LIST})
ENDIF(APPLE)
#############################################################
# sources
SET(QGIS_NATIVE_SRCS
qgsnative.cpp
)
SET(QGIS_NATIVE_MOC_HDRS
qgsnative.h
)
SET(QGIS_NATIVE_HDRS
qgsnative.h
)
IF(APPLE)
SET(QGIS_APP_OBJC_SRCS
mac/cocoainitializer.mm
mac/qgsmacnative.mm
)
SET_SOURCE_FILES_PROPERTIES(${QGIS_APP_OBJC_SRCS} PROPERTIES COMPILE_FLAGS "-x objective-c++")
SET(QGIS_NATIVE_SRCS ${QGIS_NATIVE_SRCS}
${QGIS_APP_OBJC_SRCS}
)
SET (QGIS_NATIVE_MOC_HDRS
${QGIS_NATIVE_MOC_HDRS}
mac/qgsmacnative.h
)
SET (QGIS_NATIVE_HDRS ${QGIS_NATIVE_HDRS}
mac/qgsmacnative.h
mac/cocoainitializer.h
)
ENDIF(APPLE)
IF(MSVC)
SET(QGIS_NATIVE_SRCS ${QGIS_NATIVE_SRCS}
../../external/wintoast/src/wintoastlib.cpp
win/qgswinnative.cpp
)
SET (QGIS_NATIVE_MOC_HDRS
${QGIS_NATIVE_MOC_HDRS}
win/qgswinnative.h
)
SET (QGIS_NATIVE_HDRS ${QGIS_NATIVE_HDRS}
win/qgswinnative.h
)
ENDIF(MSVC)
IF(UNIX AND NOT APPLE AND NOT ANDROID)
SET(QGIS_NATIVE_SRCS ${QGIS_NATIVE_SRCS}
linux/qgslinuxnative.cpp
)
SET (QGIS_NATIVE_MOC_HDRS
${QGIS_NATIVE_MOC_HDRS}
linux/qgslinuxnative.h
)
SET (QGIS_NATIVE_HDRS ${QGIS_NATIVE_HDRS}
linux/qgslinuxnative.h
)
ENDIF(UNIX AND NOT APPLE AND NOT ANDROID)
QT5_WRAP_CPP(QGIS_NATIVE_MOC_SRCS ${QGIS_NATIVE_MOC_HDRS})
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
IF(MSVC)
INCLUDE_DIRECTORIES(SYSTEM
../../external/wintoast/src
)
ENDIF(MSVC)
#############################################################
# qgis_native library
ADD_LIBRARY(qgis_native SHARED ${QGIS_NATIVE_SRCS} ${QGIS_NATIVE_MOC_SRCS} ${QGIS_NATIVE_HDRS} ${QGIS_NATIVE_MOC_HDRS})
SET_PROPERTY(TARGET qgis_native PROPERTY POSITION_INDEPENDENT_CODE ON)
GENERATE_EXPORT_HEADER(
qgis_native
BASE_NAME NATIVE
EXPORT_FILE_NAME qgis_native.h
)
SET(QGIS_NATIVE_HDRS ${QGIS_NATIVE_HDRS} ${CMAKE_CURRENT_BINARY_DIR}/qgis_native.h)
IF(NOT APPLE)
INSTALL(FILES ${QGIS_NATIVE_HDRS} DESTINATION ${QGIS_INCLUDE_DIR})
ELSE(NOT APPLE)
SET_TARGET_PROPERTIES(qgis_native PROPERTIES
CLEAN_DIRECT_OUTPUT 1
FRAMEWORK 1
FRAMEWORK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}"
MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_SOURCE_DIR}/mac/framework.info.plist.in"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${COMPLETE_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER org.qgis.qgis3_native
BUILD_WITH_INSTALL_RPATH TRUE
PUBLIC_HEADER "${QGIS_NATIVE_HDRS}"
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
)
ENDIF(NOT APPLE)
#generate unversioned libs for android
IF(NOT ANDROID)
SET_TARGET_PROPERTIES(qgis_native PROPERTIES
VERSION ${COMPLETE_VERSION}
SOVERSION ${COMPLETE_VERSION}
)
ENDIF(NOT ANDROID)
TARGET_LINK_LIBRARIES(qgis_native
${Qt5Core_LIBRARIES}
${Qt5Gui_LIBRARIES}
"${NATIVE_LINK_LIBS}"
)
IF (UNIX AND NOT APPLE AND NOT ANDROID)
TARGET_LINK_LIBRARIES(qgis_native Qt5::DBus)
ENDIF (UNIX AND NOT APPLE AND NOT ANDROID)
IF (APPLE)
FIND_PACKAGE(Qt5MacExtras)
TARGET_LINK_LIBRARIES(qgis_native Qt5::MacExtras)
ENDIF (APPLE)
IF (MSVC)
FIND_PACKAGE(Qt5WinExtras)
TARGET_LINK_LIBRARIES(qgis_native shell32)
TARGET_LINK_LIBRARIES(qgis_native ${Qt5Widget_LIBRARIES} ${QT_QTMAIN_LIBRARY})
TARGET_LINK_LIBRARIES(qgis_native Qt5::WinExtras)
ENDIF (MSVC)
# install
INSTALL(TARGETS qgis_native
RUNTIME DESTINATION ${QGIS_BIN_DIR}
LIBRARY DESTINATION ${QGIS_LIB_DIR}
ARCHIVE DESTINATION ${QGIS_LIB_DIR}
FRAMEWORK DESTINATION ${QGIS_FW_SUBDIR}
PUBLIC_HEADER DESTINATION ${QGIS_INCLUDE_DIR}
)
# Mac dev frameworks
IF (APPLE AND QGIS_MACAPP_INSTALL_DEV)
INSTALL(TARGETS qgis_native FRAMEWORK DESTINATION ${QGIS_MACAPP_DEV_PREFIX})
INSTALL(CODE "EXECUTE_PROCESS(COMMAND install_name_tool -id \"${QGIS_MACAPP_DEV_PREFIX}/qgis_native.framework/Versions/${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}/qgis_native\" \"$ENV{DESTDIR}${QGIS_MACAPP_DEV_PREFIX}/qgis_native.framework/qgis_native\")")
ENDIF (APPLE AND QGIS_MACAPP_INSTALL_DEV)