This repository has been archived by the owner on Apr 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
executable file
·1705 lines (1485 loc) · 58.6 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_minimum_required(VERSION 3.5)
set(BASE_STANDALONE FALSE) # TODO
# project() must be before checks, see https://stackoverflow.com/a/26437667/10904212
set(PROJECT_NAME "skemgl")
set(PROJECT_VERSION 1.0.0.1)
project(${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
LANGUAGES CXX C)
# --------------------------- conan configuration ------------------------------
# Conan package manager List of packages used by the project is container in
# conanfile.py
option(CONAN_AUTO_INSTALL "Let CMake call conan install automatically"
OFF
)
if (CONAN_AUTO_INSTALL)
set(CONAN_PROFILE
"default"
CACHE STRING "Conan profile to use during installation")
include(cmake/conan-auto-install.cmake)
conan_auto_install(${CONAN_PROFILE})
endif()
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR}/)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake OPTIONAL)
conan_basic_setup(
# prevent conan_basic_setup from resetting cmake variables
TARGETS
KEEP_RPATHS
# see https://github.com/conan-io/conan/issues/6012
NO_OUTPUT_DIRS)
else()
message (FATAL_ERROR "must use conan")
endif()
find_package(cmake_platform_detection REQUIRED)
run_cmake_platform_detection()
find_package(cmake_build_options REQUIRED)
setup_default_build_type(RELEASE)
setup_cmake_build_options(RELEASE DEBUG)
find_package(cobalt_glm REQUIRED)
find_package(chromium_build_util REQUIRED)
if(TARGET chromium_build_util::chromium_build_util-static)
set(build_util_LIB chromium_build_util::chromium_build_util-static)
else()
message(FATAL_ERROR "not supported: using system provided chromium_build_util library")
endif()
# cobalt
set(ENABLE_COBALT TRUE CACHE BOOL "ENABLE_COBALT")
message(STATUS "ENABLE_COBALT = ${ENABLE_COBALT}")
if(ENABLE_COBALT)
find_package(cobalt_starboard_headers_only REQUIRED)
if(TARGET cobalt_starboard_headers_only::cobalt_starboard_headers_only-static)
set(cobalt_starboard_headers_only_LIB cobalt_starboard_headers_only::cobalt_starboard_headers_only-static)
else()
message(FATAL_ERROR "not supported: using system provided cobalt_starboard_headers_only library")
endif()
find_package(cobalt_starboard REQUIRED)
if(TARGET cobalt_starboard::cobalt_starboard-static)
set(cobalt_starboard_LIB cobalt_starboard::cobalt_starboard-static)
else()
message(FATAL_ERROR "not supported: using system provided cobalt_starboard library")
endif()
find_package(cobalt_nanobase REQUIRED)
if(TARGET cobalt_nanobase::cobalt_nanobase-static)
set(cobalt_nanobase_LIB cobalt_nanobase::cobalt_nanobase-static)
else()
message(FATAL_ERROR "not supported: using system provided cobalt_nanobase library")
endif()
find_package(cobalt_base REQUIRED)
if(TARGET cobalt_base::cobalt_base-static)
set(cobalt_base_LIB cobalt_base::cobalt_base-static)
else()
message(FATAL_ERROR "not supported: using system provided cobalt_base library")
endif()
endif(ENABLE_COBALT)
find_package(chromium_base REQUIRED)
if(TARGET chromium_base::chromium_base-static)
set(base_LIB chromium_base::chromium_base-static)
else()
message(FATAL_ERROR "not supported: using system provided chromium_base library")
endif()
find_package(chromium_url REQUIRED)
if(TARGET chromium_url::chromium_url-static)
set(url_LIB chromium_url::chromium_url-static)
else()
message(FATAL_ERROR "not supported: using system provided chromium_url library")
endif()
set(USE_ICU TRUE CACHE BOOL "USE_ICU")
if(USE_ICU)
set(USE_CUSTOM_ICU TRUE)
endif(USE_ICU)
#
# ICU
#
if(USE_ICU)
set(COMMON_FLAGS "${COMMON_FLAGS} -DHAS_ICU=1")
if(NOT DEFINED USE_CUSTOM_ICU)
message(FATAL_ERROR "need to define USE_CUSTOM_ICU")
endif(NOT DEFINED USE_CUSTOM_ICU)
if(USE_CUSTOM_ICU)
# chromium_icu
if(TARGET_LINUX OR TARGET_EMSCRIPTEN)
find_package(chromium_icu REQUIRED)
if(NOT TARGET chromium_icu::chromium_icu-static)
message(FATAL_ERROR "not supported: using system provided chromium_icu library")
endif()
elseif(TARGET_WINDOWS)
# skip
else()
message(FATAL_ERROR "chromium_icu not found")
endif()
#
set(COMMON_FLAGS "${COMMON_FLAGS} -DUSE_CUSTOM_ICU=1")
set(CUSTOM_ICU_LIB chromium_icu::chromium_icu-static) # see icu.cmake
else()
set(CUSTOM_ICU_LIB icu) # platform specific
message(FATAL_ERROR "TODO: supports not only USE_CUSTOM_ICU")
endif(USE_CUSTOM_ICU)
endif(USE_ICU)
#
if(NOT DEFINED CUSTOM_ICU_LIB)
message(FATAL_ERROR "CUSTOM_ICU_LIB must be defined")
endif(NOT DEFINED CUSTOM_ICU_LIB)
# TODO: move to base
# ${dynamic_annotations_LIB}
if(TARGET_LINUX)
# ENABLE_DYNAMIC_ANNOTATIONS option defines DYNAMIC_ANNOTATIONS_ENABLED=1
# NOTE: we always need to link with dynamic_annotations
set(ENABLE_DYNAMIC_ANNOTATIONS TRUE) # required by tcmalloc
elseif(TARGET_EMSCRIPTEN OR TARGET_WINDOWS)
set(ENABLE_DYNAMIC_ANNOTATIONS FALSE)
else()
message(FATAL_ERROR "unknown platform")
endif()
if(NOT DEFINED ENABLE_DYNAMIC_ANNOTATIONS)
message(FATAL_ERROR "ENABLE_DYNAMIC_ANNOTATIONS must be defined")
endif(NOT DEFINED ENABLE_DYNAMIC_ANNOTATIONS)
find_package(chromium_dynamic_annotations REQUIRED)
if(TARGET chromium_dynamic_annotations::chromium_dynamic_annotations-static)
set(dynamic_annotations_LIB chromium_dynamic_annotations::chromium_dynamic_annotations-static)
else()
message(FATAL_ERROR "not supported: using system provided dynamic_annotations library")
endif()
if(TARGET_LINUX)
find_package(chromium_tcmalloc REQUIRED)
if(TARGET chromium_tcmalloc::chromium_tcmalloc-static)
set(tcmalloc_LIB chromium_tcmalloc::chromium_tcmalloc-static)
else()
message(FATAL_ERROR "not supported: using system provided chromium_tcmalloc library")
endif()
elseif(TARGET_WINDOWS OR TARGET_EMSCRIPTEN)
# skip
else()
message(FATAL_ERROR "platform not supported")
endif()
#if(TARGET_LINUX)
# # xdg_mime
# include(xdg_mime.cmake)
# # xdg_user_dirs
# include(xdg_user_dirs.cmake)
#elseif(TARGET_WINDOWS OR TARGET_EMSCRIPTEN)
# # skip
#else()
# message(FATAL_ERROR "platform not supported")
#endif()
# xdg_user_dirs
if(TARGET_LINUX)
find_package(chromium_xdg_user_dirs REQUIRED)
if(TARGET chromium_xdg_user_dirs::chromium_xdg_user_dirs-static)
set(xdg_user_dirs_LIB chromium_xdg_user_dirs::chromium_xdg_user_dirs-static)
else()
message(FATAL_ERROR "not supported: using system provided xdg_user_dirs library")
endif()
elseif(TARGET_WINDOWS OR TARGET_EMSCRIPTEN)
# skip
else()
message(FATAL_ERROR "platform no supported")
endif()
# xdg_mime
if(TARGET_LINUX)
find_package(chromium_xdg_mime REQUIRED)
if(TARGET chromium_xdg_mime::chromium_xdg_mime-static)
set(xdg_mime_LIB chromium_xdg_mime::chromium_xdg_mime-static)
else()
message(FATAL_ERROR "not supported: using system provided xdg_mime library")
endif()
elseif(TARGET_WINDOWS OR TARGET_EMSCRIPTEN)
# skip
else()
message(FATAL_ERROR "platform no supported")
endif()
# libevent
if(TARGET_LINUX)
find_package(chromium_libevent REQUIRED)
if(TARGET chromium_libevent::chromium_libevent-static)
set(libevent_LIB chromium_libevent::chromium_libevent-static)
else()
message(FATAL_ERROR "not supported: using system provided libevent library")
endif()
elseif(TARGET_WINDOWS OR TARGET_EMSCRIPTEN)
# skip
else()
message(FATAL_ERROR "platform no supported")
endif()
# modp_b64
find_package(chromium_modp_b64 REQUIRED)
if(TARGET chromium_modp_b64::chromium_modp_b64-static)
set(modp_b64_LIB chromium_modp_b64::chromium_modp_b64-static)
else()
message(FATAL_ERROR "not supported: using system provided modp_b64 library")
endif()
set(ENABLE_ZLIB TRUE CACHE BOOL "ENABLE_ZLIB")
if(TARGET_EMSCRIPTEN)#OR TARGET_LINUX)
set(USE_SYSTEM_ZLIB TRUE CACHE BOOL "USE_SYSTEM_ZLIB")
else()
set(USE_SYSTEM_ZLIB FALSE CACHE BOOL "USE_SYSTEM_ZLIB")
endif(TARGET_EMSCRIPTEN)
# chromium_zlib
if(NOT USE_SYSTEM_ZLIB)
find_package(chromium_zlib REQUIRED)
if(TARGET chromium_zlib::chromium_zlib-static)
if(DEFINED zlib_LIB)
message(FATAL_ERROR "REDEFINITION: zlib_LIB")
endif(DEFINED zlib_LIB)
set(zlib_LIB chromium_zlib::chromium_zlib-static)
else()
message(FATAL_ERROR "not supported: using system provided chromium_zlib library")
endif()
endif(NOT USE_SYSTEM_ZLIB)
# chromium_libxml
find_package(chromium_libxml REQUIRED)
if(TARGET chromium_libxml::chromium_libxml-static)
set(libxml_LIB chromium_libxml::chromium_libxml-static)
else()
message(FATAL_ERROR "not supported: using system provided chromium_libxml library")
endif()
# compact_enc_det
set(ENABLE_COMPACT_ENC_DET TRUE)
if(NOT ENABLE_COMPACT_ENC_DET)
set(COMMON_FLAGS "${COMMON_FLAGS} -DDISABLE_COMPACT_ENC_DET=1")
endif(NOT ENABLE_COMPACT_ENC_DET)
if(ENABLE_COMPACT_ENC_DET)
find_package(chromium_compact_enc_det REQUIRED)
if(TARGET chromium_compact_enc_det::chromium_compact_enc_det-static)
set(ced_LIB chromium_compact_enc_det::chromium_compact_enc_det-static)
else()
message(FATAL_ERROR "not supported: using system provided compact_enc_det library")
endif()
endif(ENABLE_COMPACT_ENC_DET)
# this sets the paths that cmake will use to locate libs (via the FindXXX.cmake or XXConfig.cmake scripts)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/SDL2)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils/checks)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils/options)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils/options/chromium)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
# ------------------------- External CMake includes ----------------------------
# CMake-provided scripts
include(ExternalProject)
include(CheckCXXCompilerFlag)
include(CheckSymbolExists)
include(TestBigEndian)
include(CheckIncludeFile)
include(CheckLibraryExists)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# Helper module for selecting option based on multiple values. Module help:
# https://cmake.org/cmake/help/v3.10/module/CMakeDependentOption.html
include(CMakeDependentOption)
# ------------------------------- Options --------------------------------------
include(ConfigSafeGuards)
include(ForceLatinPaths)
include(PlatformChecks)
include(BuildOptions)
include(CommonOptions)
if(TARGET_EMSCRIPTEN)
include(EmscriptenOptions)
endif(TARGET_EMSCRIPTEN)
include(ChromiumOptions)
include(GLEW_Options)
include(Threads_Options)
include(LibDL_Options)
include(GLES2_Options)
include(GL_Options)
include(SDL2_Options)
include(ZLIB_Options)
include(CXTPLOptions)
include(freetype_Options)
include(harfbuzz_Options)
if(RELEASE_BUILD AND NOT TARGET_EMSCRIPTEN)
include(StripDebugSymbols)
endif(RELEASE_BUILD AND NOT TARGET_EMSCRIPTEN)
include(SetOptimizeFlags)
# --------------------------------- Utils --------------------------------------
include(Utils)
# ------------------------------ Project files ---------------------------------
include(ProjectFiles)
# --------------------------- CMake configuration ------------------------------
# set_cmake_module_paths from Utils.cmake
set_cmake_module_paths( ${PROJECT_NAME}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/submodules/CXTPL/cmake/exports")
# prevent_in_source_builds from Utils.cmake
prevent_in_source_builds()
# check_supported_os from Utils.cmake
check_supported_os()
if(NOT EMSCRIPTEN)
option(USE_LD_GOLD "Use GNU gold linker" ON)
# add_gold_linker from Utils.cmake
add_gold_linker()
option(USE_CCACHE "Use CCACHE" ON)
# add_ccache from Utils.cmake
add_ccache()
endif(NOT EMSCRIPTEN)
find_threads()
# ------------------------- print_cmake_system_info ----------------------------
# print_cmake_system_info from Utils.cmake
print_cmake_system_info()
# ------------------------------- definitions ----------------------------------
if(NOT RELEASE_BUILD)
if(TARGET_WINDOWS)
set(COMMON_FLAGS "${COMMON_FLAGS} /D_DEBUG") #
endif(TARGET_WINDOWS)
#
set(COMMON_FLAGS "${COMMON_FLAGS} -DD_DEBUG") #
endif(NOT RELEASE_BUILD)
if(NOT TARGET_WINDOWS)
# always return on non-void functions to prevent UB
set(COMMON_FLAGS "${COMMON_FLAGS} -Wreturn-type")
# https://gist.github.com/morido/8637535
set(COMMON_FLAGS "${COMMON_FLAGS} -Werror=return-type")
endif(NOT TARGET_WINDOWS)
if(RELEASE_BUILD)
list(APPEND APP_DEFINITIONS RELEASE_BUILD=1)
endif(RELEASE_BUILD)
list(APPEND APP_DEFINITIONS SDL_MAIN_HANDLED=1)
list(APPEND APP_DEFINITIONS ENABLE_OPENGL=1)
list(APPEND APP_DEFINITIONS ENABLE_CUSTOM_FONTS=1)
list(APPEND APP_DEFINITIONS HARFBUZZ_UNICODE=1)
list(APPEND APP_DEFINITIONS ENABLE_SK_EFFECTS=1)
if(NOT ENABLE_NATIVE_HTML)
list(APPEND APP_DEFINITIONS ENABLE_EMSCRIPTEN_INPUT=1)
endif(NOT ENABLE_NATIVE_HTML)
if(ENABLE_SKIA)
list(APPEND APP_DEFINITIONS ENABLE_SK_UI=1)
list(APPEND APP_DEFINITIONS ENABLE_IMAGES=1)
endif(ENABLE_SKIA)
if(ENABLE_MAIN)
list(APPEND APP_DEFINITIONS ENABLE_MAIN=1)
endif(ENABLE_MAIN)
include_directories( # TODO: use target_include_directories
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
# # TODO
# #set(COMMON_CXX_FLAGS "-DNEED_SHORT_EXTERNAL_NAMES=1")
# -fno-exceptions
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
## set(CMAKE_CXX_STANDARD 17)
## set(CMAKE_CXX_STANDARD_REQUIRED ON)
## set(CMAKE_CXX_EXTENSIONS OFF) # -std=c++11 instead of -std=gnu++11
if(TARGET_WINDOWS)
# see http://clang.llvm.org/docs/UsersManual.html#clang-cl
set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /std:c++17")
else()
set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -std=c++17") # use target options
endif()
# see https://github.com/chromium/chromium/blob/master/build/config/compiler/BUILD.gn#L683
#set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -ftime-trace")
# see https://aras-p.info/blog/2019/01/12/Investigating-compile-times-and-Clang-ftime-report/
#set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -ftime-report")
# TODO
set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -DCODEC_IMPLEMENTATION=1")
# TODO:
# https://github.com/ambiesoft/gsrc/blob/199d762d322087c67cec2e9f1aaa7bfd5e0eb4c4/info/20180715-builderror-220332.txt#L76
# https://groups.google.com/a/chromium.org/forum/#!topic/gn-dev/-PraKAwRlV8
# https://developercommunity.visualstudio.com/content/problem/339089/arm64-conversion-issue-error-c2440-initializing-1.html
MATH(EXPR SIZEOF_VOID_P_BITS "${CMAKE_SIZEOF_VOID_P}*8")
set(COMMON_FLAGS "${COMMON_FLAGS} -DSIZEOF_VOID_P=${SIZEOF_VOID_P_BITS}")
message(STATUS "DSIZEOF_VOID_P=${SIZEOF_VOID_P_BITS}")
set(COMMON_FLAGS "${COMMON_FLAGS} -DUI_VIEWS_PORT=1")
if(MSVC) # TODO
# see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-by-compiler-version?view=vs-2019
#set(COMMON_FLAGS "${COMMON_FLAGS} -DWCHAR_T_IS_UTF16=1") # TODO: narrowing
#set(COMMON_FLAGS "${COMMON_FLAGS} /wd2397") # TODO: narrowing
#set(COMMON_FLAGS "${COMMON_FLAGS} /wd2398") # TODO: narrowing
#set(COMMON_FLAGS "${COMMON_FLAGS} /wd2440") # TODO: narrowing
#set(COMMON_FLAGS "${COMMON_FLAGS} /wd2712") # TODO: Cannot use __try in functions that require object unwinding
# https://docs.microsoft.com/en-us/cpp/build/reference/gf-eliminate-duplicate-strings?view=vs-2019
#set(COMMON_FLAGS "${COMMON_FLAGS} /GF")
# https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=vs-2019
#set(COMMON_FLAGS "${COMMON_FLAGS} /Zi")
# https://docs.microsoft.com/en-us/cpp/build/reference/tc-tp-tc-tp-specify-source-file-type?view=vs-2019
#set(COMMON_FLAGS "${COMMON_FLAGS} /TP")
# TODO: https://stackoverflow.com/a/34630892
# https://docs.microsoft.com/en-us/cpp/build/reference/za-ze-disable-language-extensions?view=vs-2019
# set(COMMON_FLAGS "${COMMON_FLAGS} /Za")
# unknown option
#set(COMMON_FLAGS "${COMMON_FLAGS} /permissive")
set(COMMON_FLAGS "${COMMON_FLAGS} -DCOMPILER_MSVC=1")
# https://docs.microsoft.com/en-us/cpp/build/reference/zc-strictstrings-disable-string-literal-type-conversion?view=vs-2019
set(COMMON_FLAGS "${COMMON_FLAGS} /Zc:strictStrings-")
# https://docs.microsoft.com/en-us/cpp/build/reference/gd-gr-gv-gz-calling-convention?view=vs-2019
#set(COMMON_FLAGS "${COMMON_FLAGS} /Gv")
# https://docs.microsoft.com/en-us/cpp/build/reference/gt-support-fiber-safe-thread-local-storage?view=vs-2019
set(COMMON_FLAGS "${COMMON_FLAGS} /GT")
# https://docs.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=vs-2019
set(COMMON_FLAGS "${COMMON_FLAGS} /GS-")
set(COMMON_FLAGS "${COMMON_FLAGS} -D_CRT_SECURE_NO_WARNINGS=1")
# https://docs.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=vs-2019
set(COMMON_FLAGS "${COMMON_FLAGS} /sdl-")
#set(COMMON_FLAGS "${COMMON_FLAGS} /D__DATE__=")
#set(COMMON_FLAGS "${COMMON_FLAGS} /D__TIME__=")
#set(COMMON_FLAGS "${COMMON_FLAGS} /D__TIMESTAMP__=")
#set(COMMON_FLAGS "${COMMON_FLAGS} /d2FastFail")
# https://docs.microsoft.com/en-us/cpp/build/reference/wx-treat-linker-warnings-as-errors?view=vs-2019
#set(COMMON_FLAGS "${COMMON_FLAGS} /WX")
set(COMMON_FLAGS "${COMMON_FLAGS} -DWIN32_LEAN_AND_MEAN")
# LDFLAGS https://git.m4xw.net/Switch/RetroArch/beetle-pce-fast-libretro/commit/48a734c9dc36905fa6779303fb1c80003bce4853?w=1
#set(COMMON_FLAGS "${COMMON_FLAGS} -SUBSYSTEM:CONSOLE")
#set(COMMON_FLAGS "${COMMON_FLAGS} /SUBSYSTEM:CONSOLE")
#set(COMMON_FLAGS "${COMMON_FLAGS} /SUBSYSTEM:WINDOWS")
set(COMMON_FLAGS "${COMMON_FLAGS} -D_CONSOLE=1")
#set(COMMON_FLAGS "${COMMON_FLAGS} -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L276
set(COMMON_FLAGS "${COMMON_FLAGS} -DNTDDI_VERSION=NTDDI_WIN10_RS2")
set(COMMON_FLAGS "${COMMON_FLAGS} -D_WIN32_WINNT=0x0A00")
set(COMMON_FLAGS "${COMMON_FLAGS} -DWINVER=0x0A00")
# Exceptions in allocator shim are not supported!
# see https://github.com/chromium/chromium/blob/5514bb10d8770fea460152d278f105895067aa38/build/config/compiler/BUILD.gn#L1775
# TODO: /EHsc- # Disabling Exceptions for MSVC
set(COMMON_FLAGS "${COMMON_FLAGS} /EHsc-")
# https://stackoverflow.com/questions/1372480/c-redefinition-header-files-winsock2-h
set(COMMON_FLAGS "${COMMON_FLAGS} -D_WINSOCKAPI_=1")
set(COMMON_FLAGS "${COMMON_FLAGS} -D_HAS_EXCEPTIONS=0")
# see https://github.com/jarro2783/cxxopts/issues/49
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L601
set(COMMON_FLAGS "${COMMON_FLAGS} -DNOMINMAX=1")
set(COMMON_FLAGS "${COMMON_FLAGS} -DHB_NO_MT=1") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} -D_WIN32=1") # TODO
# https://github.com/blockspacer/skia-opengl-emscripten/blob/8390245e4aadd160d99e297968594bb6ad86caaa/src/chromium/third_party/ced/BUILD.gn#L57
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4005") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4006") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4018") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4309") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4310") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4267") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} -D_CRT_NONSTDC_NO_WARNINGS=1") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} -D_CRT_NONSTDC_NO_DEPRECATE=1") # TODO
# see https://github.com/chromium/chromium/blob/5514bb10d8770fea460152d278f105895067aa38/build/config/compiler/BUILD.gn#L1093
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4117") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4800") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4267") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4996") # TODO
# see https://github.com/chromium/chromium/blob/5514bb10d8770fea460152d278f105895067aa38/build/config/compiler/BUILD.gn#L1093
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4091") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4127") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4251") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4275") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4312") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4324") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4351") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4355") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4589") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4611") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4100") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4121") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4244") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4505") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4510") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4512") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4610") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4838") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4995") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4996") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4456") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4457") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4458") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4459") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4200") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4201") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4204") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4221") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4245") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4267") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4305") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4389") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4702") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4701") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4703") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4661") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4706") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4715") # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /wd4577") # TODO
endif(MSVC)
if(RELEASE_BUILD)
if(MSVC) # TODO
set(COMMON_FLAGS "${COMMON_FLAGS} /GR-")
#set(COMMON_FLAGS "${COMMON_FLAGS} -fno-exceptions")
set(COMMON_FLAGS "${COMMON_FLAGS} -DNDEBUG=1")
#
# see https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019
set(COMMON_FLAGS "${COMMON_FLAGS} /MD")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MD")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
else()
if(ENABLE_EMBIND)
# see https://github.com/emscripten-core/emscripten/issues/7001
# see https://github.com/emscripten-core/emscripten/issues/9122
# set(COMMON_FLAGS "${COMMON_FLAGS} -frtti")
set(COMMON_FLAGS "${COMMON_FLAGS} -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0")
set(COMMON_FLAGS "${COMMON_FLAGS} -fno-rtti")
else()
set(COMMON_FLAGS "${COMMON_FLAGS} -fno-rtti")
endif(ENABLE_EMBIND)
set(COMMON_FLAGS "${COMMON_FLAGS} -fno-exceptions")
set(COMMON_FLAGS "${COMMON_FLAGS} -DNDEBUG=1")
endif()
else()
if(MSVC) # TODO
# https://stackoverflow.com/a/4184877/10904212
# see DCHECK in base::polymorphic_downcast, dynamic_cast
set(COMMON_FLAGS "${COMMON_FLAGS} /GR")
# see https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2019
set(COMMON_FLAGS "${COMMON_FLAGS} /MDd")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MDd")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
# TODO
# see https://stackoverflow.com/questions/7668200/error-lnk2038-mismatch-detected-for-iterator-debug-level-value-0-doesnt
# see https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/hh697468(v=vs.120)?redirectedfrom=MSDN
set(COMMON_FLAGS "${COMMON_FLAGS} -D_HAS_ITERATOR_DEBUGGING=0")
set(COMMON_FLAGS "${COMMON_FLAGS} -D_ITERATOR_DEBUG_LEVEL=0")
set(COMMON_FLAGS "${COMMON_FLAGS} -D_DEBUG=1") #
else()
# https://stackoverflow.com/a/4184877/10904212
# see DCHECK in base::polymorphic_downcast, dynamic_cast
set(COMMON_FLAGS "${COMMON_FLAGS} -frtti")
set(COMMON_FLAGS "${COMMON_FLAGS} -D_DEBUG=1") #
endif()
endif(RELEASE_BUILD)
if(MSVC) # TODO
#
set(COMMON_FLAGS "${COMMON_FLAGS} -ferror-limit=500") # for clang-cl
#set(COMMON_FLAGS "${COMMON_FLAGS} /errorlimit:0")
# see https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949
set(COMMON_FLAGS "${COMMON_FLAGS} -fcolor-diagnostics") # for clang-cl
# see https://software.intel.com/en-us/forums/intel-c-compiler/topic/733662
# see https://unicode-org.atlassian.net/browse/ICU-13251?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
set(COMMON_FLAGS "${COMMON_FLAGS} /utf-8")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} /Gy")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} /FS")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} /bigobj")
# see https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=vs-2019
set(COMMON_FLAGS "${COMMON_FLAGS} /Zc:__cplusplus")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} /Zc:sizedDealloc-")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} -D__STD_C")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} -D_CRT_RAND_S")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
#set(COMMON_FLAGS "${COMMON_FLAGS} -D_CRT_SECURE_NO_DEPRECATE")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
#set(COMMON_FLAGS "${COMMON_FLAGS} -D_SCL_SECURE_NO_DEPRECATE")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
#set(COMMON_FLAGS "${COMMON_FLAGS} -D_ATL_NO_OPENGL")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} -D_WINDOWS")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} -DPSAPI_VERSION=2")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} -DWIN32")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} -D_SECURE_ATL")
# see https://github.com/chromium/chromium/blob/8e82c6ab1bc2223fa25f1a127b65071d2d58ae36/build/config/win/BUILD.gn#L60
set(COMMON_FLAGS "${COMMON_FLAGS} -D_USING_V110_SDK71_")
endif()
if(ENABLE_COBALT AND NOT RELEASE_BUILD)
list(APPEND COBALT_COMMON_DEFINES COBALT_BUILD_TYPE_DEBUG=1)
list(APPEND COBALT_COMMON_DEFINES COBALT_BUILD_TYPE_DEVEL=1)
# TODO # ENABLE_DEBUGGER
# TODO # COBALT_BUILD_TYPE_QA
# TODO # COBALT_ENABLE_JAVASCRIPT_ERROR_LOGGING
# TODO # COBALT_SECURITY_SCREEN_CLEAR_TO_UGLY_COLOR
# TODO # ENABLE_DEBUG_COMMAND_LINE_SWITCHES
# TODO # ENABLE_DEBUG_C_VAL
# TODO # ENABLE_DEBUG_CONSOLE
# TODO # ENABLE_IGNORE_CERTIFICATE_ERRORS
# TODO # ENABLE_PARTIAL_LAYOUT_CONTROL
# TODO # ENABLE_TEST_DATA
# TODO # ENABLE_TEST_RUNNER
# TODO # COBALT_BOX_DUMP_ENABLED
# TODO # COBALT_FORCE_CSP
# TODO # COBALT_FORCE_HTTPS
# TODO # COBALT_BUILD_TYPE_GOLD
endif()
if(EMSCRIPTEN)
#set(COMMON_FLAGS "${COMMON_FLAGS} -DUSE_X11=0")
# custom define
set(COMMON_FLAGS "${COMMON_FLAGS} -DNO_CHROMIUM_WINDOW=1")
elseif(TARGET_LINUX)
set(COMMON_FLAGS "${COMMON_FLAGS} -DUSE_X11=1")
# custom define
set(COMMON_FLAGS "${COMMON_FLAGS} -DNO_CHROMIUM_WINDOW=1")
elseif(TARGET_WINDOWS)
#set(COMMON_FLAGS "${COMMON_FLAGS} -DUSE_X11=1") # TODO <<<
set(COMMON_FLAGS "${COMMON_FLAGS} -D_UNICODE=1") # TODO <<<
set(COMMON_FLAGS "${COMMON_FLAGS} -DUNICODE=1") # TODO <<<
set(COMMON_FLAGS "${COMMON_FLAGS} -DNO_TCMALLOC=1") # TODO <<<
# custom define
set(COMMON_FLAGS "${COMMON_FLAGS} -DNO_CHROMIUM_WINDOW=1")
else()
message(FATAL_ERROR "platform not supported")
endif()
# https://github.com/emscripten-core/emscripten/issues/4932
# https://github.com/kosh04/newlisp/blob/master/newlisp.h#L164
# TODO
if(TARGET_EMSCRIPTEN OR TARGET_LINUX)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_FILE_OFFSET_BITS=64")
set(COMMON_FLAGS "${COMMON_FLAGS} -D_LARGEFILE_SOURCE=1")
endif()
if(TARGET_EMSCRIPTEN)
# TODO: -mnontrapping-fptoint
elseif(TARGET_LINUX)
set(COMMON_FLAGS "${COMMON_FLAGS} -D_LARGEFILE64_SOURCE=1")
set(COMMON_FLAGS "${COMMON_FLAGS} -DHAVE_PTHREAD=1")
elseif(TARGET_WINDOWS)
#set(COMMON_FLAGS "${COMMON_FLAGS} -D_LARGEFILE64_SOURCE=1")
#set(COMMON_FLAGS "${COMMON_FLAGS} -DHAVE_PTHREAD=1")
else()
message(FATAL_ERROR "platform not supported")
endif()
# NVALGRIND used in tcmalloc and third_party/valgrind.h
set(COMMON_FLAGS "${COMMON_FLAGS} -DNVALGRIND=1")
if(USE_SK_GPU)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_SUPPORT_GPU=1") # skia_enable_gpu
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_SUPPORT_GPU") # skia_enable_gpu
else()
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_SUPPORT_GPU=0") # skia_enable_gpu
endif(USE_SK_GPU)
# see https://github.com/zenoalbisser/chromium/blob/e71f21b9b4b9b839f5093301974a45545dad2691/skia/BUILD.gn#L164
# see https://github.com/google/skia/blob/a6dc5c54e6f854c5d73d46d0ad2edbde9701e6d9/public.bzl#L596
if(TARGET_LINUX)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_BUILD_FOR_UNIX=1") # note: NOT from BUILD.gn
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_EXPONENT=1.2")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_CONTRAST=0.2")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_DEFAULT_FONT_CACHE_LIMIT=20971520")
elseif(TARGET_EMSCRIPTEN)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DPNG_SKIP_SETJMP_CHECK=1")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_EXPONENT=1.2")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_CONTRAST=0.2")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_DEFAULT_FONT_CACHE_LIMIT=20971520")
elseif(TARGET_WINDOWS)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_BUILD_FOR_WIN=1") # note: NOT from BUILD.gn
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_SRGB=1")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_CONTRAST=0.5")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_DEFAULT_FONT_CACHE_LIMIT=20971520")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DGR_GL_FUNCTION_TYPE=__stdcall")
elseif(TARGET_ANDROID)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_BUILD_FOR_ANDROID=1") # note: from BUILD.gn
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_BUILD_FOR_ANDROID=1") # note: from BUILD.gn
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DUSE_CHROMIUM_SKIA=1")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_APPLY_TO_A8=1")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_EXPONENT=1.4")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_CONTRAST=0.0")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_DEFAULT_FONT_CACHE_LIMIT=1048576")
elseif(TARGET_MAC)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_BUILD_FOR_MAC=1") # note: from BUILD.gn
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_METAL=1")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_SRGB=1")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_GAMMA_CONTRAST=0.0")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_DEFAULT_FONT_CACHE_LIMIT=20971520")
else()
message(FATAL_ERROR "platform not supported")
endif()
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_DISABLE_READBUFFER=1")
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DLIBANGLE_IMPLEMENTATION=1")
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DLIBGLESV2_IMPLEMENTATION=1")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DLIBEGL_IMPLEMENTATION=1")
# see modules/skottie/utils/SkottieUtils.cpp
if(ENABLE_SKOTTIE)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_INCLUDE_MANAGED_SKOTTIE=1")
endif(ENABLE_SKOTTIE)
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DANGLE_ENABLE_ESSL=1")
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DANGLE_ENABLE_GLSL=1")
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DANGLE_ENABLE_HLSL=1")
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DANGLE_ENABLE_OPENGL=1")
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DEGL_EGLEXT_PROTOTYPES=1")
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DGL_GLEXT_PROTOTYPES=1")
# https://github.com/klzgrad/naiveproxy/blob/master/src/third_party/skia/modules/skottie/BUILD.gn#L14
if(ENABLE_SKOTTIE)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_ENABLE_SKOTTIE=1")
endif(ENABLE_SKOTTIE)
find_glew()
find_LibDL()
find_GLES2()
find_GL()
find_SDL2()
# TODO: move to SDL2 from conan
if(TARGET_WINDOWS)
if(DEFINED SDL2_INCLUDE_DIRS AND SDL2_INCLUDE_DIRS)
list(APPEND SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS}/..) # TODO: hack to include SDL2/SDL.h on windows
endif(DEFINED SDL2_INCLUDE_DIRS AND SDL2_INCLUDE_DIRS)
if(DEFINED SDL2_INCLUDE_DIR AND SDL2_INCLUDE_DIR)
list(APPEND SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIR}/..) # TODO: hack to include SDL2/SDL.h on windows
endif(DEFINED SDL2_INCLUDE_DIR AND SDL2_INCLUDE_DIR)
endif(TARGET_WINDOWS)
if(TARGET_EMSCRIPTEN AND NOT USE_SYSTEM_ZLIB)
message(FATAL_ERROR "USE_SYSTEM_ZLIB on EMSCRIPTEN platform")
endif(TARGET_EMSCRIPTEN AND NOT USE_SYSTEM_ZLIB)
if(ENABLE_ZLIB AND USE_SYSTEM_ZLIB)
find_ZLIB()
endif(ENABLE_ZLIB AND USE_SYSTEM_ZLIB)
if(TARGET_WINDOWS)
set(USE_SYSTEM_FREETYPE TRUE)
endif(TARGET_WINDOWS)
if(USE_SYSTEM_FREETYPE)
find_freetype()
endif(USE_SYSTEM_FREETYPE)
if(ENABLE_HARFBUZZ AND NOT USE_CUSTOM_HARFBUZZ AND NOT HARFBUZZ_FROM_SKIA)
message(FATAL_ERROR "TODO: support for find_harfbuzz()")
find_harfbuzz()
endif(ENABLE_HARFBUZZ AND NOT USE_CUSTOM_HARFBUZZ AND NOT HARFBUZZ_FROM_SKIA)
set_optimize_flags()
if(NOT TARGET_EMSCRIPTEN)
if(USE_SK_GPU)
set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_ASSUME_GL=1")
endif(USE_SK_GPU)
endif(NOT TARGET_EMSCRIPTEN)
if(ENABLE_BASE)
set(COMMON_FLAGS "${COMMON_FLAGS} -DENABLE_BASE=1")
#list(APPEND APP_DEFINITIONS ENABLE_BASE_PREALLOC=1)
elseif(EMSCRIPTEN)
# NOTE: OS_EMSCRIPTEN defined by BASE otherwise
list(APPEND APP_DEFINITIONS OS_EMSCRIPTEN=1) # useful if base disabled
endif(ENABLE_BASE)
#
if(ENABLE_WTF)
# NOTE: WTF requires BASE
list(APPEND APP_DEFINITIONS ENABLE_WTF=1)
endif()
# NOTE: header from SKIA_EXT
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_USER_CONFIG_HEADER=\\\"${SKIA_EXT_DIR}config/SkUserConfig.h\\\"")
# NOTE: modified SkUserConfig.h
#set(SK_COMMON_FLAGS "${SK_COMMON_FLAGS} -DSK_REF_CNT_MIXIN_INCLUDE=\\\"${SKIA_EXT_DIR}config/sk_ref_cnt_ext_release.h\\\"")
#
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ICU_DEFINES}")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ICU_DEFINES}")
#
if(TARGET_EMSCRIPTEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMCC_COMMON}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EMCC_COMMON}")
endif(TARGET_EMSCRIPTEN)
#
# HARFBUZZ
#
if(TARGET_EMSCRIPTEN OR TARGET_LINUX OR TARGET_WINDOWS)
if(USE_CUSTOM_HARFBUZZ)
# NOTE: harfbuzz from skia on WINDOWS
if(NOT HARFBUZZ_FROM_SKIA)
include(harfbuzz.cmake)
endif(NOT HARFBUZZ_FROM_SKIA)
endif(USE_CUSTOM_HARFBUZZ)
else()
message(FATAL_ERROR "platform not supported")
endif()
#
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_C_FLAGS}")
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_CXX_FLAGS}")
#
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
#
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SK_COMMON_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SK_COMMON_FLAGS}")
if(ENABLE_SKIA)
#
# skia
#
include(skia.cmake)
# NOTE: HarfBuzz from skia on WINDOWS
if(HARFBUZZ_FROM_SKIA)
set(HARFBUZZ_LIBRARIES SKIA)
list(APPEND HARFBUZZ_INCLUDE_DIRS ${SKIA_CMAKE_ONLY_HEADERS})
include_directories(${HARFBUZZ_INCLUDE_DIRS})
#list(APPEND HARFBUZZ_EXTRA_DEFINES ${SKIA_DEFINES}) # TODO
endif()
endif()
message(STATUS "HARFBUZZ_LIBRARIES=${HARFBUZZ_LIBRARIES}")
message(STATUS "HARFBUZZ_INCLUDE_DIRS=${HARFBUZZ_INCLUDE_DIRS}")
if(ENABLE_GRE2)
include(${CHROMIUM_DIR}GRE2.cmake)
endif(ENABLE_GRE2)#
#if(ENABLE_GLIBXML)
# include(${CHROMIUM_DIR}GLIBXML.cmake)
#endif(ENABLE_GLIBXML)
if (USE_LIBPNG AND USE_CUSTOM_LIBPNG)
# GLIBPNG
include(${CHROMIUM_DIR}GLIBPNG.cmake)
endif()
if(USE_LIBJPEG AND USE_CUSTOM_LIBJPEG)
message(FATAL_ERROR "GLIBJPEG not supported yet")
# libjpeg: requires LIBXML
include(${CHROMIUM_DIR}GLIBJPEG.cmake)
endif(USE_LIBJPEG AND USE_CUSTOM_LIBJPEG)
if(USE_LIBJPEG_TURBO AND USE_CUSTOM_LIBJPEG_TURBO)
# GLIBJPEG_TURBO: requires LIBJPEG
include(${CHROMIUM_DIR}GLIBJPEG_TURBO.cmake)
endif(USE_LIBJPEG_TURBO AND USE_CUSTOM_LIBJPEG_TURBO)
if(ENABLE_LIBYUV)
include(${CHROMIUM_DIR}libyuv.cmake)
endif(ENABLE_LIBYUV)