This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
221 lines (171 loc) · 6.12 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
# -*- CMake -*-
####################################################################################################
#
# Customizable settings
#
# Generate compile_commands.json
# -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# -D <var>:<type>=<value>: Create a cmake cache entry.
# Install path prefix, prepended onto install directories.
# -D CMAKE_INSTALL_PREFIX:PATH=...
# Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
# CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
# -D CMAKE_BUILD_TYPE:STRING=Debug
# If this value is on, makefiles will be generated without the
# .SILENT directive, and all commands will be echoed to the console
# during the make. This is useful for debugging only.
# -D CMAKE_VERBOSE_MAKEFILE:BOOL=ON
####################################################################################################
project(QtCarto)
####################################################################################################
# check cmake version
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
if(POLICY CMP0990)
cmake_policy(SET CMP0990 NEW)
endif()
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
include(qtcarto_functions)
####################################################################################################
if(ANDROID)
message(STATUS "Android build")
endif()
####################################################################################################
#
# Test
#
if(NOT ANDROID)
enable_testing()
endif(NOT ANDROID)
####################################################################################################
#
# Version
#
set(QTCARTO_VERSION_MAJOR 1)
set(QTCARTO_VERSION_MINOR 0)
set(QTCARTO_VERSION_PATCH 0)
set(QTCARTO_VERSION ${QTCARTO_VERSION_MAJOR}.${QTCARTO_VERSION_MINOR}.${QTCARTO_VERSION_PATCH})
####################################################################################################
#
# Target Platform
#
if(ANDROID)
ADD_DEFINITIONS(-DON_ANDROID -DANDROID)
endif(ANDROID)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
ADD_DEFINITIONS(-DON_LINUX)
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
ADD_DEFINITIONS(-DON_WINDOWS)
endif(CMAKE_SYSTEM_NAME MATCHES "Windows")
####################################################################################################
#
# Compiler Options
#
if(NOT ANDROID)
# SET(CMAKE_BUILD_TYPE RELEASE)
SET(CMAKE_BUILD_TYPE DEBUG)
endif(NOT ANDROID)
SET(CMAKE_VERBOSE_MAKEFILE ON)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
elseif(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CMAKE_CXX_FLAGS_COMMON "-Wall -DSystemLinux -fdiagnostics-color=auto")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_COMMON} -g -O0 -DDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_COMMON} $ENV{GCC_OPTIMISATION}")
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
endif(CMAKE_SYSTEM_NAME MATCHES "Windows")
####################################################################################################
#
# Find Qt
#
if(NOT ANDROID)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Instruct CMake to run rcc automatically when needed.
set(CMAKE_AUTORCC ON)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Positioning REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5QuickWidgets REQUIRED)
find_package(Qt5Sensors REQUIRED)
find_package(Qt5Sql REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5Test REQUIRED)
# find_package(Qt5Xml REQUIRED)
# find_package(Qt5WebView REQUIRED)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_QML_DEBUG") # Fixme: right way to do?
# INCLUDE_DIRECTORIES(${Qt5Core_INCLUDES})
# ADD_DEFINITIONS(${Qt5Core_DEFINITIONS})
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
endif(NOT ANDROID)
####################################################################################################
#
# Find Proj4
#
if(NOT ANDROID)
include(FindProj4)
if(PROJ4_FOUND)
# add_definitions(-DWITH_PROJ4)
INCLUDE_DIRECTORIES(PROJ4_INCLUDE_DIR)
endif(PROJ4_FOUND)
endif(NOT ANDROID)
####################################################################################################
#
# Find Protobuf
#
if(NOT ANDROID)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
endif(NOT ANDROID)
####################################################################################################
#
# Find Zlib
#
if(NOT ANDROID)
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
endif(NOT ANDROID)
####################################################################################################
configure_file(config.h.in config.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
####################################################################################################
#
# Sub directories
#
if(ANDROID)
add_subdirectory(third-parties)
endif(ANDROID)
if(NOT ANDROID)
INCLUDE_DIRECTORIES(src)
endif(NOT ANDROID)
if(NOT ANDROID)
add_subdirectory(src)
add_subdirectory(imports)
add_subdirectory(mapviewer)
endif(NOT ANDROID)
if(NOT ANDROID)
add_subdirectory(tools)
add_subdirectory(test)
endif(NOT ANDROID)
####################################################################################################
#
# End
#
####################################################################################################