forked from qgis/QGIS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1258 lines (1063 loc) · 50.5 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#############################################################
# CMake settings
cmake_minimum_required(VERSION 3.12.0)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_AUTORCC ON)
# set path to additional CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# POLICIES
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0053 NEW)
cmake_policy(SET CMP0071 NEW)
cmake_policy(SET CMP0094 NEW)
if(NOT "${CMAKE_VERSION}" VERSION_LESS "3.27")
cmake_policy(SET CMP0144 NEW)
# include(Dart) still used, as is the "Experimental" target
cmake_policy(SET CMP0145 OLD)
endif()
# don't relink it only the shared object changes
set(CMAKE_LINK_DEPENDS_NO_SHARED ON)
#############################################################
# Project and version
set(CPACK_PACKAGE_VERSION_MAJOR "3")
set(CPACK_PACKAGE_VERSION_MINOR "37")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(COMPLETE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(RELEASE_NAME "Master")
project(qgis VERSION ${COMPLETE_VERSION})
if (APPLE)
set(QGIS_APP_NAME "QGIS")
else()
set(QGIS_APP_NAME "qgis")
endif()
# Note the version no is Mmmpp for Major/minor/patch, 0-padded, thus '10100' for 1.1.0
math(EXPR QGIS_VERSION_INT "${CPACK_PACKAGE_VERSION_MAJOR}*10000+${CPACK_PACKAGE_VERSION_MINOR}*100+${CPACK_PACKAGE_VERSION_PATCH}")
message(STATUS "QGIS version: ${COMPLETE_VERSION} ${RELEASE_NAME} (${QGIS_VERSION_INT})")
set (ENABLE_LOCAL_BUILD_SHORTCUTS FALSE CACHE BOOL "Disables some build steps which are only relevant for releases to speed up compilation time for development")
#############################################################
if (APPLE)
# QGIS custom dependencies package from qgis/QGIS-Mac-Packager
# they can be downloaded from https://qgis.org/downloads/macos/qgis-deps
# and extracted to /opt/QGIS/qgis-deps-<deps-version>/stage
set (QGIS_MAC_DEPS_DIR "" CACHE PATH "Path to QGIS Mac custom dependencies directory")
# Setup LIB_DIR and CMAKE_PREFIX_PATH to help CMake's
# find_packages to look for these libraries instead of system libraries
if ( QGIS_MAC_DEPS_DIR )
set(ENV{LIB_DIR} ${QGIS_MAC_DEPS_DIR})
list(APPEND CMAKE_PREFIX_PATH ${QGIS_MAC_DEPS_DIR})
endif()
endif()
#############################################################
# Configure OpenCL if available
set(HAVE_OPENCL FALSE)
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "BSD$")
option(USE_OPENCL "Use OpenCL" OFF)
else()
option(USE_OPENCL "Use OpenCL" ON)
endif()
if (USE_OPENCL)
find_package(OpenCL)
if(${OpenCL_FOUND})
set(HAVE_OPENCL TRUE)
# Fixup for standard FindOpenCL module not assigning proper framework headers directory
if (APPLE AND "${OpenCL_INCLUDE_DIR}" MATCHES "OpenCL\\.framework/?$")
set(OpenCL_INCLUDE_DIR "${OpenCL_INCLUDE_DIR}/Headers" CACHE PATH "" FORCE)
set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR})
endif()
find_package(OpenCLhpp)
if(NOT OPENCL_HPP_FOUND)
# Use internal headers copied from OpenCL-CLHPP project
set(OPENCL_HPP_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/external/opencl-clhpp/include CACHE PATH "" FORCE)
message(STATUS "Couldn't find OpenCL C++ headers, using internal: ${OPENCL_HPP_INCLUDE_DIR}")
endif()
set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIRS} ${OPENCL_HPP_INCLUDE_DIR})
else()
message(STATUS "Couldn't find OpenCL: support DISABLED")
endif()
endif()
# Configure CCache if available
if(NOT MSVC)
option(USE_CCACHE "Use ccache" ON)
if (USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
message(STATUS "ccache found")
endif(CCACHE_FOUND)
endif(USE_CCACHE)
endif(NOT MSVC)
if (IOS)
set (DEFAULT_FORCE_STATIC_LIBS TRUE)
else()
set (DEFAULT_FORCE_STATIC_LIBS FALSE)
endif()
set (FORCE_STATIC_LIBS ${DEFAULT_FORCE_STATIC_LIBS} CACHE BOOL "Determines whether libraries should be static only")
mark_as_advanced(FORCE_STATIC_LIBS)
if (FORCE_STATIC_LIBS)
set (LIBRARY_TYPE STATIC)
# following variable is used in qgsconfig.h
set (HAVE_STATIC_PROVIDERS TRUE)
else()
set (LIBRARY_TYPE SHARED)
unset(HAVE_STATIC_PROVIDERS)
endif()
# in generated makefiles use relative paths so the project dir is moveable
# Note commented out since it cause problems but it would be nice to resolve these and enable
#
# issue is caused by include_directories(${CMAKE_BINARY_DIR}) near the end of this file generating incorrect path
#set (CMAKE_USE_RELATIVE_PATHS ON)
set (WITH_CORE TRUE CACHE BOOL "Determines whether QGIS core should be built.")
mark_as_advanced(WITH_CORE)
if(WITH_CORE)
# Try to configure and build GRASS plugin by default
foreach (GRASS_SEARCH_VERSION 7 8)
# Legacy note:
# For GRASS 6 there were used cached variables without version suffix so that existing caches didn't have to be reconfigured.
# Cached variables were: WITH_GRASS, WITH_GRASS7, GRASS_PREFIX, GRASS_PREFIX7, GRASS_INCLUDE_DIR, GRASS_INCLUDE_DIR7
# Everywhere else each variable has version major appended.
# Normal variables were: GRASS_FOUND6, GRASS_FOUND7, GRASS_MAJOR_VERSION6, GRASS_MAJOR_VERSION7, etc.
# In addition there is also GRASS_FOUND, which is TRUE if at least one version of GRASS was found
set (GRASS_CACHE_VERSION ${GRASS_SEARCH_VERSION})
set (WITH_GRASS${GRASS_CACHE_VERSION} TRUE CACHE BOOL "Determines whether GRASS ${GRASS_SEARCH_VERSION} plugin should be built")
if (WITH_GRASS${GRASS_CACHE_VERSION})
find_package(GRASS ${GRASS_SEARCH_VERSION})
set (GRASS_PREFIX${GRASS_CACHE_VERSION} ${GRASS_PREFIX${GRASS_SEARCH_VERSION}} CACHE PATH "Path to GRASS ${GRASS_SEARCH_VERSION} base directory")
endif()
endforeach (GRASS_SEARCH_VERSION)
set (WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library (and everything built on top of it) should be built")
set (WITH_OAUTH2_PLUGIN TRUE CACHE BOOL "Determines whether OAuth2 authentication method plugin should be built")
if(WITH_OAUTH2_PLUGIN)
set(HAVE_OAUTH2_PLUGIN TRUE)
endif()
set (WITH_AUTH TRUE CACHE BOOL "Determines whether QGIS authentication methods should be built")
set (WITH_ANALYSIS TRUE CACHE BOOL "Determines whether QGIS analysis library should be built")
set (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built")
if(WITH_DESKTOP)
if((WIN32 AND NOT MINGW) OR (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS))
set (CRASH_HANDLER_AVAILABLE TRUE)
else()
set (CRASH_HANDLER_AVAILABLE FALSE)
endif()
set (WITH_CRASH_HANDLER ${CRASH_HANDLER_AVAILABLE} CACHE BOOL "Determines whether the QGIS crash handler application should be built")
if(WITH_CRASH_HANDLER AND NOT CRASH_HANDLER_AVAILABLE)
message(FATAL_ERROR "Crash handler cannot be built on this environment. Set WITH_CRASH_HANDLER to false.")
endif()
if(WITH_CRASH_HANDLER)
set (HAVE_CRASH_HANDLER TRUE) # used in qgsconfig.h
else()
set (HAVE_CRASH_HANDLER FALSE) # used in qgsconfig.h
endif()
endif()
set (WITH_3D TRUE CACHE BOOL "Determines whether QGIS 3D library should be built")
set (WITH_QUICK FALSE CACHE BOOL "Determines whether QGIS Quick library should be built")
set (WITH_QGIS_PROCESS TRUE CACHE BOOL "Determines whether the standalone \"qgis_process\" tool should be built")
set (NATIVE_CRSSYNC_BIN "" CACHE PATH "Path to a natively compiled synccrsdb binary. If set, crssync will not build but use provided bin instead.")
mark_as_advanced (NATIVE_CRSSYNC_BIN)
# try to configure and build python bindings by default
set (WITH_BINDINGS TRUE CACHE BOOL "Determines whether Python bindings should be built")
if (WITH_BINDINGS)
# By default bindings will be installed only to QGIS directory
# Someone might want to install it to python site-packages directory
# as otherwise user has to use PYTHONPATH environment variable to add
# QGIS bindings to package search path
set (BINDINGS_GLOBAL_INSTALL FALSE CACHE BOOL "Install bindings to global Python directory? (might need root)")
set (SIP_GLOBAL_INSTALL FALSE CACHE BOOL "Install sip source files to system sip directory? (might need root)")
set (WITH_STAGED_PLUGINS TRUE CACHE BOOL "Stage-install core Python plugins to run from build directory? (utilities and console are always staged)")
set (WITH_PY_COMPILE FALSE CACHE BOOL "Determines whether Python modules in staged or installed locations should be byte-compiled")
# concatenate QScintilla2 API files
if (WITH_GUI)
set (WITH_QSCIAPI TRUE CACHE BOOL "Whether to generate PyQGIS QScintilla2 API file. (For devs) run 'make qsci-pap-src' in between QGIS build and install to regenerate .pap file in source tree for console auto-completion.")
# keep casual users from updating their source tree via WITH_QSCIAPI
mark_as_advanced (WITH_QSCIAPI)
endif()
endif()
# server disabled default because it needs FastCGI (which is optional dependency)
set (WITH_SERVER FALSE CACHE BOOL "Determines whether QGIS server should be built")
if(WITH_SERVER)
set (WITH_SERVER_LANDINGPAGE_WEBAPP FALSE CACHE BOOL "Determines whether QGIS server landingpage webapp should be built (requires nodejs and yarn)")
set (SERVER_SKIP_ECW FALSE CACHE BOOL "Determines whether QGIS server should disable ECW (ECW in server apps requires a special license)")
set (WITH_SERVER_PLUGINS ${WITH_BINDINGS} CACHE BOOL "Determines whether QGIS server support for Python plugins should be built")
if(WITH_SERVER_PLUGINS AND NOT WITH_BINDINGS)
message(FATAL_ERROR "Server plugins are not supported without Python bindings. Enable WITH_BINDINGS or disable WITH_SERVER_PLUGINS")
endif()
if(WITH_SERVER_PLUGINS)
set(HAVE_SERVER_PYTHON_PLUGINS TRUE)
endif()
endif()
# Custom widgets
set (WITH_CUSTOM_WIDGETS FALSE CACHE BOOL "Determines whether QGIS custom widgets for Qt Designer should be built")
if (NOT WITH_GUI)
set (HAVE_GUI FALSE) # used in qgsconfig.h
# force value of some options
if(WITH_DESKTOP)
message(FATAL_ERROR "Desktop cannot be built without gui. Enable WITH_GUI or disable WITH_DESKTOP.")
endif()
if(WITH_CUSTOM_WIDGETS)
message(FATAL_ERROR "Custom widgets cannot be built without gui. Enable WITH_GUI or disable WITH_CUSTOM_WIDGETS.")
endif()
else()
set (HAVE_GUI TRUE) # used in qgsconfig.h
endif()
if ( WITH_DESKTOP AND NOT WITH_ANALYSIS )
message(FATAL_ERROR "Desktop cannot be built without analysis")
endif()
if ( WITH_QGIS_PROCESS AND NOT WITH_ANALYSIS )
message(FATAL_ERROR "Process tool cannot be built without analysis")
endif()
if ( WITH_DESKTOP )
# The qgis_desktop target is meant to build a minimal but complete running QGIS during development
# This should help to reduce compile time while still having a "complete enough" QGIS for most of the development
add_custom_target(qgis_desktop
DEPENDS qgis qgispython pycore pygui pyanalysis provider_postgres staged-plugins pyplugin-installer resources svg doc icons
)
endif()
# try to configure and build MDAL support
set (WITH_INTERNAL_MDAL TRUE CACHE BOOL "Determines whether MDAL should be built from internal copy (recommended)")
if (NOT WITH_INTERNAL_MDAL)
set (MDAL_PREFIX "" CACHE PATH "Path to MDAL base directory")
endif()
# try to configure and build POLY2TRI support
set (WITH_INTERNAL_POLY2TRI TRUE CACHE BOOL "Determines whether POLY2TRI should be built from internal copy")
# try to configure and build POSTGRESQL support
set (WITH_POSTGRESQL TRUE CACHE BOOL "Determines whether POSTGRESQL support should be built")
if (WITH_POSTGRESQL)
set (POSTGRESQL_PREFIX "" CACHE PATH "Path to POSTGRESQL base directory")
endif()
# try to configure and build POSTGRESQL support
set (WITH_SPATIALITE TRUE CACHE BOOL "Determines whether Spatialite support should be built (required for spatialite, virtual, wfs providers)")
if (WITH_SPATIALITE)
set (WITH_QSPATIALITE FALSE CACHE BOOL "Determines whether QSPATIALITE sql driver should be built")
endif()
set (WITH_ORACLE FALSE CACHE BOOL "Determines whether Oracle support should be built")
if(WITH_ORACLE)
set(HAVE_ORACLE TRUE)
set(ORACLE_INCLUDEDIR "" CACHE STRING "Path to OCI headers")
set(ORACLE_LIBDIR "" CACHE STRING "Path to OCI libraries")
endif()
set (WITH_HANA FALSE CACHE BOOL "Determines whether SAP HANA Spatial support should be built")
if(WITH_HANA)
find_package(ODBC)
if(ODBC_FOUND)
set(HAVE_HANA TRUE)
add_subdirectory(external/odbccpp)
set_target_properties(odbccpp_static PROPERTIES AUTOMOC OFF AUTOUIC OFF AUTORCC OFF)
else()
message(STATUS "Couldn't find ODBC library")
endif()
endif(WITH_HANA)
set (WITH_PDAL TRUE CACHE BOOL "Determines whether PDAL support should be built")
set (WITH_EPT TRUE CACHE BOOL "Determines whether Entwine Point Cloud (EPT) support should be built")
set (WITH_COPC TRUE CACHE BOOL "Determines whether Cloud Optimized Point Cloud (COPC) support should be built")
set (WITH_DRACO TRUE CACHE BOOL "Determines whether Draco support should be built")
set (WITH_THREAD_LOCAL TRUE CACHE BOOL "Determines whether std::thread_local should be used")
mark_as_advanced(WITH_THREAD_LOCAL)
if (MINGW OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
# MingW has broken support for thread_local, so force disabling it
# see
# https://sourceforge.net/p/mingw-w64/bugs/445/
# https://sourceforge.net/p/mingw-w64/bugs/527/
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80816
# also OpenBSD has no thread_local support, see https://github.com/qgis/QGIS/issues/25248
else()
if (WITH_THREAD_LOCAL)
set (USE_THREAD_LOCAL TRUE) # used in qgsconfig.h
endif()
endif()
# Compile flag. Make it possible to turn it off.
set (PEDANTIC TRUE CACHE BOOL "Determines if we should compile in pedantic mode.")
# whether coverage tests should be performed
set (ENABLE_COVERAGE FALSE CACHE BOOL "Perform coverage tests?")
# whether coverage documentation should be generated
set (GENERATE_COVERAGE_DOCS FALSE CACHE BOOL "Generate coverage docs (requires lcov)?")
# hide this variable because building of python bindings might fail
# if set to other directory than expected
mark_as_advanced(LIBRARY_OUTPUT_PATH)
if (MSVC AND CMAKE_GENERATOR MATCHES "NMake")
# following variable is also used in qgsconfig.h
set (USING_NMAKE TRUE)
endif()
if (CMAKE_GENERATOR MATCHES "Ninja")
# following variable is also used in qgsconfig.h
set (USING_NINJA TRUE)
endif()
find_package(FLEX 2.6 REQUIRED)
find_package(BISON REQUIRED)
#############################################################
# search for dependencies
if(NOT WIN32 AND NOT ANDROID)
include(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(openpty OPENPTY_IN_LIBC)
if(NOT OPENPTY_IN_LIBC)
set(CMAKE_REQUIRED_INCLUDES util.h)
set(CMAKE_REQUIRED_LIBRARIES util)
CHECK_FUNCTION_EXISTS(openpty NEED_LIBUTIL)
if(NEED_LIBUTIL)
set(OPENPTY_LIBRARY util)
else()
message (SEND_ERROR "openpty not found!")
endif()
endif()
endif()
# required
find_package(Proj REQUIRED)
message(STATUS "Found Proj: ${PROJ_VERSION} ${PROJ_DIR}")
find_package(GEOS REQUIRED)
message(STATUS "Found Geos: ${GEOS_VERSION} ${GEOS_DIR}")
find_package(GDAL REQUIRED)
message(STATUS "Found GDAL: ${GDAL_VERSION} ${GDAL_DIR}")
find_package(EXPAT REQUIRED)
find_package(Spatialindex REQUIRED)
find_package(LibZip REQUIRED)
find_package(Sqlite3)
if (NOT SQLITE3_FOUND)
message (SEND_ERROR "sqlite3 dependency was not found!")
endif()
find_package(Protobuf CONFIG)
find_package(Protobuf REQUIRED)
message(STATUS "Found Protobuf: ${Protobuf_LIBRARIES}")
if (NOT Protobuf_PROTOC_EXECUTABLE)
message (SEND_ERROR "Protobuf library's 'protoc' tool was not found!")
endif()
find_package(ZLIB REQUIRED) # for decompression of vector tiles in MBTiles file
message(STATUS "Found zlib: ${ZLIB_LIBRARIES}")
find_package(EXIV2 REQUIRED)
# optional
if (WITH_POSTGRESQL)
find_package(Postgres) # PostgreSQL provider
endif()
if (NOT WITH_INTERNAL_MDAL)
find_package(MDAL REQUIRED) # MDAL provider
endif()
if (NOT WITH_INTERNAL_POLY2TRI)
find_package(poly2tri REQUIRED)
endif()
if (WITH_SPATIALITE)
find_package(SpatiaLite REQUIRED)
set (HAVE_SPATIALITE TRUE)
endif()
if (POSTGRES_FOUND)
# following variable is used in qgsconfig.h
set (HAVE_POSTGRESQL TRUE)
endif()
set (WITH_QTWEBKIT TRUE CACHE BOOL "Enable QtWebkit support")
if (WITH_QTWEBKIT)
add_definitions(-DWITH_QTWEBKIT)
message(STATUS "Qt WebKit support enabled")
else()
message(STATUS "Qt WebKit support DISABLED.")
endif()
set (WITH_INTERNAL_LAZPERF TRUE CACHE BOOL "Determines whether LazPerf should be built from internal copy (recommended)")
if (WITH_EPT OR WITH_COPC)
if (NOT WITH_INTERNAL_LAZPERF)
find_package(LazPerf) # for decompression of point clouds
endif()
if (NOT LazPerf_FOUND)
message(STATUS "Using embedded laz-perf")
endif()
endif()
if (WITH_EPT) # EPT provider
find_package(ZSTD REQUIRED) # for decompression of point clouds
set(HAVE_EPT TRUE) # used in qgsconfig.h
endif()
if (WITH_COPC) # COPC provider
set(HAVE_COPC TRUE) # used in qgsconfig.h
endif()
if (WITH_PDAL)
if (NOT WITH_EPT)
message(FATAL_ERROR "PDAL provider cannot be built with EPT disabled")
endif()
find_package(PDAL REQUIRED) # PDAL provider
set(HAVE_PDAL_QGIS TRUE) # used in qgisconfig.h. note -- we can't use HAVE_PDAL here as the grass public headers redefine this!
if (PDAL_VERSION_MAJOR GREATER 3 OR (PDAL_VERSION_MAJOR EQUAL 2 AND PDAL_VERSION_MINOR GREATER_EQUAL 5))
set(PDAL_2_5_OR_HIGHER TRUE)
endif()
endif()
if (WITH_DRACO)
find_package(Draco REQUIRED)
message(STATUS "Found Draco: ${DRACO_LIBRARY} (${DRACO_VERSION})")
set(HAVE_DRACO TRUE) # used in qgisconfig.h
endif()
#############################################################
# search for Qt
set (BUILD_WITH_QT6 FALSE CACHE BOOL "Enable (experimental) Qt6 support")
if (BUILD_WITH_QT6)
set(QT_VERSION_MAJOR 6)
set(QT_MIN_VERSION 6.4.0)
set(QT_VERSION_BASE "Qt6")
set(QT_VERSION_BASE_LOWER "qt6")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
else()
set(QT_VERSION_MAJOR 5)
set(QT_MIN_VERSION 5.15.2)
set(QT_VERSION_BASE "Qt5")
set(QT_VERSION_BASE_LOWER "qt5")
set(HAS_KDE_QT5_PDF_TRANSFORM_FIX FALSE CACHE BOOL "Using KDE's Qt 5.15 fork with the PDF brush transform fix")
set(HAS_KDE_QT5_SMALL_CAPS_FIX FALSE CACHE BOOL "Using KDE's Qt 5.15 fork with the QFont::SmallCaps fix")
set(HAS_KDE_QT5_FONT_STRETCH_FIX FALSE CACHE BOOL "Using KDE's Qt 5.15 fork with the QFont stretch fix")
endif()
# Use QtSerialPort optionally for GPS
set (WITH_QTSERIALPORT TRUE CACHE BOOL "Determines whether QtSerialPort should be tried for GPS positioning")
if (WITH_QTSERIALPORT)
find_package(${QT_VERSION_BASE} COMPONENTS SerialPort REQUIRED)
# following variable is used in qgsconfig.h
set (HAVE_QTSERIALPORT TRUE)
endif()
# Use QtGamepad optionally for input control
set (WITH_QTGAMEPAD FALSE CACHE BOOL "Determines whether QtGamepad should be tried for GPS positioning")
if (WITH_QTGAMEPAD)
find_package(${QT_VERSION_BASE} COMPONENTS Gamepad REQUIRED)
# following variable is used in qgsconfig.h
set (HAVE_QTGAMEPAD TRUE)
endif()
set (WITH_PDF4QT FALSE CACHE BOOL "Determines whether the embedded PDF4Qt library should be build for PDF and HTML to QPainter conversion")
if (WITH_PDF4QT)
set(HAVE_PDF4QT TRUE) # used in qgisconfig.h
message(STATUS "PDF4Qt enabled")
else()
message(STATUS "PDF4Qt disabled")
endif()
find_package(${QT_VERSION_BASE} COMPONENTS Core Gui Widgets Network Xml Svg Concurrent Test Sql Positioning REQUIRED)
if (BUILD_WITH_QT6)
find_package(${QT_VERSION_BASE} COMPONENTS Core5Compat REQUIRED)
endif()
if (NOT IOS)
set (DEFAULT_WITH_QTPRINTER TRUE)
else ()
set (DEFAULT_WITH_QTPRINTER FALSE)
endif()
set (WITH_QTPRINTER ${DEFAULT_WITH_QTPRINTER} CACHE BOOL "Enable QtPrinter support")
if (WITH_QTPRINTER)
find_package(${QT_VERSION_BASE} COMPONENTS PrintSupport REQUIRED)
set (HAVE_QTPRINTER TRUE)
endif()
if (WITH_QTWEBKIT)
if(BUILD_WITH_QT6)
message(FATAL_ERROR "Qt WebKit support cannot be enabled on Qt 6 builds")
endif()
find_package(Qt5WebKit REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED)
endif()
if (WITH_3D)
find_package(${QT_VERSION_BASE} COMPONENTS 3DCore 3DRender 3DInput 3DLogic 3DExtras REQUIRED)
set(HAVE_3D TRUE) # used in qgsconfig.h
endif()
set (WITH_QTWEBENGINE FALSE CACHE BOOL "Enable QtWebEngine support")
if (WITH_QTWEBENGINE)
if(BUILD_WITH_QT6)
find_package(${QT_VERSION_BASE} COMPONENTS WebEngineCore REQUIRED)
else()
# QWebEnginePage is only available in widgets module in Qt5
find_package(${QT_VERSION_BASE} COMPONENTS WebEngineCore WebEngineWidgets REQUIRED)
endif()
message(STATUS "QtWebEngine support enabled")
set(HAVE_WEBENGINE TRUE) # used in qgsconfig.h
else()
message(STATUS "QtWebEngine support DISABLED.")
set(HAVE_WEBENGINE FALSE) # used in qgsconfig.h
endif()
# get the Qt plugins directory
get_target_property(QMAKE_EXECUTABLE ${QT_VERSION_BASE}::qmake LOCATION)
execute_process(COMMAND ${QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS RESULT_VARIABLE return_code OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE DEFAULT_QT_PLUGINS_DIR )
set (QT_PLUGINS_DIR ${DEFAULT_QT_PLUGINS_DIR} CACHE STRING "Path to installation directory for Qt Plugins. Defaults to Qt native plugin directory")
if (BUILD_WITH_QT6)
message(STATUS "Found Qt version: ${Qt6Core_VERSION}")
else()
message(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")
endif()
if (WITH_QUICK)
find_package(${QT_VERSION_BASE} COMPONENTS Qml Quick REQUIRED)
if(${CMAKE_SYSTEM_NAME} MATCHES "Android" AND NOT BUILD_WITH_QT6)
find_package(${QT_VERSION_BASE} COMPONENTS AndroidExtras)
endif()
# following variable is used in qgsconfig.h
set (HAVE_QUICK TRUE)
endif()
if(WITH_QTWEBKIT)
set(OPTIONAL_QTWEBKIT ${Qt5WebKitWidgets_LIBRARIES})
endif()
# search for QScintilla2 (C++ lib)
if (WITH_GUI)
find_package(QScintilla REQUIRED)
find_package(Qwt REQUIRED)
endif()
# Password helper
if(BUILD_WITH_QT6)
find_package(Qt6Keychain CONFIG REQUIRED)
else()
find_package(Qt5Keychain CONFIG REQUIRED)
endif()
# Master password hash and authentication encryption
find_package(QCA REQUIRED)
# Check for runtime dependency of qca-ossl plugin
# REQUIRED if unit tests are to be run from build directory
if(NOT MSVC)
include(QCAMacros)
FIND_QCAOSSL_PLUGIN_CPP(ENABLE_TESTS)
endif()
if (APPLE)
# Libtasn1 is for DER-encoded PKI ASN.1 parsing/extracting workarounds
find_package(Libtasn1 REQUIRED)
endif()
if (SUPPRESS_QT_WARNINGS)
# Newer versions of UseQt4.cmake include Qt with -isystem automatically
# This can be used to force this behavior on older systems
# Can be removed as soon as Travis-CI updates from precise
include_directories(SYSTEM ${QT_INCLUDE_DIR})
endif()
# Disable automatic conversion from QString to ASCII 8-bit strings (char *)
# (Keeps code compatible with Qt/Mac/64bit)
add_definitions(-DQT_NO_CAST_TO_ASCII)
endif()
set(CMAKE_AUTOMOC ON)
# build our version of astyle
set (WITH_ASTYLE FALSE CACHE BOOL "Deprecated. Should be OFF. If you plan to contribute you should reindent with scripts/prepare_commit.sh (using 'our' astyle)")
# QML
set(QML_IMPORT_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" CACHE PATH "QML directory for QML autocomplete")
#############################################################
# testing
# whether unit tests should be build
set (ENABLE_TESTS TRUE CACHE BOOL "Build unit tests?")
if (ENABLE_TESTS)
set (PUSH_TO_CDASH FALSE CACHE BOOL "Determines whether test results should be pushed to CDASH site")
set(QT_USE_QTTEST TRUE)
enable_testing()
# Adds some testing specific build targets e.g. make Experimental
include(Dart)
# Additional test configuration options e.g. max upload size of test report
configure_file(
"${CMAKE_SOURCE_DIR}/cmake_templates/CTestCustom.cmake.in"
"${CMAKE_BINARY_DIR}/CTestCustom.cmake"
IMMEDIATE @ONLY)
if (PUSH_TO_CDASH)
configure_file(
"${CMAKE_SOURCE_DIR}/cmake_templates/CTestConfig.cmake.in"
"${CMAKE_BINARY_DIR}/CTestConfig.cmake"
IMMEDIATE @ONLY)
endif()
# For server side testing we have no X, we can use xvfb as a fake x
# sudo apt-get install xvfb
add_custom_target(check COMMAND xvfb-run --server-args=-screen\ 0\ 1024x768x24 ctest --output-on-failure)
# Define SOURCETREE fixture
add_test(NAME logGitStatus COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/chkgitstatus.sh log)
add_test(NAME checkGitStatus COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/chkgitstatus.sh check)
set_tests_properties(logGitStatus PROPERTIES FIXTURES_SETUP SOURCETREE)
set_property(TEST logGitStatus PROPERTY SKIP_RETURN_CODE 2)
set_tests_properties(checkGitStatus PROPERTIES FIXTURES_CLEANUP SOURCETREE)
set_property(TEST checkGitStatus PROPERTY SKIP_RETURN_CODE 2)
endif()
add_custom_target(tags COMMAND
cd ${CMAKE_CURRENT_SOURCE_DIR} && ctags
--c++-kinds=+p
--exclude=build
--exclude=.ci
--exclude=cmake
--exclude=cmake_templates
--exclude=debian
--exclude=doc
--exclude=.docker
--exclude=editors
--exclude=.github
--exclude=i18n
--exclude=images
--exclude=resources
--exclude=rpm
--exclude=scripts
--exclude=Testing
--exclude=tests
--exclude=.tx
--extras=+q
--fields=+iaS
--language-force=C++
--recurse=yes
)
if (WITH_CORE)
# ModelTest
set(ENABLE_MODELTEST FALSE CACHE BOOL "Enable QT ModelTest (not for production)")
endif()
#############################################################
# enable warnings
if (PEDANTIC)
message (STATUS "Pedantic compiler settings enabled")
if(MSVC)
set(_warnings "")
if (NOT USING_NMAKE AND NOT USING_NINJA)
set(_warnings "${_warnings} /W4" )
endif()
# disable warnings
set(_warnings "${_warnings} /wd4091 ") # 'typedef': ignored on left of '' when no variable is declared (occurs in MS DbgHelp.h header)
set(_warnings "${_warnings} /wd4100 ") # unused formal parameters
set(_warnings "${_warnings} /wd4127 ") # constant conditional expressions (used in Qt template classes)
set(_warnings "${_warnings} /wd4190 ") # 'identifier' has C-linkage specified, but returns UDT 'identifier2' which is incompatible with C
set(_warnings "${_warnings} /wd4231 ") # nonstandard extension used : 'identifier' before template explicit instantiation (used in Qt template classes)
set(_warnings "${_warnings} /wd4244 ") # conversion from '...' to '...' possible loss of data
set(_warnings "${_warnings} /wd4251 ") # needs to have dll-interface to be used by clients of class (occurs in Qt template classes)
set(_warnings "${_warnings} /wd4267 ") # 'argument': conversion from 'size_t' to 'int', possible loss of data
set(_warnings "${_warnings} /wd4275 ") # non dll-interface class '...' used as base for dll-interface class '...'
set(_warnings "${_warnings} /wd4290 ") # c++ exception specification ignored except to indicate a function is not __declspec(nothrow) (occurs in sip generated bindings)
set(_warnings "${_warnings} /wd4456 ") # declaration of '...' hides previous local declaration
set(_warnings "${_warnings} /wd4457 ") # declaration of '...' hides a function parameter
set(_warnings "${_warnings} /wd4458 ") # declaration of '...' hides class member
set(_warnings "${_warnings} /wd4505 ") # unreferenced local function has been removed (QgsRasterDataProvider::extent)
set(_warnings "${_warnings} /wd4510 ") # default constructor could not be generated (sqlite3_index_info, QMap)
set(_warnings "${_warnings} /wd4512 ") # assignment operator could not be generated (sqlite3_index_info)
set(_warnings "${_warnings} /wd4610 ") # user defined constructor required (sqlite3_index_info)
set(_warnings "${_warnings} /wd4706 ") # assignment within conditional expression (pal)
set(_warnings "${_warnings} /wd4714 ") # function '...' marked as __forceinline not inlined (QString::toLower/toUpper/trimmed)
set(_warnings "${_warnings} /wd4800 ") # 'int' : forcing value to bool 'true' or 'false' (performance warning)
set(_warnings "${_warnings} /wd4996 ") # '...': was declared deprecated (unfortunately triggered when implementing deprecated interfaces even when it is deprecated too)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_warnings}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_warnings}")
else()
# add warnings via flags (not as definitions as on Mac -Wall can not be overridden per language )
set(_warnings "-Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing")
set(WERROR FALSE CACHE BOOL "Treat build warnings as errors.")
if (WERROR)
set(_warnings "${_warnings} -Werror")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_warnings}")
# c++ only warnings
set(_warnings "${_warnings} -Wnon-virtual-dtor")
# unavoidable - we can't avoid these, as older, supported compilers do not support removing the redundant move
set(_warnings "${_warnings} -Wno-redundant-move")
# disable misleading-indentation warning -- it's slow to parse the sip files and not needed since we have the automated code styling rules
set(_warnings "${_warnings} -Wno-misleading-indentation")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.9.999)
# heaps of these thrown by Qt headers at the moment (sep 2019)
set(_warnings "${_warnings} -Wno-deprecated-copy")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_warnings}")
# Qt produces lots of warnings with strict aliasing (as of Qt 4.4.0 & GCC 4.3)
# There are redundant declarations in Qt and GDAL
# add_definitions( -fstrict-aliasing -Wstrict-aliasing=1 -Wredundant-decls )
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wreturn-type-c-linkage -Woverloaded-virtual -Wimplicit-fallthrough")
endif()
# add any extra CXXFLAGS flags set by user. can be -D CXX_EXTRA_FLAGS or environment variable
# command line -D option overrides environment variable
# e.g. useful for suppressing transient upstream warnings in dependencies, like Qt
set(CXX_EXTRA_FLAGS "" CACHE STRING "Additional appended CXXFLAGS")
if ("${CXX_EXTRA_FLAGS}" STREQUAL "" AND DEFINED $ENV{CXX_EXTRA_FLAGS})
set(CXX_EXTRA_FLAGS "$ENV{CXX_EXTRA_FLAGS}")
endif()
if (NOT "${CXX_EXTRA_FLAGS}" STREQUAL "")
message (STATUS "Appending CXX_EXTRA_FLAGS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_EXTRA_FLAGS}")
endif()
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Qunused-arguments")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Qunused-arguments")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Qunused-arguments")
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
# spatialite crashes on ppc - see bugs.debian.org/603986
add_definitions( -fno-strict-aliasing )
endif()
if (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
message (STATUS "Debug output enabled")
set(QGISDEBUG TRUE)
else()
set(QGISDEBUG FALSE)
endif()
set (AGGRESSIVE_SAFE_MODE FALSE CACHE BOOL "Forces a aggressive safe mode where issues like unsafe thread access will resort in fatal exceptions")
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /std:c++17 /permissive-")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /std:c++17 /permissive-")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# disable macros that offend std::numeric_limits<T>::min()/max()
add_definitions(-DNOMINMAX)
endif()
# Prevent build when Qt api deprecated before this Qt version is used:
add_definitions(-DQT_DEPRECATED_WARNINGS)
# Unfortunately Qwt uses deprecated QString::null in headers, preventing this being raised above 5.8
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050800)
# For fast string concatenation
add_definitions(-DQT_USE_QSTRINGBUILDER)
set(WITH_GSL TRUE CACHE BOOL "Determines whether GSL library should be used")
if (WITH_ANALYSIS AND WITH_GSL)
find_package(GSL REQUIRED)
set(HAVE_GSL TRUE)
set(HAVE_GEOREFERENCER TRUE)
endif()
if(ENABLE_COVERAGE)
include("cmake/modules/coverage/CodeCoverage.cmake")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage")
SETUP_TARGET_FOR_COVERAGE(qgis_coverage ctest coverage)
endif()
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
include("cmake/modules/linker.cmake")
endif()
#############################################################
# platform specific stuff
if (WITH_CORE)
if (WIN32)
set (DEFAULT_LIB_SUBDIR lib)
set (DEFAULT_LIBEXEC_SUBDIR .)
set (DEFAULT_DATA_SUBDIR .)
set (DEFAULT_PLUGIN_SUBDIR plugins)
set (DEFAULT_INCLUDE_SUBDIR include)
set (DEFAULT_QML_SUBDIR qml)
set (DEFAULT_SERVER_MODULE_SUBDIR server)
if (MSVC)
set (DEFAULT_BIN_SUBDIR bin)
set (DEFAULT_CGIBIN_SUBDIR bin)
# put all the build products into a single directory
# under build (doesn't affect install target) to make for
# easier debugging.
# Turn on defines for non standard maths stuff
add_definitions(-D_USE_MATH_DEFINES)
# Turn off deprecation warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
if (INSTALL_DEPS)
install(DIRECTORY ${INSTALL_DEPS} DESTINATION .)
endif()
else()
set (DEFAULT_BIN_SUBDIR .)
set (DEFAULT_CGIBIN_SUBDIR .)
endif()
else()
if(APPLE)
set(QGIS_MACAPP_FRAMEWORK TRUE CACHE BOOL "Build as a framework on OSX")
endif()
if (APPLE AND QGIS_MACAPP_FRAMEWORK)
if (POLICY CMP0042) # in CMake 3.0.0+
set (CMAKE_MACOSX_RPATH OFF) # otherwise ON by default
endif()
if (POLICY CMP0068) # in CMake 3.9.0+
cmake_policy(SET CMP0068 NEW)
endif()
# for Mac OS X, everything is put inside an application bundle
# save the root install prefix for the app later
set (QGIS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set (QGIS_MACAPP_PREFIX ${CMAKE_INSTALL_PREFIX}/${QGIS_APP_NAME}.app/Contents)
# common prefix for components, let cmake handle it
set (CMAKE_INSTALL_PREFIX ${QGIS_MACAPP_PREFIX}/MacOS)
# 5 bundling levels, each includes previous
# -1 nothing
# 0 fixup the library paths for all QGIS libraries with @loader_path
# 1 Qt frameworks
# 2 non-system libraries, "standard"
# 3 non-system frameworks, "standalone"
set (QGIS_MACAPP_BUNDLE 1 CACHE STRING "What to bundle into app package")
set (QGIS_MACAPP_BUNDLE_USER "" CACHE STRING "Path to user bundling script")
set (QGIS_MACAPP_INSTALL_DEV FALSE CACHE BOOL "Install developer frameworks")
set (QGIS_MACAPP_DEV_PREFIX "/Library/Frameworks" CACHE STRING "Path to install developer frameworks")
set (DEFAULT_BIN_SUBDIR bin)
set (QGIS_BIN_SUBDIR_REV ..)
set (DEFAULT_CGIBIN_SUBDIR fcgi-bin)
set (QGIS_CGIBIN_SUBDIR_REV ..)
set (DEFAULT_LIB_SUBDIR lib)
set (QGIS_LIB_SUBDIR_REV ..)
set (QGIS_FW_SUBDIR ../Frameworks)
set (QGIS_FW_SUBDIR_REV ../MacOS)
set (DEFAULT_DATA_SUBDIR ../Resources)
set (QGIS_DATA_SUBDIR_REV ../MacOS)
set (DEFAULT_LIBEXEC_SUBDIR lib/qgis)
set (QGIS_LIBEXEC_SUBDIR_REV ../..)
set (DEFAULT_PLUGIN_SUBDIR ../PlugIns/qgis)
set (QGIS_PLUGIN_SUBDIR_REV ../../MacOS)
set (DEFAULT_INCLUDE_SUBDIR include/qgis)
set (DEFAULT_QML_SUBDIR qml)
# Set server moodules path to DEFAULT_LIBEXEC_SUBDIR+'/server'
set (DEFAULT_SERVER_MODULE_SUBDIR ${DEFAULT_LIBEXEC_SUBDIR}/server)
# path for framework references when running from build directory
# changed later to reference in-app resources upon install
set (CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
# recent cmakes force SDKs, recent SDKs don't have user symlinks
# need to find non-system frameworks
# cmake bug #0007250 - CMAKE_SHARED_LINKER_FLAGS ignored when creating
# a framework, so these need to be manually handled with LINK_FLAGS options
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -F/Library/Frameworks")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -F/Library/Frameworks")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -F/Library/Frameworks")
else()
# UNIX
set (DEFAULT_BIN_SUBDIR bin)
set (DEFAULT_CGIBIN_SUBDIR bin)
set (DEFAULT_LIB_SUBDIR lib${LIB_SUFFIX})
set (DEFAULT_DATA_SUBDIR share/qgis)
set (DEFAULT_LIBEXEC_SUBDIR lib${LIB_SUFFIX}/qgis)
set (DEFAULT_PLUGIN_SUBDIR lib${LIB_SUFFIX}/qgis/plugins)
set (DEFAULT_INCLUDE_SUBDIR include/qgis)
set (DEFAULT_QML_SUBDIR qml)
set (DEFAULT_SERVER_MODULE_SUBDIR ${DEFAULT_LIBEXEC_SUBDIR}/server)
# QGIS_MACAPP_FRAMEWORK=FALSE
if(APPLE)
set (QGIS_MACAPP_BUNDLE -1)
set (CMAKE_FRAMEWORK FALSE)
set (QGIS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
endif()
endif()
endif()
if (ANDROID)
set (DEFAULT_PLUGIN_SUBDIR lib)
string(REPLACE "<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME>" "" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
endif()
#assume we have escaped compiler directives
#eventually we want to change this to new
#since we don't need to jump through so many
#hoops to escape compiler directives then
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
if(NOT "${CMAKE_VERSION}" VERSION_LESS "3.3")
cmake_policy(SET CMP0063 NEW)
endif()
if(MSVC)
cmake_policy(SET CMP0020 NEW)
endif()
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
endif() #"${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
include(GenerateExportHeader)
set (WITH_CLAZY FALSE CACHE BOOL "Determines whether Clazy checks should be enabled")
mark_as_advanced (WITH_CLAZY)
if (WITH_CLAZY)
set(CMAKE_CXX_BASE_FLAGS "${CMAKE_CXX_FLAGS}")
# qcolor-from-literal crashes clang with clazy 1.11
set(CLAZY_BASE_CHECKS "connect-3arg-lambda,lambda-unique-connection,empty-qstringliteral,fully-qualified-moc-types,lowercase-qml-type-name,qfileinfo-exists,qmap-with-pointer-key,unused-non-trivial-variable,overridden-signal,qdeleteall,qstring-left,skipped-base-method,isempty-vs-count,missing-qobject-macro,container-anti-pattern")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_BASE_FLAGS} -Xclang -plugin-arg-clazy -Xclang ${CLAZY_BASE_CHECKS}")
if (WERROR AND NOT ${QGISDEBUG})
message(FATAL_ERROR "Don't activate both WERROR and ADD_CLAZY_CHECKS in Release mode, you will get many false positive errors")
endif()
if (WERROR AND ("$ENV{CLAZY_IGNORE_DIRS}" STREQUAL ""))
message(WARNING "WERROR and ADD_CLAZY_CHECKS are activated. To avoid unwanted Clazy error, please set the CLAZY_IGNORE_DIRS environment variable like this : \nexport CLAZY_IGNORE_DIRS=\"(.*/external/.*)|(.*sip_.*part.*)\"")
endif()
endif()
endif()
#############################################################
# user-changeable settings which can be used to customize
# layout of QGIS installation
# (default values are platform-specific)
set (QGIS_BIN_SUBDIR ${DEFAULT_BIN_SUBDIR} CACHE STRING "Subdirectory where executables will be installed")
set (QGIS_CGIBIN_SUBDIR ${DEFAULT_CGIBIN_SUBDIR} CACHE STRING "Subdirectory where CGI executables will be installed")
set (QGIS_LIB_SUBDIR ${DEFAULT_LIB_SUBDIR} CACHE STRING "Subdirectory where libraries will be installed")
set (QGIS_LIBEXEC_SUBDIR ${DEFAULT_LIBEXEC_SUBDIR} CACHE STRING "Subdirectory where private executables will be installed")
set (QGIS_DATA_SUBDIR ${DEFAULT_DATA_SUBDIR} CACHE STRING "Subdirectory where QGIS data will be installed")