forked from OpenCPN/OpenCPN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
2592 lines (2301 loc) · 76.4 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
# ---------------------------------------------------------------------------
# Author: Dave Register DEB
# config from: antonm - Anton Martchukov <[email protected]>
# Update: sethdart (Jean-Eudes Onfray)
# with parts from balp (Anders Arnholm)
# ***************************************************************************
# - Copyright (C) 2010 by David S. Register *
# - This program is free software; you can redistribute it and/or modify *
# - it under the terms of the GNU General Public License as published by *
# - the Free Software Foundation; either version 2 of the License, or *
# - (at your option) any later version. *
# - *
# - This program is distributed in the hope that it will be useful, *
# - but WITHOUT ANY WARRANTY; without even the implied warranty of *
# - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# - GNU General Public License for more details. *
# - *
# - You should have received a copy of the GNU General Public License *
# - along with this program; if not, write to the *
# - Free Software Foundation, Inc., *
# - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
# ***************************************************************************
#[[
Configuring opencpn
===================
Help:
Opencpn configuration options can be listed using
cmake -LH | grep -B1 OCPN_
Renamed options:
From version TBD all OpenCPN configuration options have a OCPN_ prefix
Many older options are renamed, some examples:
ENABLE_SYSTEM_CMD_SOUND -> OCPN_ENABLE_SYSTEM_CMD_SOUND
USE_BUNDLED_LIBS -> OCPN_USE_BUNDLED_LIBS
BUNDLE_DOCS -> OCPN_BUNDLE_DOCS
BUNDLE_TCDATA -> OCPN_BUNDLE_TCDATA
BUNDLE_GSHHS ->OCPN_BUNDLE_GSHHS
ENABLE_PORTAUDIO -> OCPN_ENABLE_PORTAUDIO
USE_GARMINHOST -> OCPN_USE_GARMINHOST
ENABLE_CPPCHECK -> OCPN_ENABLE_CPPCHECK
Installation paths:
- Since TBD OpenCPN supports the GNU install paths, see
https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html
- Use CMAKE_INSTALL_LIBDIR to change the base directory for plugins;
defaults to library location on most platforms, but is 'lib' on
Debian.
Sound:
- Without options, defaults to MswSound on Windows, PortAudioSound
on Linux and WxSound on OSX.
- With OCPN_ENABLE_SYSTEM_CMD_SOUND enabled SystemCmdSound will be the
backend used on all platforms.
- With OCPN_ENABLE_PORTAUDIO activated PortAudioSound can be used on all
platforms if the necessary headers and libraries are available.
- OCPN_ENABLE_SNDFILE adds libsndfile support to portaudio. libsndfile
supports a wide range of audio formats instead of .wav only.
Bundled libraries:
- OCPN_USE_BUNDLED_LIBS forces use of external/bundled libraries including
wxsvg and liblz4. It's either:
- ON => use all bundled libraries.
- OFF => Always use external (system) libraries if available.
- A comma-separated list of libraries where the bundled variant
should be used. For other libraries, system libs is preferred.
- If found, the system tinyxml library is used unconditionally.
Documentation:
- OCPN_BUNDLE_DOCS governs inclusion of docs in the package.
- Note that documentation is available in a separate download from
opencpn website.
Tidal/current and GSHHS wallpaper
- OCPN_BUNDLE_TCDATA (boolean) includes tide/current harmonics data in
package.
- BUNDLE_GSHHS (NONE,MIN,[CRUDE],LOW,INTERMEDIATE,HIGH,FULL) governs the
wallpaper map used as last resort and world overview.
To build for android, use something like:
$cmake -DUSE_GARMINHOST=OFF
-D_wx_selected_config=androideabi-qt
-DCMAKE_TOOLCHAIN_FILE=../buildandroid/build_android.cmake
-DwxQt_Build=build_android_53
-DwxQt_Base=/home/dsr/Projects/wxqt/wxWidgets
-DQt_Base /home/dsr/Qt/5.3)
..
Silent/Verbose builds:
cmake's handling of these issues is underwhelming. On most platforms the
builds are by default verbose. Use 'cmake OCPN_VERBOSE=OFF' to make
a silent build. The OCPN_VERBOSE value can be overridden using
'make VERBOSE=1' or 'make -s'
#]]
#[[
TODO:
- Profiling opt
- test with Win & OSX
USE_GLU_TESS
USE_GLU_DLL
I also find it deficient in some areas. For instance, I cannot make it
output a VS project with certain compile switches set as desired,
namely /MT vs /MD. This means I must manually set this and other compiler
options after the CMake step. Sometimes I forget. Grrr...
set /MT for Release build, and /MTd for debug.
Is this still problem? If so, generator expressions seem to be the solution.
#]]
cmake_minimum_required(VERSION 3.1.1)
cmake_policy(SET CMP0043 NEW)
cmake_policy(SET CMP0025 NEW)
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif ()
# Prefer libGL.so to libOpenGL.so, see CMP0072
set(OpenGL_GL_PREFERENCE "LEGACY")
project(OpenCPN)
if (NOT DEFINED OCPN_VERBOSE OR OCPN_VERBOSE)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif ()
message(STATUS "cmake version: ${CMAKE_VERSION}")
if (APPLE)
set(PACKAGE_NAME OpenCPN)
else (APPLE)
set(PACKAGE_NAME opencpn)
endif (APPLE)
# Locations where cmake looks for cmake modules.
set(
CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/build
${CMAKE_SOURCE_DIR}/
${CMAKE_SOURCE_DIR}/cmake
)
include(FindPkgConfig)
include(CMakeDependentOption)
# Per default, use CMAKE_INSTALL_LIBDIR=lib on Debian (and derivatives)
# to avoid multilib plugin paths. After all, we do not install any
# "real" libraries.
if (EXISTS /etc/debian_version AND NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif ()
include(GNUInstallDirs)
#
# Options
#
macro (BUNDLE_DOCS_OPT onoff)
option(OCPN_BUNDLE_DOCS "Include documentation in package" ${onoff})
endmacro (BUNDLE_DOCS_OPT)
macro (BUNDLE_TCDATA_OPT onoff)
option(
OCPN_BUNDLE_TCDATA "Include tide/current harmonics data in package"
${onoff}
)
endmacro (BUNDLE_TCDATA_OPT)
macro (BUNDLE_GSHHS_OPT value)
set(
OCPN_BUNDLE_GSHHS "${value}"
CACHE
STRING
"Include GSHHS wallpaper map in package (NONE,MIN,[CRUDE],LOW,INTERMEDIATE,HIGH,FULL)"
)
endmacro (BUNDLE_GSHHS_OPT)
# If on Windows or Apple, build the monolithic package, to override use a non-
# sense values from the commandline (due to cmake inability to distinguish
# between not set and set to FALSE): cmake -DOCPN_BUNDLE_DOCS=BLAH
# -DOCPN_BUNDLE_TCDATA=BLAH -DOCPN_BUNDLE_GSHHS=BLAH ..
if (APPLE OR WIN32)
bundle_docs_opt("ON")
bundle_tcdata_opt("ON")
bundle_gshhs_opt("CRUDE")
else (APPLE OR WIN32)
bundle_docs_opt("OFF")
bundle_tcdata_opt("OFF")
bundle_gshhs_opt("NONE")
endif (APPLE OR WIN32)
option(OCPN_VERBOSE "Make verbose builds" ON)
set(OCPN_PACKAGE_RELEASE "1" CACHE STRING "Package release number")
option(OCPN_USE_GL "Enable OpenGL support" ON)
if (MSVC OR (NOT APPLE AND NOT QT_ANDROID AND NOT MINGW))
option(OCPN_USE_CRASHREPORT "Enable crash reporting" ON)
else ()
set(OCPN_USE_CRASHREPORT FALSE)
endif ()
if (NOT WIN32 AND NOT APPLE)
set(PA_DEFAULT "ON")
endif ()
option(
OCPN_ENABLE_PORTAUDIO "Use portaudio(3) to play sounds if available"
${PA_DEFAULT}
)
cmake_dependent_option(
OCPN_ENABLE_SNDFILE
"Use libsndfile for portaudio if available."
ON
"OCPN_ENABLE_PORTAUDIO"
ON
)
option(OCPN_USE_GARMINHOST "Enable Garmin Host Mode support" ON)
set(
OCPN_WXWIDGETS_FORCE_VERSION
CACHE STRING "Force usage of a specific wxWidgets version."
)
set(
OCPN_WXWIDGETS_OPTIONS
CACHE STRING "Additional flags to wxWidgets_CONFIG_OPTIONS"
)
if (WIN32 AND NOT UNIX)
option(OCPN_BUNDLE_WXDLLS "Bundle the prebuilt WX DLLs" ON)
option(OCPN_BUNDLE_VCDLLS "Bundle the VC redistributable libraries" ON)
endif ()
if (CMAKE_VERSION VERSION_GREATER 3.4)
option(OCPN_ENABLE_CLANG_TIDY "Add clang-tidy automatically to builds" OFF)
set(ENABLE_SANITIZER "none" CACHE STRING "Add clang sanitizer to the build")
endif ()
if (CMAKE_VERSION VERSION_GREATER 3.9)
option(OCPN_ENABLE_CPPCHECK "Add cppcheck automatically to builds" OFF)
endif ()
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(
CMAKE_BUILD_TYPE RelWithDebInfo
CACHE
STRING
"Choose type of build: None Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
if (APPLE)
option(OCPN_USE_LIBCPP "Use libc++ instead of libstdc++ on macOS" ON)
endif ()
option(OCPN_USE_EXTERN_CURL "Use external libcurl" OFF)
if (NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${TENTATIVE_PREFIX})
endif (NOT CMAKE_INSTALL_PREFIX)
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(BUNDLED_LIBS_DEFAULT "ON")
else ()
set(BUNDLED_LIBS_DEFAULT "OFF")
endif ()
set(
OCPN_USE_BUNDLED_LIBS ${BUNDLED_LIBS_DEFAULT}
CACHE
STRING
"Use bundled libraries instead of system's [ON, OFF or comma-sep list]"
)
option(OCPN_USE_NEWSERIAL "Use new serial communication implementation" ON)
option(OCPN_USE_CURL "Use Curl libraries" ON)
option(OCPN_USE_SVG "Use SVG graphics" ON)
option(OCPN_USE_LZMA "Use LZMA for chart compression" ON)
option(OCPN_CI_BUILD "Use CI build versioning rules" OFF)
option(
OCPN_ENABLE_SYSTEM_CMD_SOUND
"Use aplay(1), afplay(1) etc. to play sounds if available" ON
)
# Check if a given library should use the bundled source
macro (USE_BUNDLED_LIB _result library)
if ("${OCPN_USE_BUNDLED_LIBS}" STREQUAL "")
set(OCPN_USE_BUNDLED_LIBS "ON")
endif ()
if (${OCPN_USE_BUNDLED_LIBS} STREQUAL "OFF")
set(${_result} "OFF")
elseif (${OCPN_USE_BUNDLED_LIBS} STREQUAL "ON")
set(${_result} "ON")
elseif (",${OCPN_USE_BUNDLED_LIBS}," MATCHES ",${library},")
set(${_result} "ON")
else ()
set(${_result} "OFF")
endif ()
endmacro (USE_BUNDLED_LIB)
#
# Language, compiler and static checkers setup
#
include(GetArch)
getarch()
message(STATUS "*** Build Architecture is ${ARCH}")
set(CMAKE_CXX_STANDARD 11)
message(STATUS "Setting C++11 standard via cmake standard mechanism")
if (NOT MSVC)
set(OBJ_VISIBILITY "-fvisibility=hidden")
endif ()
if (CMAKE_VERSION VERSION_GREATER 3.4)
if (OCPN_ENABLE_CLANG_TIDY)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
PATHS /usr/local/opt/llvm/bin
)
if (CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
# For more, see http://clang.llvm.org/extra/clang-tidy/
# set(CLANG_TIDY_CHECKS "-*,modernize-*")
set(CLANG_TIDY_CHECKS "-*,performance-*")
set(
CMAKE_CXX_CLANG_TIDY
"${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*'"
CACHE STRING ""
FORCE
)
else ()
message(AUTHOR_WARNING "clang-tidy not found!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
endif ()
endif ()
endif ()
if (CMAKE_VERSION VERSION_GREATER 3.4)
# Add support for address etc sanitizers, part 1/2 (other half after
# ADD_EXECUTABLE)
set_property(
CACHE ENABLE_SANITIZER
PROPERTY
STRINGS
none
address
memory
thread
undefined
)
if (NOT "${ENABLE_SANITIZER}" MATCHES "none")
add_compile_options(-fsanitize=${ENABLE_SANITIZER})
endif ()
endif ()
if (CMAKE_VERSION VERSION_GREATER 3.9)
if (OCPN_ENABLE_CPPCHECK)
find_program(CPPCHECK_EXECUTABLE NAMES "cppcheck")
set(CMAKE_CXX_CPPCHECK ${CPPCHECK_EXECUTABLE})
endif ()
endif ()
message(STATUS "Default compiler options:")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL: ${CMAKE_CXX_FLAGS_MINSIZEREL}")
message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
message(
STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
)
# ADD_COMPILE_OPTIONS( "-Wall" "-ansi" "-pedantic" "-Wno-variadic-macros" )
# TODO: Should we use -fno-stack-protector IF NOT DEBUGGING CFLAGS="-O2
# -march=native"
if (NOT WIN32 AND NOT APPLE)
add_compile_options(
"-Wall"
"-Wno-unused"
"-fexceptions"
"-rdynamic"
"-fno-strict-aliasing"
)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_options("-O0")
endif ()
add_compile_options("-Wno-deprecated-declarations")
# TODO: Enable deprecation warnings again after the 5.0.0 cycle
add_definitions(" -DPREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\"")
# profiling with gprof ADD_COMPILE_OPTIONS( -pg ) SET(CMAKE_EXE_LINKER_FLAGS
# -pg) profiling with gcov ADD_COMPILE_OPTIONS( "-fprofile-arcs -ftest-
# coverage" ) SET(EXTRA_LIBS ${EXTRA_LIBS} "gcov")
endif (NOT WIN32 AND NOT APPLE)
if (MINGW)
add_compile_options(
"-Wall"
"-Wno-unused"
"-Wno-cpp"
"-fexceptions"
"-fno-strict-aliasing"
)
add_definitions("-DPSAPI_VERSION=1")
add_definitions("-DUNICODE" "-D_UNICODE")
endif (MINGW)
if (APPLE)
add_compile_options(
"-Wall"
"-Wno-unused"
"-fexceptions"
"-Wno-overloaded-virtual"
"-fno-strict-aliasing"
"-Wno-deprecated"
"-Wno-deprecated-declarations"
"-Wno-unknown-pragmas"
"-D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_"
)
endif (APPLE)
if (APPLE)
set(CMAKE_C_FLAGS "-O2 -arch ${ARCH}")
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -arch ${ARCH}")
set(CMAKE_C_FLAGS_MINSIZEREL "-O2 -arch ${ARCH}")
set(CMAKE_C_FLAGS_RELEASE "-O3 -arch ${ARCH}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O3 -arch ${ARCH}")
if (OCPN_USE_LIBCPP)
set(OCPN_LIBCPP "-stdlib=libc++")
endif (OCPN_USE_LIBCPP)
set(CMAKE_CXX_FLAGS "-O2 ${OCPN_LIBCPP} -arch ${ARCH}")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 ${OCPN_LIBCPP} -arch ${ARCH}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-O2 ${OCPN_LIBCPP} -arch ${ARCH}")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 ${OCPN_LIBCPP} -arch ${ARCH}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3 ${OCPN_LIBCPP} -arch ${ARCH}")
set(
CMAKE_EXE_LINKER_FLAGS
"-O2 ${OCPN_LIBCPP} -arch ${ARCH} ${CMAKE_EXE_LINKER_FLAGS}"
)
set(CMAKE_SHARED_LINKER_FLAGS "-O2 ${OCPN_LIBCPP} -arch ${ARCH}")
set(CMAKE_MODULE_LINKER_FLAGS "-O2 ${OCPN_LIBCPP} -arch ${ARCH}")
endif (APPLE)
if (MSVC)
add_definitions(-D__MSVC__)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-DPSAPI_VERSION=1)
endif (MSVC)
if (MSVC)
set(CMAKE_C_FLAGS_DEBUG "/MP /MDd /Ob0 /Od /D_DEBUG /Zi /RTC1")
set(CMAKE_C_FLAGS_MINSIZEREL "/MP /MD /O1 /Ob1 /D NDEBUG")
set(CMAKE_C_FLAGS_RELEASE "/MP /MD /O2 /Ob2 /D NDEBUG /Zi /wd8051 /wd4068")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MP /MD /O2 /Ob1 /D NDEBUG /Zi")
set(CMAKE_CXX_FLAGS_DEBUG "/MP /MDd /Ob0 /Od /D_DEBUG /Zi /RTC1 /EHa")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/MP /MD /O1 /Ob1 /D NDEBUG /EHa")
set(CMAKE_CXX_FLAGS_RELEASE "/MP /MD /O2 /Ob2 /D NDEBUG /Zi /EHa")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MP /MD /O2 /Ob1 /D NDEBUG /Zi /EHa")
set(CMAKE_EXE_LINKER_FLAGS "/DEBUG ${CMAKE_EXE_LINKER_FLAGS}")
endif (MSVC)
if (QT_ANDROID)
set(CMAKE_BUILD_TYPE Debug)
add_definitions(-D__WXQT__)
add_definitions(-DOCPN_USE_WRAPPER)
add_definitions(-D__OCPN__ANDROID__)
add_definitions(-DANDROID)
set(CMAKE_CXX_FLAGS "-pthread -fPIC -s -O2")
endif (QT_ANDROID)
set(
LINUX_LIB_PATHS
/usr/local/lib
/usr/local/lib64
/usr/lib/i386-linux-gnu
/usr/lib/x86_64-linux-gnu
/usr/lib
/usr/lib64
)
set(PREFIX_BIN ${CMAKE_INSTALL_BINDIR})
set(PREFIX_INCLUDE ${CMAKE_INSTALL_INCLUDEDIR})
set(PREFIX_DATA ${CMAKE_INSTALL_DATADIR})
set(PREFIX_PKGDATA ${CMAKE_INSTALL_DATADIR}/${PACKAGE_NAME})
set(PREFIX_LIB "${CMAKE_INSTALL_FULL_LIBDIR}")
#
# Version handling
#
include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
if (OCPN_CI_BUILD)
include(Utils)
today(DATE)
commit_id(COMMIT)
set(VERSION_TAIL "+${COMMIT}")
set(VERSION_DATE "${DATE}")
endif (OCPN_CI_BUILD)
set(
PACKAGE_VERSION
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_TAIL}"
)
# Detect the Apple Version of the build machine
if (APPLE)
exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
string(
REGEX
MATCH
"[0-9]+"
DARWIN_VERSION
${DARWIN_VERSION}
)
message(STATUS "*** Building on DARWIN_VERSION=${DARWIN_VERSION}")
if (DARWIN_VERSION GREATER 11)
set(APPLE_MODERN 1 INTERNAL)
endif (DARWIN_VERSION GREATER 11)
endif (APPLE)
message(STATUS "*** Staging to build ${PACKAGE_NAME} ${PACKAGE_VERSION} ***")
#
# Bundled data: docs, tcdata, gshhs
#
if (NOT WIN32 AND NOT APPLE AND NOT QT_ANDROID)
option(OCPN_FORCE_GTK3 "Force the build to use GTK3" OFF)
endif ()
if (OCPN_BUNDLE_DOCS MATCHES "ON")
message(STATUS "*** Package will include documentation ***")
else (OCPN_BUNDLE_DOCS MATCHES "ON")
message(STATUS "*** Package will NOT include documentation ***")
endif (OCPN_BUNDLE_DOCS MATCHES "ON")
#
# Linux: set up GTK (wxWidgets prerequisite).
#
if (NOT WIN32 AND NOT APPLE AND NOT QT_ANDROID)
include(OcpnFindGtk)
endif ()
# set a build flag for arm architecture, to catch any rPI runtime changes
# required
if (ARCH MATCHES "arm*" AND (NOT QT_ANDROID))
add_definitions(-DocpnARM)
endif (ARCH MATCHES "arm*" AND (NOT QT_ANDROID))
if (DEFINED _wx_selected_config)
message(STATUS "selected config ${_wx_selected_config}")
if (_wx_selected_config MATCHES "androideabi-qt")
message(STATUS "Building for wxQt-Android")
message(STATUS "Qt_Base: " ${Qt_Base})
message(
STATUS
"wxQt_Base/Build: "
${wxQt_Base}
"/"
${wxQt_Build}
)
set(QT_ANDROID "ON")
endif (_wx_selected_config MATCHES "androideabi-qt")
endif (DEFINED _wx_selected_config)
if ((_wx_selected_config MATCHES "qt-armv7"))
set(wxWidgets_FIND_COMPONENTS base core xml html adv aui)
else ()
set(wxWidgets_FIND_COMPONENTS net xml html adv aui core base webview)
endif ()
if (OPENGLES_FOUND)
set(wxWidgets_FIND_COMPONENTS ${wxWidgets_FIND_COMPONENTS} gl)
endif ()
if ((NOT OPENGLES_FOUND) AND (NOT QT_ANDROID))
if (OCPN_USE_GL)
find_package(OpenGL)
else (OCPN_USE_GL)
message(STATUS "OpenGL disabled by option USE_GL...")
endif (OCPN_USE_GL)
if (OPENGL_FOUND)
set(wxWidgets_FIND_COMPONENTS gl ${wxWidgets_FIND_COMPONENTS})
include_directories(${OPENGL_INCLUDE_DIR})
message(STATUS "Found OpenGL....")
message(STATUS " GL Lib: " ${OPENGL_LIBRARIES})
message(STATUS " GL Include: " ${OPENGL_INCLUDE_DIR})
add_definitions(-DocpnUSE_GL)
# We need to remove GLU from the OPENGL_LIBRARIES list
foreach (_currentLibFile ${OPENGL_LIBRARIES})
# MESSAGE (STATUS " Lib File: " ${_currentLibFile})
set(UCNAME ${_currentLibFile})
string(TOUPPER ${UCNAME} UCNAME)
if (NOT ${UCNAME} MATCHES "(.*)GLU(.*)")
set(
REVISED_OPENGL_LIBRARIES ${_currentLibFile}
${REVISED_OPENGL_LIBRARIES}
)
endif ()
endforeach (_currentLibFile)
set(OPENGL_LIBRARIES ${REVISED_OPENGL_LIBRARIES})
message(STATUS " Revised GL Lib: " ${OPENGL_LIBRARIES})
else (OPENGL_FOUND)
message(STATUS "OpenGL not found...")
endif (OPENGL_FOUND)
endif ()
if (NOT QT_ANDROID)
# Find wxWidgets here, and the setting get inherited by all plugins. These
# options can be used to set the linux widgets build type
set(wxWidgets_USE_DEBUG OFF)
set(wxWidgets_USE_UNICODE ON)
set(wxWidgets_USE_UNIVERSAL OFF)
set(wxWidgets_USE_STATIC OFF)
if (WXWIDGETS_FORCE_VERSION)
set(wxWidgets_CONFIG_OPTIONS --version=${WXWIDGETS_FORCE_VERSION})
endif ()
if (MSVC)
# Exclude wxexpat.lib, since we use our own version. Other things are
# excluded as well, but we don't need them
set(wxWidgets_EXCLUDE_COMMON_LIBRARIES TRUE)
endif (MSVC)
if (GTK2_FOUND)
set(wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} --toolkit=gtk2)
elseif (GTK3_FOUND)
set(wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} --toolkit=gtk3)
endif ()
find_package(wxWidgets COMPONENTS ${wxWidgets_FIND_COMPONENTS})
if (wxWidgets_FOUND)
message(STATUS "Found wxWidgets webview add-on")
add_definitions(-DwxUSE_WEBVIEW=1 -DHAVE_WEBVIEW)
else ()
add_definitions(-DwxUSE_WEBVIEW=0)
list(REMOVE_ITEM wxWidgets_FIND_COMPONENTS webview)
message(STATUS "Could not find wxWidgets webview add-on")
find_package(wxWidgets REQUIRED COMPONENTS ${wxWidgets_FIND_COMPONENTS})
endif ()
if (MSYS)
# Convert msys to windows paths, and handle the missing /usr
string(
REGEX
REPLACE
"/usr/local"
";C:/MinGW/msys/1.0/local"
wxWidgets_INCLUDE_DIRS
"${wxWidgets_INCLUDE_DIRS}"
)
endif (MSYS)
include(${wxWidgets_USE_FILE})
# As of cmake 3.11.2, these libraries are missing in list despite that we
# looked for them. This is a nasty fix which might fail miserably. Assumption:
# All builds using GTK uses unicode and wxWidgets 3.0
if (GTK3_FOUND)
list(APPEND wxWidgets_LIBRARIES "-lwx_gtk3u_aui-3.0")
if (OPENGL_FOUND)
list(APPEND wxWidgets_LIBRARIES "-lwx_gtk3u_gl-3.0")
endif ()
endif ()
message(STATUS "Found wxWidgets...")
message(STATUS " wxWidgets Include: ${wxWidgets_INCLUDE_DIRS}")
message(STATUS " wxWidgets Libraries: ${wxWidgets_LIBRARIES}")
# We need to remove GLU from the wxWidgets_LIBRARIES list It only appears to
# get on the list for MSW...
foreach (_currentLibFile ${wxWidgets_LIBRARIES})
set(UCNAME ${_currentLibFile})
string(TOUPPER ${UCNAME} UCNAME)
if (NOT ${UCNAME} MATCHES "(.*)GLU(.*)")
set(
REVISED_wxWidgets_LIBRARIES ${REVISED_wxWidgets_LIBRARIES}
${_currentLibFile}
)
endif ()
endforeach (_currentLibFile)
set(wxWidgets_LIBRARIES ${REVISED_wxWidgets_LIBRARIES})
message(STATUS " Revised wxWidgets Libraries: ${wxWidgets_LIBRARIES}")
endif (NOT QT_ANDROID)
message(STATUS "")
message(STATUS "*** Staging to build ${PACKAGE_NAME} ***")
message(STATUS "*** Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "*** Will install to ${CMAKE_INSTALL_PREFIX} ***")
if (QT_ANDROID)
include_directories("${Qt_Base}/android_armv7/include/QtCore")
include_directories("${Qt_Base}/android_armv7/include")
include_directories("${Qt_Base}/android_armv7/include/QtWidgets")
include_directories("${Qt_Base}/android_armv7/include/QtGui")
include_directories("${Qt_Base}/android_armv7/include/QtOpenGL")
include_directories("${Qt_Base}/android_armv7/include/QtTest")
include_directories(
"${wxQt_Base}/${wxQt_Build}/lib/wx/include/arm-linux-androideabi-qt-unicode-static-3.1"
)
include_directories("${wxQt_Base}/include")
add_definitions(-DQT_WIDGETS_LIB)
endif (QT_ANDROID)
set(
HDRS
include/AboutFrame.h
include/AboutFrameImpl.h
include/AIS_Bitstring.h
include/AIS_Decoder.h
include/ais.h
include/AISTargetAlertDialog.h
include/AIS_Target_Data.h
include/AISTargetListDialog.h
include/AISTargetQueryDialog.h
include/bbox.h
include/canvasMenu.h
include/chart1.h
include/ChartDataInputStream.h
include/chartdb.h
include/chartdbs.h
include/chartimg.h
include/chcanv.h
include/ChInfoWin.h
include/compass.h
include/concanv.h
include/ConnectionParams.h
include/cutil.h
include/datastream.h
include/DetailSlider.h
include/dsPortType.h
include/emboss_data.h
include/FlexHash.h
include/FontDesc.h
include/FontMgr.h
include/geodesic.h
include/georef.h
include/GoToPositionDialog.h
include/gshhs.h
include/Hyperlink.h
include/IDX_entry.h
include/iENCToolbar.h
include/kml.h
include/Layer.h
include/LinkPropDlg.h
include/LLRegion.h
include/MarkIcon.h
include/MarkInfo.h
include/mbtiles.h
include/multiplexer.h
include/NavObjectCollection.h
include/navutil.h
include/NMEALogWindow.h
include/ocpCursor.h
include/OCP_DataStreamInput_Thread.h
include/OCPN_DataStreamEvent.h
include/ocpndc.h
include/OCPNListCtrl.h
include/ocpn_pixel.h
include/OCPNPlatform.h
include/ocpn_plugin.h
include/OCPNRegion.h
include/ocpn_types.h
include/options.h
include/piano.h
include/pluginmanager.h
include/PositionParser.h
include/printtable.h
include/Quilt.h
include/RolloverWin.h
include/Route.h
include/routemanagerdialog.h
include/routeman.h
include/RoutePoint.h
include/routeprintout.h
include/RoutePropDlg.h
include/RoutePropDlgImpl.h
include/S57ClassRegistrar.h
include/S57Light.h
include/S57ObjectDesc.h
include/S57QueryDialog.h
include/S57Sector.h
include/Select.h
include/SelectItem.h
include/SendToGpsDlg.h
include/Station_Data.h
include/styles.h
include/TCDataFactory.h
include/TCDataSource.h
include/TCDS_Ascii_Harmonic.h
include/TCDS_Binary_Harmonic.h
include/TC_Error_Code.h
include/tcmgr.h
include/TCWin.h
include/thumbwin.h
include/tide_time.h
include/timers.h
include/toolbar.h
include/Track.h
include/trackprintout.h
include/TrackPropDlg.h
include/TTYScroll.h
include/TTYWindow.h
include/undo.h
include/vector2D.h
include/viewport.h
include/WindowDestroyListener.h
${CMAKE_BINARY_DIR}/include/config.h
)
set(
SRCS
src/AboutFrame.cpp
src/AboutFrameImpl.cpp
src/AIS_Bitstring.cpp
src/ais.cpp
src/AIS_Decoder.cpp
src/AISTargetAlertDialog.cpp
src/AIS_Target_Data.cpp
src/AISTargetListDialog.cpp
src/AISTargetQueryDialog.cpp
src/bbox.cpp
src/CanvasConfig.cpp
src/canvasMenu.cpp
src/CanvasOptions.cpp
src/chart1.cpp
src/ChartDataInputStream.cpp
src/chartdb.cpp
src/chartdbs.cpp
src/chartimg.cpp
src/chcanv.cpp
src/ChInfoWin.cpp
src/compass.cpp
src/concanv.cpp
src/ConfigMgr.cpp
src/ConnectionParams.cpp
src/cutil.cpp
src/datastream.cpp
src/DetailSlider.cpp
src/FlexHash.cpp
src/FontDesc.cpp
src/FontMgr.cpp
src/garmin_wrapper.h
src/geodesic.cpp
src/georef.cpp
src/GoToPositionDialog.cpp
src/gshhs.cpp
src/Hyperlink.cpp
src/IDX_entry.cpp
src/iENCToolbar.cpp
src/kml.cpp
src/Layer.cpp
src/LinkPropDlg.cpp
src/LLRegion.cpp
src/MarkInfo.cpp
src/mbtiles.cpp
src/MUIBar.cpp
src/multiplexer.cpp
src/NavObjectCollection.cpp
src/navutil.cpp
src/NMEALogWindow.cpp
src/ocpCursor.cpp
src/OCP_DataStreamInput_Thread.cpp
src/OCPN_AUIManager.cpp
src/OCPN_DataStreamEvent.cpp
src/ocpndc.cpp
src/OCPNListCtrl.cpp
src/ocpn_pixel.cpp
src/OCPNPlatform.cpp
src/OCPNRegion.cpp
src/options.cpp
src/piano.cpp
src/pluginmanager.cpp
src/PositionParser.cpp
src/printtable.cpp
src/pugixml.cpp
src/Quilt.cpp
src/RolloverWin.cpp
src/Route.cpp
src/routemanagerdialog.cpp
src/routeman.cpp
src/RoutePoint.cpp
src/routeprintout.cpp
src/RoutePropDlg.cpp
src/RoutePropDlgImpl.cpp
src/S57QueryDialog.cpp
src/Select.cpp
src/SelectItem.cpp
src/SendToGpsDlg.cpp
src/Station_Data.cpp
src/styles.cpp
src/TCDataFactory.cpp
src/TCDataSource.cpp
src/TCDS_Ascii_Harmonic.cpp
src/TCDS_Binary_Harmonic.cpp
src/tcmgr.cpp
src/TCWin.cpp
src/thumbwin.cpp
src/toolbar.cpp
src/Track.cpp
src/trackprintout.cpp
src/TrackPropDlg.cpp
src/TTYScroll.cpp
src/TTYWindow.cpp
src/undo.cpp
src/viewport.cpp
)
if (OCPN_USE_GARMINHOST)
message(STATUS "GarminHost is enabled.")
set(USE_GARMINHOST 1) # -> config.h
set(SRCS ${SRCS} src/garmin_wrapper.cpp)
endif ()
if (APPLE)
if (DARWIN_VERSION LESS 16)
message(
STATUS "DarkMode not included, requires Mac build host Darwin >= 16"
)
else ()
list(APPEND SRCS src/DarkMode.mm src/DarkMode.h)
add_definitions(-DOCPN_USE_DARKMODE)
endif ()
endif (APPLE)
if (NOT WIN32 AND NOT APPLE AND NOT QT_ANDROID AND OCPN_USE_CRASHREPORT)
list(APPEND HDRS include/crashprint.h)
list(APPEND SRCS src/crashprint.cpp)
endif (NOT WIN32 AND NOT APPLE AND NOT QT_ANDROID AND OCPN_USE_CRASHREPORT)
if (APPLE)
add_executable(${PACKAGE_NAME} MACOSX_BUNDLE ${HDRS} ${SRCS})
elseif (WIN32)
add_executable(${PACKAGE_NAME} WIN32 ${HDRS} ${SRCS})
else ()
add_executable(${PACKAGE_NAME} ${HDRS} ${SRCS})
endif ()
add_library(_opencpn INTERFACE) # plugin link target.
target_link_libraries(_opencpn INTERFACE ${PACKAGE_NAME})
target_include_directories(
_opencpn
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include
)
add_library(ocpn::opencpn ALIAS _opencpn)
set_target_properties(
${PACKAGE_NAME}
PROPERTIES
ENABLE_EXPORTS
1
OUTPUT_NAME
${PACKAGE_NAME}
ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
)
target_include_directories(
${PACKAGE_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
)
if (APPLE)
target_include_directories(
${PACKAGE_NAME}
PRIVATE /usr/X11/include /usr/X11/include/GL
)
endif ()
# IF(NOT WIN32) include(OcpnFindGpsd) if (TARGET ocpn::gpsd)
# target_link_libraries(${PACKAGE_NAME} ocpn::gpsd) endif () ENDIF (NOT WIN32)
find_package(Gettext REQUIRED)
add_subdirectory(libs/ssl_sha1)
target_link_libraries(${PACKAGE_NAME} PRIVATE ssl::sha1)
#
# Linux: set up GTK
#
if (NOT WIN32 AND NOT APPLE AND NOT QT_ANDROID)
include(OcpnFindGtk)