-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJagati.cmake
2592 lines (2339 loc) · 121 KB
/
Jagati.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
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
# © Copyright 2010 - 2021 BlackTopp Studios Inc.
# This file is part of The Mezzanine Engine.
#
# The Mezzanine Engine 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 3 of the License, or
# (at your option) any later version.
#
# The Mezzanine Engine 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 The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
#
# The original authors have included a copy of the license specified above in the
# 'Docs' folder. See 'gpl.txt'
#
# We welcome the use of the Mezzanine engine to anyone, including companies who wish to
# Build professional software and charge for their product.
#
# However there are some practical restrictions, so if your project involves
# any of the following you should contact us and we will try to work something
# out:
# - DRM or Copy Protection of any kind(except Copyrights)
# - Software Patents You Do Not Wish to Freely License
# - Any Kind of Linking to Non-GPL licensed Works
# - Are Currently In Violation of Another Copyright Holder's GPL License
# - If You want to change our code and not add a few hundred MB of stuff to
# your distribution
#
# These and other limitations could cause serious legal problems if you ignore
# them, so it is best to simply contact us or the Free Software Foundation, if
# you have any questions.
#
# Joseph Toppi - [email protected]
# John Blackwood - [email protected]
########################################################################################################################
# This is the basic package manager for the Mezzanine, called the Jagati. This will track and download packages from git
# repositories. This will handle centrally locating Mezzanine packages and provide tools for finding and linking against
# them appropriately. This will not be included directly in git repositories, but rather a small download snippet will
# ensure this stays up to date.
# # Do something like this to include the Jagati. Try to use the newest version and
# # get the checksum from the repo before using it.
# set(JagatiChecksum "ae061311fcc4ecca287e7e7df38f9f52fbacc2060946f92bdece21\
# d86584f1de152c59a7181992a30365c07bb58772f3dadef38adbb4b15c305429a1b966f314")
# file(DOWNLOAD
# "https://raw.githubusercontent.com/BlackToppStudios/Jagati/0.12.1/Jagati.cmake"
# "${${PROJECT_NAME}_BINARY_DIR}/Jagati.cmake"
# EXPECTED_HASH SHA512=${JagatiChecksum}
# )
########################################################################################################################
########################################################################################################################
# From Here to the next thick banner exist a series of simple checks and variables to act as baseline assumptions for
# the rest of the Jagati, so it can perform complex things confidently.
########################################################################################################################
########################################################################################################################
########################################################################################################################
# Basic Sanity Checks the Jagati enforces
# Prevent the Jagati from being loaded twice.
if(JagatiVersion)
message(STATUS "Already loaded Jagati version '${JagatiVersion}', not loading again.")
return()
else(JagatiVersion)
set(JagatiVersion "0.31.0")
message(STATUS "Preparing Jagati Version: ${JagatiVersion}")
endif(JagatiVersion)
# Break if some fool tries to build in his source directory.
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Prevented in source tree build. Please create a build directory outside of"
" the Mezzanine source code and have cmake build from there.")
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
# Allow using versions of CMake back to 3.0 even with policy changes.
cmake_minimum_required(VERSION 3.0)
if("${CMAKE_VERSION}" VERSION_GREATER "3.1.0")
message(STATUS "Setting comparison policy for newer versions of CMake. Using CMP0054.")
cmake_policy(SET CMP0054 NEW)
else("${CMAKE_VERSION}" VERSION_GREATER "3.1.0")
message(STATUS "NOT setting comparison policy for newer versions of CMake. Not using CMP0054.")
endif("${CMAKE_VERSION}" VERSION_GREATER "3.1.0")
########################################################################################################################
# Index API
########################################################################################################################
# PackageMetadata
#
# This is intended to be used by repos to add a package that the Jagati can work with. This accepts the Name of the
# package, the URL to download it from, and a simple description of the package.
#
# Usage:
# # From the index file
# PackageMetadata("PackageName" "https://url.com/folder/package_repo.git" "This is an example packaged.")
#
# Result:
# The Jagati is made aware of the package and after this CMakeLists.txt that use the Jagati will be able to use
# `IncludeJagatiPackage("PackageName")` and they should work correctly. Those CMakeLists.txt will need to meet any
# other requirements for IncludeJagatiPackage (Like running the StandardJagatiSetup).
#
set(JAGATI_PackageList "Jagati" CACHE STRING "A list of all Jagati Packages from the index, always reloaded." FORCE)
function(PackageMetadata PackageName Url DocString)
set(JAGATI_PackageList "${JAGATI_PackageList};${PackageName}" CACHE STRING
"A list of all Jagati Packages from the index, always reloaded." FORCE)
set("${PackageName}_GitURL" "${Url}" CACHE STRING "${DocString}")
endfunction(PackageMetadata PackageName Url DocString)
########################################################################################################################
# Loading the Package Index
if(NOT JAGATI_IndexFile)
message(STATUS "Jagati Indexfile not provided, using default.")
get_filename_component(JAGATI_IndexFolder "${JAGATI_File}" DIRECTORY)
set(JAGATI_IndexFile "${JAGATI_IndexFolder}/JagatiIndex.cmake" CACHE FILEPATH
"The file that defines the packages and download URLs that the Jagati will work with.")
endif(NOT JAGATI_IndexFile)
if(NOT JAGATI_IndexDownload)
option(JAGATI_IndexDownload "Should the Jagati Package Index be downloaded automatically" ON)
endif(NOT JAGATI_IndexDownload)
if(JAGATI_IndexDownload)
set(JAGATI_IndexChecksum "4ad9b0ff814ef986cbb82a47c9ae3fe6c77f403925ac17608\
6c316532d61ce76d14e461b633ae9f30b25a5f7e982772206684e498baf9380e80a0a3bb4b2d485"
CACHE STRING "The expected Checksum of the Jagati Package Index.")
set(JAGATI_IndexUrl "https://raw.githubusercontent.com/BlackToppStudios/Jagati/0.29.0/JagatiIndex.cmake"
CACHE STRING "Where to download the Jagati from.")
file(DOWNLOAD "${JAGATI_IndexUrl}" "${JAGATI_IndexFile}" EXPECTED_HASH SHA512=${JAGATI_IndexChecksum})
endif(JAGATI_IndexDownload)
message(STATUS "Pre-load Index settings:")
message(STATUS "\tJAGATI_IndexFolder: ${JAGATI_IndexFolder}")
message(STATUS "\tJAGATI_IndexFile: ${JAGATI_IndexFile}")
message(STATUS "\tJAGATI_IndexUrl: ${JAGATI_IndexUrl}")
message(STATUS "\tJAGATI_IndexChecksum: ${JAGATI_IndexChecksum}")
include("${JAGATI_IndexFile}")
message(STATUS "Index loaded, Packages include: ${JAGATI_PackageList}")
foreach(JAGATI_OnePackage ${JAGATI_PackageList})
message(STATUS "\t${JAGATI_OnePackage}")
endforeach(JAGATI_OnePackage)
########################################################################################################################
# File construction variables
set(MEZZ_Copyright
"// © Copyright 2010 - 2021 BlackTopp Studios Inc.\n\
/* This file is part of The Mezzanine Engine.\n\
\n\
The Mezzanine Engine is free software: you can redistribute it and/or modify\n\
it under the terms of the GNU General Public License as published by\n\
the Free Software Foundation, either version 3 of the License, or\n\
(at your option) any later version.\n\
\n\
The Mezzanine Engine is distributed in the hope that it will be useful,\n\
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
GNU General Public License for more details.\n\
\n\
You should have received a copy of the GNU General Public License\n\
along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.\n\
*/\n\
/* The original authors have included a copy of the license specified above in the\n\
'Docs' folder. See 'gpl.txt'\n\
*/\n\
/* We welcome the use of the Mezzanine engine to anyone, including companies who wish to\n\
Build professional software and charge for their product.\n\
\n\
However there are some practical restrictions, so if your project involves\n\
any of the following you should contact us and we will try to work something\n\
out:\n\
- DRM or Copy Protection of any kind(except Copyrights)\n\
- Software Patents You Do Not Wish to Freely License\n\
- Any Kind of Linking to Non-GPL licensed Works\n\
- Are Currently In Violation of Another Copyright Holder's GPL License\n\
- If You want to change our code and not add a few hundred MB of stuff to\n\
your distribution\n\
\n\
These and other limitations could cause serious legal problems if you ignore\n\
them, so it is best to simply contact us or the Free Software Foundation, if\n\
you have any questions.\n\
\n\
Joseph Toppi - [email protected]\n\
John Blackwood - [email protected]\n\
*/\n\n"
)
########################################################################################################################
# Require external packages.
include(CTest)
include(ExternalProject)
########################################################################################################################
########################################################################################################################
# From here to the next thick banner is the Cross-Compiling utilities provided by the Jagati, with a primary focus on
# compiling to Android and iOS.
########################################################################################################################
########################################################################################################################
########################################################################################################################
# EnableIOSCrossCompile
#
# This is used to configure the basic build settings for projects that wish to build on iOS.
# Some projects may want or need to perform additional configuration than what is provided
# here to get a working build.
#
# This attempts to make sane settings for building with either the live OS or simulator in
# mind as possible targets.
#
# Usage:
# # Be certain to call project() before calling this. Ideally this should be called
# # just after downloading the Jagati, prior to any other calls.
# EnableIOSCrossCompile()
#
# Result:
# The following options will all be created, made available, and printed:
# MEZZ_iOSTarget
# MEZZ_iOSCompanyName
#
macro(EnableIOSCrossCompile)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode")
message(FATAL_ERROR "XCode generator required to cross-compile to iOS.")
endif(NOT CMAKE_GENERATOR STREQUAL "Xcode")
if(NOT LibraryBuildType STREQUAL "STATIC")
message(FATAL_ERROR "iOS only permits static builds.")
endif(NOT LibraryBuildType STREQUAL "STATIC")
set(CMAKE_SYSTEM_NAME "AppleIOS")
if(NOT "$ENV{IOS_SDK_VERSION}" STREQUAL "")
set(CMAKE_SYSTEM_VERSION $ENV{IOS_SDK_VERSION})
endif(NOT "$ENV{IOS_SDK_VERSION}" STREQUAL "")
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING_TARGET IOS)
set(IOS ON)
set(UNIX ON)
set(APPLE ON)
set(CMAKE_MACOSX_BUNDLE YES)
set(XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhoneDeveloper")
set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
# Required as of cmake 2.8.10
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
# Skip the platform compiler checks for cross compiling
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_C_COMPILER_WORKS TRUE)
# Set Bundle stuff
if(NOT DEFINED MEZZ_iOSCompanyName)
set(MEZZ_iOSCompanyName "BlackToppStudios")
endif(NOT DEFINED MEZZ_iOSCompanyName)
set(MEZZ_iOSCompanyName ${MEZZ_iOSCompanyName} CACHE
STRING "The name of the company building the iOS target. Used to generate the Bundle ID."
)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.${MEZZ_iOSCompanyName}.\${PRODUCT_NAME:rfc1034identifier}")
# Determine our target
option(MEZZ_iOSSimulator
"Whether or not to compile iOS binaries to target a simulator. Disable for physical device." ON
)
if(MEZZ_iOSSimulator)
set(XCODE_IOS_TARGET iphonesimulator)
set(IOS_ARCH x86_64)
message(STATUS "Configuring iOS build for Simulator using architecture(s): ${IOS_ARCH}")
else(MEZZ_iOSSimulator)
set(XCODE_IOS_TARGET iphoneos)
set(IOS_ARCH armv7 armv7s arm64)
message(STATUS "Configuring iOS build for Device using architecture(s): ${IOS_ARCH}")
endif(MEZZ_iOSSimulator)
set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS")
# We need to find the iOS SDK to use
execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_TARGET} Path
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${MEZZ_iOSTarget}")
# Hidden visibilty is required for cxx on iOS
set(CMAKE_C_FLAGS_INIT "")
set(CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden -isysroot ${CMAKE_OSX_SYSROOT}")
endmacro(EnableIOSCrossCompile)
########################################################################################################################
########################################################################################################################
# From here to the next thick banner are macros to set variables in the scope of the calling CMake or cache project that
# all Jagati packages should set. The idea is that every variable needed to link or inspect the source will be cleanly
# set and easy to inspect, from just the output of CMake and a sample CMakeLists.txt.
########################################################################################################################
########################################################################################################################
########################################################################################################################
# InitializeSingleScopeVars
#
# There have been several occasions in the history of the Jagati were is was desirable to have a variable that was set
# only once for the whole project. These were often refactored away or their functionality removed, but when such items
# are required this macro will be called once and executed in the scope of the parent most project.
#
#
# Usage:
# # Don't, Only the Jagati should call this.
# InitializeSingleScopeVars()
#
# Result:
# The parent project is claimed by setting ParentProject.
# The index used to keep track of what subdirs have been added is cleared
#
macro(InitializeSingleScopeVars)
set(ParentProject "${PROJECT_NAME}")
set(AddDirectoryOnceIndex "" CACHE INTERNAL "" FORCE)
endmacro(InitializeSingleScopeVars)
########################################################################################################################
# ClaimParentProject
#
# This is used to determine what the parent-most project is. Whichever project calls this first will be presumed to be
# the parent-most scope and be the only one that doesn't set all of it's variables in its parent's scope.
#
# This is also used to initialize a few internal variables that need to only be initilized once.
#
# Usage:
# # Be certain to call project() before calling this.
# # Call this from the main project before calling anything else to insure your project is root.
# ClaimParentProject()
#
# Result:
# The ParentProject variable will all be set, made available, printed, and other Jagati projects
# will know not to pollute your namespace.
#
macro(ClaimParentProject)
if(ParentProject)
# It is already set so we must be a child.
message(STATUS "Project '${PROJECT_NAME}' acknowledges '${ParentProject}' as the Parent Project.")
else(ParentProject)
message(STATUS "Claiming '${PROJECT_NAME}' as the Parent Project.")
InitializeSingleScopeVars()
endif(ParentProject)
endmacro(ClaimParentProject)
########################################################################################################################
# CreateLocationVars
#
# This will create a number of variables in the scope of the calling script that correspond to the name of the project
# so that they can readily be referenced from other project including the caller as a subproject.
#
# Usage:
# # Be certain to call project before calling this.
# CreateLocationVars()
#
# Result:
# The following variables will all be set to some valid folder, made available and printed:
#
# ${PROJECT_NAME}BinaryDir
# ${PROJECT_NAME}GenHeadersDir
# ${PROJECT_NAME}GenSourceDir
#
# ${PROJECT_NAME}RootDir
# ${PROJECT_NAME}DoxDir
# ${PROJECT_NAME}IncludeDir
# ${PROJECT_NAME}LibDir
# ${PROJECT_NAME}SourceDir
# ${PROJECT_NAME}SwigDir
# ${PROJECT_NAME}TestDir
#
macro(CreateLocationVars)
message(STATUS "Creating Location Variables for '${PROJECT_NAME}'")
# TODO: Figure out the best way to accept already set versions of these if set already.
#######################################
# Derived Output Folders
set(${PROJECT_NAME}BinaryDir "${${PROJECT_NAME}_BINARY_DIR}/" CACHE INTERNAL "" FORCE)
set(${PROJECT_NAME}GenHeadersDir "${${PROJECT_NAME}BinaryDir}config/" CACHE INTERNAL "" FORCE)
set(${PROJECT_NAME}GenSourceDir "${${PROJECT_NAME}BinaryDir}generated_source/" CACHE INTERNAL "" FORCE)
#######################################
# Derived Input Folders
set(${PROJECT_NAME}RootDir "${${PROJECT_NAME}_SOURCE_DIR}/" CACHE INTERNAL "" FORCE)
set(${PROJECT_NAME}DoxDir "${${PROJECT_NAME}RootDir}dox/" CACHE INTERNAL "" FORCE)
set(${PROJECT_NAME}IncludeDir "${${PROJECT_NAME}RootDir}include/" CACHE INTERNAL "" FORCE)
set(${PROJECT_NAME}LibDir "${${PROJECT_NAME}RootDir}lib/" CACHE INTERNAL "" FORCE)
set(${PROJECT_NAME}SourceDir "${${PROJECT_NAME}RootDir}src/" CACHE INTERNAL "" FORCE)
set(${PROJECT_NAME}SwigDir "${${PROJECT_NAME}RootDir}swig/" CACHE INTERNAL "" FORCE)
set(${PROJECT_NAME}TestDir "${${PROJECT_NAME}RootDir}test/" CACHE INTERNAL "" FORCE)
#######################################
# Package Directory Variables
set(MEZZ_PackageDirectory "$ENV{MEZZ_PACKAGE_DIR}" CACHE PATH "Folder for storing Jagati Packages.")
set(PackageDirectory_Description "Folder for storing Jagati Packages.")
set(PackageDirectory_Default "${${PROJECT_NAME}BinaryDir}JagatiPackages/")
set(PackageDirectory_MissingWarning "MEZZ_PackageDirectory is not set or could not be found, this needs to be \
a valid folder where Mezzanine Libraries can be downloaded to. You can set the Environment variable \
'MEZZ_PACKAGE_DIR' or set MEZZ_PackageDirectory in CMake, if left unset this will create a folder in the output \
directory."
)
if(EXISTS "$ENV{MEZZ_PACKAGE_DIR}")
set(MEZZ_PackageDirectory "$ENV{MEZZ_PACKAGE_DIR}" CACHE PATH "${PackageDirectory_Description}" FORCE)
else(EXISTS "$ENV{MEZZ_PACKAGE_DIR}")
if(EXISTS "${MEZZ_PackageDirectory}")
set(MEZZ_PackageDirectory "${MEZZ_PackageDirectory}" CACHE PATH "${PackageDirectory_Description}" FORCE)
else(EXISTS "${MEZZ_PackageDirectory}")
message(STATUS "${PackageDirectory_MissingWarning}")
set(MEZZ_PackageDirectory "${PackageDirectory_Default}" CACHE PATH "${PackageDirectory_Description}" FORCE)
endif(EXISTS "${MEZZ_PackageDirectory}")
endif(EXISTS "$ENV{MEZZ_PACKAGE_DIR}")
if(NOT "${MEZZ_PackageDirectory}" MATCHES "^.*/$") # Append Slash if needed
set(MEZZ_PackageDirectory "${MEZZ_PackageDirectory}/")
endif(NOT "${MEZZ_PackageDirectory}" MATCHES "^.*/$")
#######################################
message(STATUS "Variables for '${PROJECT_NAME}'")
message(STATUS "Derived Output folders")
message(STATUS "'${PROJECT_NAME}BinaryDir' - ${${PROJECT_NAME}BinaryDir}")
message(STATUS "'${PROJECT_NAME}GenHeadersDir' - ${${PROJECT_NAME}GenHeadersDir}")
message(STATUS "'${PROJECT_NAME}GenSourceDir' - ${${PROJECT_NAME}GenSourceDir}")
message(STATUS "Derived Input folders")
message(STATUS "'${PROJECT_NAME}RootDir' - ${${PROJECT_NAME}RootDir}")
message(STATUS "'${PROJECT_NAME}DoxDir' - ${${PROJECT_NAME}DoxDir}")
message(STATUS "'${PROJECT_NAME}IncludeDir' - ${${PROJECT_NAME}IncludeDir}")
message(STATUS "'${PROJECT_NAME}LibDir' - ${${PROJECT_NAME}LibDir}")
message(STATUS "'${PROJECT_NAME}SourceDir' - ${${PROJECT_NAME}SourceDir}")
message(STATUS "'${PROJECT_NAME}SwigDir' - ${${PROJECT_NAME}SwigDir}")
message(STATUS "'${PROJECT_NAME}TestDir' - ${${PROJECT_NAME}TestDir}")
message(STATUS "MEZZ_PackageDirectory - ${MEZZ_PackageDirectory}")
message(STATUS "ENV{MEZZ_PACKAGE_DIR} - ${MEZZ_PackageDirectory}")
endmacro(CreateLocationVars)
########################################################################################################################
# CreateLocations
#
# This will use the created location variables to create any needed folders for generated source and include files and
# add default folders to the include path.
#
# Usage:
# # Be certain to call project before calling this.
# CreateLocations()
#
# Result:
# Folders on the filesystem will be created.
#
macro(CreateLocations)
# Derived Output Folders
file(MAKE_DIRECTORY ${${PROJECT_NAME}GenHeadersDir})
file(MAKE_DIRECTORY ${${PROJECT_NAME}GenSourceDir})
include_directories(${${PROJECT_NAME}IncludeDir} ${${PROJECT_NAME}GenHeadersDir})
# Derived Input Folders
file(MAKE_DIRECTORY ${${PROJECT_NAME}DoxDir})
file(MAKE_DIRECTORY ${${PROJECT_NAME}IncludeDir})
file(MAKE_DIRECTORY ${${PROJECT_NAME}LibDir})
file(MAKE_DIRECTORY ${${PROJECT_NAME}SourceDir})
file(MAKE_DIRECTORY ${${PROJECT_NAME}SwigDir})
file(MAKE_DIRECTORY ${${PROJECT_NAME}TestDir})
endmacro(CreateLocations)
########################################################################################################################
# DecideOutputNames
#
# This will create a few variables in the scope of the calling script or cache that correspond to the name of the
# project so that they can readily be referenced from other project including the caller as a subproject.
#
# Usage:
# # Be certain to call project before calling this.
# DecideOutputNames()
#
# Result:
# The following variables will all be set to some valid folder, made available and printed:
# ${PROJECT_NAME}BinTarget
# ${PROJECT_NAME}LibTarget
# ${PROJECT_NAME}TestTarget
#
macro(DecideOutputNames)
message(STATUS "Creating Output Executable Variables for '${PROJECT_NAME}'")
if(${PROJECT_NAME}BinTarget)
set(${PROJECT_NAME}BinTarget "${${PROJECT_NAME}BinTarget}" CACHE INTERNAL "" FORCE)
else(${PROJECT_NAME}BinTarget)
set(${PROJECT_NAME}BinTarget "${PROJECT_NAME}_Main" CACHE INTERNAL "" FORCE)
endif(${PROJECT_NAME}BinTarget)
message(STATUS "'${PROJECT_NAME}BinTarget' - ${${PROJECT_NAME}BinTarget}")
if(${PROJECT_NAME}LibTarget)
set(${PROJECT_NAME}LibTarget "${${PROJECT_NAME}LibTarget}" CACHE INTERNAL "" FORCE)
else(${PROJECT_NAME}LibTarget)
set(${PROJECT_NAME}LibTarget "${PROJECT_NAME}" CACHE INTERNAL "" FORCE)
endif(${PROJECT_NAME}LibTarget)
message(STATUS "'${PROJECT_NAME}LibTarget' - ${${PROJECT_NAME}LibTarget}")
if(${PROJECT_NAME}TestTarget)
set(${PROJECT_NAME}TestTarget "${${PROJECT_NAME}TestTarget}" CACHE INTERNAL "" FORCE)
else(${PROJECT_NAME}TestTarget)
set(${PROJECT_NAME}TestTarget "${PROJECT_NAME}_Tester" CACHE INTERNAL "" FORCE)
endif(${PROJECT_NAME}TestTarget)
message(STATUS "'${PROJECT_NAME}TestTarget' - ${${PROJECT_NAME}TestTarget}")
endmacro(DecideOutputNames)
########################################################################################################################
# IdentifyCPU
# Clearly CMake knows how to ID the CPU without our help, but there are tricks to it and builtin tools are not as well
# identified as the could be. Hopefully this overcomes these minor shortfalls and provide a single source of truth for
# build time CPU determination in the Jagati/Mezzanine.
#
# Usage:
# # Be the parentmost cmake scope or this has no effect.
# IdentifyCPU()
#
# Result:
# Details about CPU are displayed and the following variables are set:
#
# CpuIsKnown - ON/OFF
# CpuIsX86 - ON/OFF
# CpuIsAmd64 - ON/OFF
# CpuIsArm - ON/OFF
#
# If CpuIsKnown is set at least one of the other values will betrueas well, otherwise they will all be OFF.
macro(IdentifyCPU)
# TODO - This may need to detect more CPU types so correct optimizations can be enabled when crosscompiling or
# targetting older CPUs.
message(STATUS "Checking CPU information this system.")
set(CpuIsKnown OFF)
set(CpuIsX86 OFF)
set(CpuIsAmd64 OFF)
set(CpuIsArm OFF)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
set(CpuIsKnown ON)
set(CpuIsArm ON)
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)")
set(CpuIsKnown ON)
set(CpuIsX86 ON)
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)")
set(CpuIsKnown ON)
set(CpuIsX86 ON)
set(CpuIsAmd64 ON)
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)")
message(STATUS "'CpuIsKnown' - ${CpuIsKnown}")
message(STATUS "'CpuIsX86' - ${CpuIsX86}")
message(STATUS "'CpuIsAmd64' - ${CpuIsAmd64}")
message(STATUS "'CpuIsArm' - ${CpuIsArm}")
endmacro(IdentifyCPU)
########################################################################################################################
# IdentifyOS
# Clearly CMake knows how to ID the OS without our help, but there are tricks to it and builtin tools are not as well
# identified as the could be. Hopefully this overcomes these minor shortfalls and provide a single source of truth for
# build time platform determination in the Jagati/Mezzanine.
#
# Usage:
# # Be the parentmost cmake scope or this has no effect.
# IdentifyOS()
#
# Result:
# Details about OS are displayed and the following variables are set:
#
# SystemIsLinux - ON/OFF
# SystemIsWindows - ON/OFF
# SystemIsMacOSX - ON/OFF
# SystemIsIOS - ON/OFF
#
# Platform32Bit - ON/OFF
# Platform64Bit - ON/OFF
#
# CatCommand - Some command that can print files when supplied a filename as only argument.
# PlatformDefinition - LINUX/WINDOWS/MACOSX
#
macro(IdentifyOS)
if("${ParentProject}" STREQUAL "${PROJECT_NAME}")
message(STATUS "Detecting OS:")
set(SystemIsLinux OFF)
set(SystemIsWindows OFF)
set(SystemIsMacOSX OFF)
set(SystemIsIOS OFF)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
message(STATUS "Detected OS as 'Linux'.")
set(SystemIsLinux ON)
endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
message(STATUS "Detected OS as 'Windows'.")
set(SystemIsWindows ON)
endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
message(STATUS "Detected OS as 'Mac OS X'.")
set(SystemIsMacOSX ON)
endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "AppleIOS")
message(STATUS "Detected OS as 'iOS'.")
set(SystemIsIOS ON)
endif("${CMAKE_SYSTEM_NAME}" STREQUAL "AppleIOS")
message(STATUS "'SystemIsLinux' - ${SystemIsLinux}")
message(STATUS "'SystemIsWindows' - ${SystemIsWindows}")
message(STATUS "'SystemIsMacOSX' - ${SystemIsMacOSX}")
message(STATUS "'SystemIsIOS' - ${SystemIsIOS}")
if(SystemIsLinux)
message(STATUS "Setting specific variables for 'Linux'.")
set(CatCommand "cat")
set(PlatformDefinition "LINUX")
endif(SystemIsLinux)
if(SystemIsWindows)
message(STATUS "Setting specific variables for 'Windows'.")
set(CatCommand "type")
set(PlatformDefinition "WINDOWS")
endif(SystemIsWindows)
if(SystemIsMacOSX)
message(STATUS "Setting specific variables for 'Mac OS X'.")
set(CatCommand "cat")
set(PlatformDefinition "MACOSX")
endif(SystemIsMacOSX)
if(SystemIsIOS)
message(STATUS "Setting specific variables for 'iOS'.")
set(CatCommand "cat")
set(PlatformDefinition "IOS")
endif(SystemIsIOS)
message(STATUS "'CatCommand' - ${CatCommand}")
set(Platform32Bit OFF)
set(Platform64Bit OFF)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(STATUS "Detected a 64 bit platform.")
set(Platform64Bit ON)
else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(STATUS "Detected a 32 bit platform.")
set(Platform32Bit ON)
endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
message(STATUS "'Platform64Bit' - ${Platform64Bit}")
message(STATUS "'Platform32Bit' - ${Platform32Bit}")
endif("${ParentProject}" STREQUAL "${PROJECT_NAME}")
endmacro(IdentifyOS)
########################################################################################################################
# IdentifyCompiler
#
# Again, CMake knows how to detect the compiler. It does this in hyper precise detail. For purposes of the Mezzanine
# there are really two categories of compiler: visual studio and good compilers. This can roughly identify those
# categories and provide a single source of truth for each of the 5 supported compilers.
#
# If this fails to detect the compiler this reports a message with status of FATAL_ERROR which may terminate CMake.
#
# Usage:
# # Be the parentmost cmake scope or this has no effect.
# IdentifyCompiler()
#
# Result:
# Details about compiler are displayed and the following variables are set:
#
# CompilerIsClang - ON/OFF
# CompilerIsEmscripten - ON/OFF
# CompilerIsGCC - ON/OFF
# CompilerIsIntel - ON/OFF
# CompilerIsMsvc - ON/OFF
#
# CompilerDesignNix - ON/OFF
# CompilerDesignMS - ON/OFF
#
# CompilerSupportsCoverage - ON/OFF
#
# CompilerDetected - ON/OFF (FATAL_ERROR when OFF)
#
macro(IdentifyCompiler)
if("${ParentProject}" STREQUAL "${PROJECT_NAME}")
message(STATUS "Detecting Compiler:")
# If compiler ID is unset set try to guess it
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "")
if(CMAKE_CXX_COMPILER MATCHES "/em\\+\\+(-[a-zA-Z0-9.])?$")
set(CMAKE_CXX_COMPILER_ID "Emscripten")
endif(CMAKE_CXX_COMPILER MATCHES "/em\\+\\+(-[a-zA-Z0-9.])?$")
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "")
message(STATUS "CMAKE_CXX_COMPILER_ID: '${CMAKE_CXX_COMPILER_ID}'")
set(CompilerIsGCC OFF)
set(CompilerIsClang OFF)
set(CompilerIsIntel OFF)
set(CompilerIsMsvc OFF)
set(CompilerIsEmscripten OFF)
set(CompilerDesignNix OFF)
set(CompilerDesignMS OFF)
set(CompilerSupportsCoverage OFF)
set(CompilerDetected OFF)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(STATUS "Detected compiler as 'GCC'.")
set(CompilerIsGCC ON)
set(CompilerDesignNix ON)
set(CompilerDetected ON)
set(CompilerSupportsCoverage ON)
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
message(STATUS "Detected compiler as 'AppleClang' using Clang settings.")
set(CompilerIsClang ON)
set(CompilerDesignNix ON)
set(CompilerDetected ON)
set(CompilerSupportsCoverage ON)
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "Detected compiler as 'Clang'.")
set(CompilerIsClang ON)
set(CompilerDesignNix ON)
set(CompilerDetected ON)
set(CompilerSupportsCoverage ON)
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
message(STATUS "Detected compiler as 'Intel'.")
set(CompilerIsIntel ON)
set(CompilerDesignNix ON)
set(CompilerDetected ON)
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
if(CMAKE_CXX_COMPILER MATCHES "/em\\+\\+(-[a-zA-Z0-9.])?$")
message(STATUS "Detected compiler as 'Emscripten'.")
set(CompilerIsEmscripten ON)
set(CompilerDesignNix ON)
set(CompilerDetected ON)
endif(CMAKE_CXX_COMPILER MATCHES "/em\\+\\+(-[a-zA-Z0-9.])?$")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(STATUS "Detected compiler as 'MSVC'.")
set(CompilerIsMsvc ON)
set(CompilerDesignMS ON)
set(CompilerDetected ON)
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_GENERATOR}" STREQUAL "Xcode")
# This stops msvc and xcode from breaking linking and the purpose of output dirs with multiple output dirs.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${${PROJECT_NAME}BinaryDir}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${${PROJECT_NAME}BinaryDir}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${${PROJECT_NAME}BinaryDir}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${${PROJECT_NAME}BinaryDir}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${${PROJECT_NAME}BinaryDir}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${${PROJECT_NAME}BinaryDir}")
endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_GENERATOR}" STREQUAL "Xcode")
message(STATUS "'CompilerIsGCC' - ${CompilerIsGCC}")
message(STATUS "'CompilerIsClang' - ${CompilerIsClang}")
message(STATUS "'CompilerIsIntel' - ${CompilerIsIntel}")
message(STATUS "'CompilerIsMsvc' - ${CompilerIsMsvc}")
message(STATUS "'CompilerIsEmscripten' - ${CompilerIsEmscripten}")
if(CompilerDesignNix)
message(STATUS "Presuming *nix style compiler.")
endif(CompilerDesignNix)
if(CompilerDesignMS)
message(STATUS "Presuming ms style compiler.")
endif(CompilerDesignMS)
message(STATUS "'CompilerDesignNix' - ${CompilerDesignNix}")
message(STATUS "'CompilerDesignMS' - ${CompilerDesignMS}")
message(STATUS "'CompilerSupportsCoverage' - ${CompilerSupportsCoverage}")
message(STATUS "'CompilerDetected' - ${CompilerDetected}")
if(NOT CompilerDetected)
message(FATAL_ERROR "Compiler not detected, Exiting! This can be supressed by removing check in the\
Jagati macro IdentifyCompiler.")
endif(NOT CompilerDetected)
endif("${ParentProject}" STREQUAL "${PROJECT_NAME}")
endmacro(IdentifyCompiler)
########################################################################################################################
# IdentifyDebug
#
# Again, CMake knows all about the debug state. It also does this in hyper precise detail, and does it implicitly with
# the Build Type. For purposes of the Mezzanine we really want a single boolean yes or no for debugging, it also doesn't
# help that compilers have like 50 different ways to check this each with their own possible ways to fail. Even if half
# of those are great and never fail a single source of truth is still required and this should be it for the Jagati.
#
# To use this, just set the CMAKE_BUILD_TYPE like you normally would and this will use a Regex to identify debug
# settings and notify the code and other build settings that care.
#
# Usage:
# # Be the parentmost cmake scope or this has no effect.
# IdentifyDebug()
#
# Result:
# Details about compiler debug symbol generation state are displayed and the following variables are set:
#
# CompilerDebug - ON/OFF
#
macro(IdentifyDebug)
if("${ParentProject}" STREQUAL "${PROJECT_NAME}")
message(STATUS "Detecting Debug:")
message(STATUS "CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}'")
set(CompilerDebug OFF)
if("${CMAKE_BUILD_TYPE}" MATCHES "[Dd][Ee][Bb]")
message(STATUS "Detected compiler as creating debug data.")
set(CompilerDebug ON)
else("${CMAKE_BUILD_TYPE}" MATCHES "[Dd][Ee][Bb]")
message(STATUS "Detected compiler as skipping debug data.")
endif("${CMAKE_BUILD_TYPE}" MATCHES "[Dd][Ee][Bb]")
endif("${ParentProject}" STREQUAL "${PROJECT_NAME}")
endmacro(IdentifyDebug)
########################################################################################################################
# SetCommonCompilerFlags
#
# This is one of those things that CMake is simultaneously great and terrible at. It provides over 9000 ways to do this
# and many of them are wrong. Here is one way that seems to work most of the time when we do it:
#
# Usage:
# # Be sure the variable CompilerDesignNix is set to "ON" or "OFF".
# # Be sure that all the CompilerIsXXXX variables are set correctly.
# # The easiest way to do both of those is to use IdentifyCompiler().
# # Also set the CPU flags set by IdentifyCPU correcting for the platform you are building for.
# SetCommonCompilerFlags()
#
# Results:
# Compiler flags are set that do the following:
# Enable a ton of warnings.
# Treat warnings as errors are set.
# Turn off compiler logos.
# Enable Position independent code or otherwise fix linker issues.
# Turn on C++17.
#
macro(SetCommonCompilerFlags)
if(CompilerDesignNix)
# These warnings work will work on all nix style compilers. Here are the most important flags:
# -std=c++17 - Set the C++ standard to C++17.
# -fno-strict-aliasing - Required for linking some of the Mezzanine dependencies correctly.
# -Wall - Enables "all" compiler warnings, actually abour 2/3rds, including common stuff like bad inits.
# -Wextra - Enable the rest of the warnings except some sketchy ones.
# -Werror - Turn all warnings into errors.
# -pedantic-errors - Warn for accidental use of compiler extensions or undefined behavior.
#
# These exist to prevent issues well before they become issues:
# -Wcast-align - When a cast changes alignment to a larger boundary, added because theorhetical performance.
# -Wcast-qual - When CV qualifiers are changed, these are almost always bugs.
# -Wctor-dtor-privacy - All private constructors when they probably ought to be deleted.
# -Wdisabled-optimization - Code to complex to be optimized, also means code is too complex to be maintained.
# -Wformat=2 - Adds extra checks for security and y2k and other easily static checkable things.
# -Wmissing-declarations - Mandate function prototypes.
# -Wmissing-include-dirs - Directory passed on command line does not exist.
# -Wold-style-cast - C-style casts are errors, which they should be because they are crazy.
# -Wredundant-decls - This stops, if you read the name you can probpably guess it, redudant declarations.
# -Wshadow - A variable in a more local scope has teh same name as one is a larger/higher scope.
# -Wconversion - Sign conversions and stuff that cause data loss, used to be -Wsign-conversion.
# -Wsign-promo - Prevent issues with enums and ints choosing a signed version of a datatype when using unsigned.
# -Wstrict-overflow=2 - When the compiler re-arranges some math that might cause an integer overflow.
# -Wundef - Fail when undeclared preprocessor macros are used, almost always a bug/platform error.
#
# Warning supression - These hurt more than help
# -Wno-weak-vtables - weak vtables aren't an issue because compiler remove dupes and source access removes risk.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-std=c++17 -Wall -Wextra -Werror -pedantic-errors \
-Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Wmissing-declarations \
-Wmissing-include-dirs -Wold-style-cast -Wredundant-decls -Wshadow -Wconversion -Wsign-promo \
-Wstrict-overflow=2 -Wundef")
# Emscripten is a unique beast.
if(CompilerIsEmscripten)
# The same warnings as clang.
set(CMAKE_CXX_FLAGS "-s DISABLE_EXCEPTION_CATCHING=0 ${CMAKE_CXX_FLAGS} -Weverything \
-Wno-documentation-unknown-command -Wno-c++98-compat -Wno-weak-vtables")
# This is exe on windows and nothing on most platforms, but without this emscripten output is... wierd.
set(CMAKE_EXECUTABLE_SUFFIX ".js")
else(CompilerIsEmscripten)
# Store thread library link information for later.
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
# A few checks that are very specific.
if(CpuIsAmd64 AND Platform64Bit)
if(MEZZ_Force32Bit)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
else(MEZZ_Force32Bit)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
endif(MEZZ_Force32Bit)
endif(CpuIsAmd64 AND Platform64Bit)
if(SystemIsLinux)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif(SystemIsLinux)
if(CompilerIsGCC)
if(NOT SystemIsMacOSX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++fs")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
endif(NOT SystemIsMacOSX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op -Wnoexcept -Wstrict-null-sentinel")
endif(CompilerIsGCC)
if(CompilerIsClang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything \
-Wno-documentation-unknown-command -Wno-c++98-compat -Wno-weak-vtables")
if(NOT SystemIsMacOSX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wctad-maybe-unsupported")
endif(NOT SystemIsMacOSX)
endif(CompilerIsClang)
endif(CompilerIsEmscripten)
if(NOT MEZZ_Debug)
# TODO - This needs to respect crosscompiling situations.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mtune=native")
endif(NOT MEZZ_Debug)
# Removed -Winline it did not seem useful.
# He are some flags suggested for use an why they were not used:
# -Woverloaded-virtual - What did the author of this think virtual methods were for if not
# to be overloaded. This disagrees with explicit design decisions.
# -Wmisleading-indentation - Help find errors revolving around tabs and control flow. I
# want to enable this, but not until GCC 6.
# -DDEBUG_DIRECTOR_EXCEPTION # Used to make swig emit more.
else(CompilerDesignNix)
if(CompilerIsMsvc)
# Used:
# /std:c++17 - Enables C++17 as the language standard.
# /nologo - Skips a few lines of microsoft branding.
# /Wall - Enable all warnings.
# /WX - treat warnings as errors.
# /MT - Statically link against the threading capable standard library.
# Ignoring:
# C4710 - Failing to inline things in std::string, well that is STL's fault, not mine.
# C4514 - An unused function was optimized out. Why is the optimizer doing its job a warning?!
# C4251 - Is safe to ignore per STL
# http://stackoverflow.com/questions/24511376/how-to-dllexport-a-class-derived-from-stdruntime-error
# C4820 - When padding is added for performance reasons.
# C4987 - A garbage error about "throw(...)" not being standard.
# C4626, C4625, C4623, C5026, C5027 - BS about implicitly removed default functions, with no workarounds,
# because all of these all core parts of C++. It is the moral equivalent of warning on "a=b;" because
# could be overwritten and errors will arise if the previous value of "a" is needed.
# C4365 - This is actually a useful warning about conversions changing signedness, but 50+ are thrown from
# the std lib for builds as simple as the just Mezz_StaticFoundation.
# C4774 - BS warning about some sprintf derivative we never use.
# C4866 - BS warning about operator ordering, which even triggers in MSVC stdlib.
# C4996 - Attempts to force "_s" versions of standard library methods, not all of which are cross-platform.
# C5039 - BS warning thrown in the bowels of never included windows headers.
# C5045 - Alerts to when compiler would add instructions to mitigate Spectre if /Qspectre switch were used.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /nologo /Wall /WX /MT \
/wd4710 /wd4514 /wd4251 /wd4820 /wd4571 /wd4626 /wd4625 /wd5026 /wd5027 /wd4221 /wd4711 \
/wd4987 /wd4365 /wd4774 /wd4623 /wd4866 /wd4996 /wd5039 /wd5045"
)
else(CompilerIsMsvc)
message(FATAL_ERROR
"Your compiler is not GCC compatible and not MSVC... Add this mysterious software's flags here."
)
endif(CompilerIsMsvc)
endif(CompilerDesignNix)
if("${ParentProject}" STREQUAL "${PROJECT_NAME}")
message(STATUS "C++ compiler and linker flags: ${CMAKE_CXX_FLAGS}")
endif("${ParentProject}" STREQUAL "${PROJECT_NAME}")
endmacro(SetCommonCompilerFlags)
########################################################################################################################
# SetProjectVariables
#