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
/
skia.cmake
1353 lines (1225 loc) · 46.2 KB
/
skia.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
#
# Skia
# NOTE: use clang on ALL platforms
# If you depend on software rasterization, image decoding, or color space conversion
# and compile Skia with GCC, MSVC or another compiler,
# you will see dramatically worse performance
# NOTE: set clang-cl,
# see https://github.com/google/skia/blob/master/site/user/build.md#highly-recommended-build-with-clang-cl
# NOTE: to modify skia build flags/include dirs provide args to c_flags,
# cause SKIA_CMAKE_ONLY_HEADERS don`t affect skia gn build!
#
# case-insensitive match TODO: is debug, Debug, DEBUG all valid?
#if(CMAKE_BUILD_TYPE MATCHES "[dD][eE][bB][uU][gG]")
# set(IS_DEBUG_BUILD ON)
#else()
# set(IS_DEBUG_BUILD OFF)
# set(EXT_SKIA_OFFICIAL_BUILD "true")
#endif()
option(SKIA_FORCE_BUILD_MODE "" "") # TODO
macro(copy_lib_include_properties
SRC_LIB
OUT_VAR_NAME
NEED_APPEND_TO_CMAKE_INCLUDE_DIRECTORIES
NEED_INCLUDE_DIRECTORIES
NEED_INTERFACE_INCLUDE_DIRECTORIES
DEBUG_MODE)
# TODO: hack to pass library include dirs to GN
if(${NEED_INCLUDE_DIRECTORIES})
get_target_property(CUSTOM__INCLUDE_DIRECTORIES ${SRC_LIB} INCLUDE_DIRECTORIES)
message(FATAL_ERROR "CUSTOM__INCLUDE_DIRECTORIES=${CUSTOM__INCLUDE_DIRECTORIES}")
if(DEFINED CUSTOM__INCLUDE_DIRECTORIES
AND NOT "${CUSTOM__INCLUDE_DIRECTORIES}" STREQUAL "CUSTOM__INCLUDE_DIRECTORIES-NOTFOUND")
message(STATUS "CUSTOM__INCLUDE_DIRECTORIES=${CUSTOM__INCLUDE_DIRECTORIES}")
# NOTE: WITH trailing comma
foreach(prop ${CUSTOM__INCLUDE_DIRECTORIES})
# TODO: hack to pass library include dirs to GN
#file(TO_NATIVE_PATH ${prop} prop)
#string(REGEX REPLACE "/" "\\\\/" prop ${prop})
set(${OUT_VAR_NAME}
"${${OUT_VAR_NAME}}\"-I${prop}\", "
)
#if(NOT ${OUT_VAR_NAME} STREQUAL "")
# set(${OUT_VAR_NAME}
# # "${${OUT_VAR_NAME}}\"-I${prop}\", "
# "${${OUT_VAR_NAME}}, "
# )
#endif()
if(NOT EXISTS "${prop}")
message(FATAL_ERROR "include dir not found: ${prop}")
endif(NOT EXISTS "${prop}")
if(${DEBUG_MODE})
message(STATUS "copy_lib_include_properties: SRC_LIB=${SRC_LIB} ; prop = ${prop}")
endif(${DEBUG_MODE})
#list(APPEND SKIA_CMAKE_ONLY_HEADERS ${prop})
endforeach(prop)
endif()
#
if(${NEED_APPEND_TO_CMAKE_INCLUDE_DIRECTORIES})
list(APPEND SKIA_CMAKE_ONLY_HEADERS ${CUSTOM__INCLUDE_DIRECTORIES})
endif(${NEED_APPEND_TO_CMAKE_INCLUDE_DIRECTORIES})
endif(${NEED_INCLUDE_DIRECTORIES})
#
if(${NEED_INTERFACE_INCLUDE_DIRECTORIES})
get_target_property(CUSTOM__INTERFACE_INCLUDE_DIRECTORIES ${SRC_LIB} INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "${SRC_LIB}: CUSTOM__INTERFACE_INCLUDE_DIRECTORIES=${CUSTOM__INTERFACE_INCLUDE_DIRECTORIES}")
if(DEFINED CUSTOM__INTERFACE_INCLUDE_DIRECTORIES
AND NOT "${CUSTOM__INTERFACE_INCLUDE_DIRECTORIES}" STREQUAL "CUSTOM__INTERFACE_INCLUDE_DIRECTORIES-NOTFOUND")
message(STATUS "CUSTOM__INTERFACE_INCLUDE_DIRECTORIES=${CUSTOM__INTERFACE_INCLUDE_DIRECTORIES}")
# NOTE: WITH trailing comma
foreach(prop ${CUSTOM__INTERFACE_INCLUDE_DIRECTORIES})
# TODO: hack to pass library include dirs to GN
#file(TO_NATIVE_PATH ${prop} prop)
#string(REGEX REPLACE "/" "\\\\/" prop ${prop})
set(${OUT_VAR_NAME}
"${${OUT_VAR_NAME}}\"-I${prop}\", "
)
#if(NOT ${OUT_VAR_NAME} STREQUAL "")
# set(${OUT_VAR_NAME}
# #"${${OUT_VAR_NAME}}\"-I${prop}\", "
# "${${OUT_VAR_NAME}}, "
# )
#endif()
if(NOT EXISTS "${prop}")
message(FATAL_ERROR "include dir not found: ${prop}")
endif(NOT EXISTS "${prop}")
if(${DEBUG_MODE})
message(STATUS "copy_lib_include_properties: SRC_LIB=${SRC_LIB} ; prop = ${prop}")
endif(${DEBUG_MODE})
#list(APPEND SKIA_CMAKE_ONLY_HEADERS ${prop})
endforeach(prop)
endif()
#
if(${NEED_APPEND_TO_CMAKE_INCLUDE_DIRECTORIES})
list(APPEND SKIA_CMAKE_ONLY_HEADERS ${CUSTOM__INTERFACE_INCLUDE_DIRECTORIES})
endif(${NEED_APPEND_TO_CMAKE_INCLUDE_DIRECTORIES})
endif(${NEED_INTERFACE_INCLUDE_DIRECTORIES})
endmacro(copy_lib_include_properties)
# force OFFICIAL_BUILD
if(RELEASE_BUILD)
message(STATUS "building SKIA in RELEASE mode")
set(IS_DEBUG_BUILD OFF)
set(EXT_SKIA_OFFICIAL_BUILD "true")
if(MSVC) # TODO
# /GR- disables run-time type information.
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"/GR-\", "
)
# If you're using our GYP files to build Skia,
# you're using build scripts mostly designed for development
# (even Release) where we don't pay much attention to
# library structure or size.
# They're all built with -g,
# which bloats the file size considerably.
# https://groups.google.com/forum/#!topic/skia-discuss/5hNRcmERVSI
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"/RELEASE\", "
)
else()
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"-fno-rtti\", "
)
# If you're using our GYP files to build Skia,
# you're using build scripts mostly designed for development
# (even Release) where we don't pay much attention to
# library structure or size.
# They're all built with -g,
# which bloats the file size considerably.
# https://groups.google.com/forum/#!topic/skia-discuss/5hNRcmERVSI
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"-g0\", "
)
endif()
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"-DNDEBUG=1\", "
)
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"-DSK_RELEASE=1\", "
)
else()
message(STATUS "building SKIA in DEBUG mode")
set(IS_DEBUG_BUILD ON)
if(MSVC) # TODO
# When /GR is on, the compiler defines the _CPPRTTI preprocessor macro. By default, /GR is on.
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"/GR\", "
)
else()
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"-frtti\", " # -frtti -rtti
)
endif()
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"-DSK_DEBUG=1\", "
)
endif(RELEASE_BUILD)
if(RELEASE_BUILD)
if(MSVC)
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"/MD\", "
)
endif(MSVC)
else()
if(MSVC)
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"/MDd\", "
)
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"/D_DEBUG\", "
)
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"-DD_DEBUG\", "
)
endif(MSVC)
endif()
# I wanted to expose (almost) all Skia options as CMake options but sadly
# GN is a really bad tool - It produces non-overridable configure errors like:
#
# ... even though the option exists (this one in skia/third_party/libjpeg-turbo/BUILD.gb)
# and it's listed in gn args --list.
# (It seems to be caused by the fact that some options are only actually used when other
# options are set appropriately. But it's not always obvious - one would have to dig into
# Skia configuration. And replicating the dependencies here + propagating it correctly into
# the ExternalProject setup is beyond reasonable.
option(EXT_SKIA_ALWAYS_BUILD "" OFF) # TODO
option(EXT_SKIA_DEBUG "" ${IS_DEBUG_BUILD})
if(TARGET_EMSCRIPTEN)
# NOTE: Use is_component_build=false with EMSCRIPTEN
option(EXT_SKIA_SHARED "build a shared lbrary (ON) or a static library (OFF)" OFF)
else(EMSCRIPTEN)
option(EXT_SKIA_SHARED "build a shared lbrary (ON) or a static library (OFF)" OFF)
endif(TARGET_EMSCRIPTEN)
set(SKIA_SRC_DIR "${SKIA_DIR}")
if(NOT EXISTS ${SKIA_SRC_DIR})
message(FATAL_ERROR "Can't find Skia sources. Please run download-dependencies.sh.")
endif()
set(SKIA_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/skia")
# TODO: extra_cflags=[\"-Wno-unknown-warning-option\",\"-s\",\"USE_FREETYPE=1\",\"-s\",\"USE_LIBPNG=1\"]
# Skia comes with -Werror on by default. That's a cool feature for release...
set(NEW_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# TODO
if(MSVC)
set(NEW_CMAKE_C_FLAGS "${NEW_CMAKE_C_FLAGS} /W0")
else()
set(NEW_CMAKE_C_FLAGS "${NEW_CMAKE_C_FLAGS} -Wno-error")
endif()
STRING(REGEX REPLACE " " "\",\"" NEW_CMAKE_C_FLAGS "${NEW_CMAKE_C_FLAGS}")
set(SKIA_C_FLAGS "\"${NEW_CMAKE_C_FLAGS}\"")
message(STATUS "SKIA_C_FLAGS=${SKIA_C_FLAGS}")
# TODO:
# https://github.com/zub2/SkiaExample/blob/master/ext/CMakeLists.txt#L40
#set(NEW_CMAKE_CXX_FLAGS "")
#foreach(line IN LISTS CMAKE_CXX_FLAGS)
# string(APPEND NEW_CMAKE_CXX_FLAGS "${line}\";\"")
#endforeach()
#STRING(REGEX REPLACE ";" "\";\"" NEW_CMAKE_CXX_FLAGS "${NEW_CMAKE_CXX_FLAGS}")
#set(SKIA_CXX_FLAGS "\"${NEW_CMAKE_CXX_FLAGS}\"")
set(NEW_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
if(TARGET_EMSCRIPTEN)
#set(NEW_CMAKE_CXX_FLAGS "${NEW_CMAKE_CXX_FLAGS} -s MODULARIZE=1 -s EXPORT_NAME=\"PathKitInit\"")
#set(NEW_CMAKE_CXX_FLAGS "${NEW_CMAKE_CXX_FLAGS} -s STRICT=1")
endif() # EMSCRIPTEN
# TODO
if(MSVC)
set(NEW_CMAKE_CXX_FLAGS "${NEW_CMAKE_CXX_FLAGS} /W0")
else()
set(NEW_CMAKE_CXX_FLAGS "${NEW_CMAKE_CXX_FLAGS} -Wno-error")
endif()
# The string literal "\\\\" represents "\\" in memory which is a valid regex (representing a single backslash).
STRING(REGEX REPLACE " " "\",\"" NEW_CMAKE_CXX_FLAGS "${NEW_CMAKE_CXX_FLAGS}")
set(SKIA_CXX_FLAGS "\"${NEW_CMAKE_CXX_FLAGS}\"")
message(STATUS "SKIA_CXX_FLAGS=${SKIA_CXX_FLAGS}")
# NOTE: header from SKIA_EXT
# set(SKIA_CXX_FLAGS "${SKIA_CXX_FLAGS},\"-DSK_USER_CONFIG_HEADER=\"${CMAKE_CURRENT_SOURCE_DIR}/src/chromium/skia/config/SkUserConfig.h\"\"") # skia_use_libpng
if(MSVC)
set(SKIA_LDFLAGS "\"/W0\"")
else()
set(SKIA_LDFLAGS "\"-Wno-error\"")
endif()
function(SET_SKIA_CONFIG_OPTION OPT_NAME OPT_VALUE)
if(OPT_VALUE)
set(${OPT_NAME} "true" PARENT_SCOPE)
else ()
set(${OPT_NAME} "false" PARENT_SCOPE)
endif()
endfunction()
SET_SKIA_CONFIG_OPTION(SK_CONF_DEBUG ${EXT_SKIA_DEBUG})
SET_SKIA_CONFIG_OPTION(SK_CONF_SHARED ${EXT_SKIA_SHARED})
# it's not possible to enable both OFFICIAL and DEBUG
if(EXT_SKIA_OFFICIAL_BUILD AND NOT EXT_SKIA_DEBUG)
set(SK_CONF_IS_OFFICIAL_BUILD "true")
else ()
set(SK_CONF_IS_OFFICIAL_BUILD "false")
endif()
message(STATUS "SK_CONF_DEBUG=${SK_CONF_DEBUG}")
message(STATUS "SK_CONF_IS_OFFICIAL_BUILD=${SK_CONF_IS_OFFICIAL_BUILD}")
if(USE_SK_GPU)
set(SK_IS_GPU "true")
else(USE_SK_GPU)
set(SK_IS_GPU "false")
message(STATUS "SKIA build without GPU support.")
endif(USE_SK_GPU)
if(EMSCRIPTEN)
set(SK_IS_x11 "true")
set(SK_IS_EGL "true")
# todo
#set(SK_CONF_IS_OFFICIAL_BUILD "true")
set(SK_CONF_SHARED "false")
set(SK_IS_processors "false") # see SKSL_STANDALONE
set(SK_IS_workarounds "false") # TODO
set(SK_IS_ccpr "false")
# https://github.com/Zubnix/skia-wasm-port/blob/master/build_skia_wasm_bitcode.sh#L16
# TODO: PATCH https://github.com/Zubnix/skia-wasm-port/blob/master/wasm_compatible_build.patch
set(SK_TARGET_CPU "target_cpu=\"wasm\"")
# see DSK_ASSUME_WEBGL
# see skia/modules/canvaskit/compile.sh
set(SK_GL_STANDARD "skia_gl_standard=\"webgl\"") # SK_ASSUME_WEBGL
#set(SK_GL_STANDARD "skia_gl_standard=\"gles\"") # SK_ASSUME_GL_ES
#set(SK_GL_STANDARD "skia_gl_standard=\"gl\"") # SK_ASSUME_GL
elseif(TARGET_WINDOWS)
set(SK_IS_x11 "false")
set(SK_IS_EGL "false")
set(SK_IS_processors "false") # see SKSL_STANDALONE
set(SK_IS_workarounds "false")
set(SK_IS_ccpr "true")
set(SK_TARGET_CPU "")
set(SK_GL_STANDARD "") # default
else()
set(SK_IS_x11 "true")
set(SK_IS_EGL "false")
set(SK_IS_processors "false") # see SKSL_STANDALONE
set(SK_IS_workarounds "false")
set(SK_IS_ccpr "true")
set(SK_TARGET_CPU "")
set(SK_GL_STANDARD "") # default
endif()
# TODO: target_cpu=\"wasm\" \
# skia_use_system_zlib=true \
# skia_use_system_icu=false \
# skia_use_system_harfbuzz=false \
# skia_use_system_expat=true \
# skia_use_mesa=false \
# is_skia_standalone=true
# skia_enable_effects=true \
# skia_enable_effects_imagefilters=true \
# see https://github.com/google/skia/blob/master/BUILD.gn
# getting right the wonky cmake string handling (with the extra level of ExternalProject)
# and the undocumented args handling of GN is a special treat
# at least Cmake 3.0 has the line continuation feature wich is cool
# but then the args can't be indented because GN is written by somone with overly strong opinions:
# "You got a tab character in here. Tabs are evil. Convert to spaces."
#${WUFFS_LIB_NAME}
if(ENABLE_WUFFS)
set(SK_IS_wuffs "true")
else(ENABLE_WUFFS)
set(SK_IS_wuffs "false")
endif(ENABLE_WUFFS)
if(ENABLE_SKSHAPER)
set(SK_IS_skshaper "true")
else(ENABLE_SKSHAPER)
set(SK_IS_skshaper "false")
endif(ENABLE_SKSHAPER)
if(TARGET_EMSCRIPTEN)
if(USE_SYSTEM_PNG)
set(SK_USE_SYSTEM_LIBPNG TRUE) # TODO: path to png.h (SkPngCodec.cpp)
endif()
set(SK_USE_SYSTEM_ZLIB FALSE)
set(SK_USE_SYSTEM_FREETYPE TRUE)
elseif(TARGET_WINDOWS)
set(SK_USE_SYSTEM_LIBPNG FALSE)
set(SK_USE_SYSTEM_ZLIB FALSE)
set(SK_USE_SYSTEM_FREETYPE FALSE)
elseif(TARGET_LINUX)
if(USE_SYSTEM_PNG)
set(SK_USE_SYSTEM_LIBPNG TRUE)
endif()
set(SK_USE_SYSTEM_ZLIB FALSE)
if(USE_SYSTEM_FREETYPE)
set(SK_USE_SYSTEM_FREETYPE TRUE)
endif(USE_SYSTEM_FREETYPE)
else()
message(FATAL_ERROR "platform not supported")
endif()
if(SK_USE_SYSTEM_LIBPNG)
set(SK_system_libpng
"skia_use_system_libpng=true"
)
endif(SK_USE_SYSTEM_LIBPNG)
if(SK_USE_SYSTEM_FREETYPE)
set(SK_system_freetype2
"skia_use_system_freetype2=true"
)
else()
set(SK_system_freetype2
"skia_use_system_freetype2=false"
)
endif(SK_USE_SYSTEM_FREETYPE)
if(NOT DEFINED ENABLE_ZLIB)
message(FATAL_ERROR "NOT DEFINED: ENABLE_ZLIB")
endif(NOT DEFINED ENABLE_ZLIB)
if(NOT DEFINED SK_USE_SYSTEM_ZLIB)
message(FATAL_ERROR "NOT DEFINED: SK_USE_SYSTEM_ZLIB")
endif(NOT DEFINED SK_USE_SYSTEM_ZLIB)
if(ENABLE_ZLIB)
set(SK_IS_zlib "true")
if(SK_USE_SYSTEM_ZLIB)
set(SK_system_zlib
"skia_use_system_zlib=true"
)
endif(SK_USE_SYSTEM_ZLIB)
else(ENABLE_ZLIB)
set(SK_IS_zlib "false")
endif(ENABLE_ZLIB)
if(USE_LIBJPEG_TURBO)
set(SK_IS_libjpeg_turbo "true")
if(USE_CUSTOM_LIBJPEG_TURBO)
#
set(SK_system_libjpeg_turbo
"skia_use_system_libjpeg_turbo=true"
)
#
#if(NOT USE_CUSTOM_LIBJPEG)
# message(FATAL_ERROR "Custom LIBJPEG_TURBO requires custom LIBJPEG")
#endif(NOT USE_CUSTOM_LIBJPEG)
endif(USE_CUSTOM_LIBJPEG_TURBO)
else()
set(SK_IS_libjpeg_turbo "false")
endif(USE_LIBJPEG_TURBO)
if(NOT FORCE_USE_SKIA_HARFBUZZ)
message(FATAL_ERROR "TODO: SKIA builds without FORCE_USE_SKIA_HARFBUZZ")
endif(NOT FORCE_USE_SKIA_HARFBUZZ)
if(DEFINED libevent_LIB)
# TODO: hack to pass library include dirs to GN
copy_lib_include_properties("${libevent_LIB}" "SKIA_EXTRA_CFLAGS" TRUE FALSE TRUE FALSE)
# TODO: copy_lib_define_properties
# TODO: copy_lib_link_properties
endif(DEFINED libevent_LIB)
# NOTE: in skia HARFBUZZ requires icui18n (unicode/uscript.h)
if(HARFBUZZ_FROM_SKIA AND NOT FORCE_USE_SKIA_HARFBUZZ)
message(FATAL_ERROR "HARFBUZZ_FROM_SKIA requires FORCE_USE_SKIA_HARFBUZZ")
endif(HARFBUZZ_FROM_SKIA AND NOT FORCE_USE_SKIA_HARFBUZZ)
if(FORCE_USE_SKIA_HARFBUZZ)
#if(ENABLE_SKSHAPER) # harfbuzz used only by skshaper
set(SK_IS_harfbuzz "true")
#
if(TARGET_WINDOWS)
set(SK_system_harfbuzz
"skia_use_system_harfbuzz=false"
)
else()
set(SK_system_harfbuzz
"skia_use_system_harfbuzz=true"
)
endif(TARGET_WINDOWS)
#
set(SK_IS_icu "true")
#
if(TARGET_WINDOWS)
set(SK_system_icu
"skia_use_system_icu=false"
)
else()
set(SK_system_icu
"skia_use_system_icu=true"
)
endif(TARGET_WINDOWS)
#else(ENABLE_SKSHAPER)
# set(SK_IS_harfbuzz "false")
# set(SK_IS_icu "false")
#endif(ENABLE_SKSHAPER)
#
if(NOT DEFINED CUSTOM_ICU_LIB)
message(FATAL_ERROR "CUSTOM_ICU_LIB must be defined")
endif(NOT DEFINED CUSTOM_ICU_LIB)
if(DEFINED CUSTOM_ICU_LIB AND USE_CUSTOM_ICU)
# TODO: hack to pass library include dirs to GN
copy_lib_include_properties("${CUSTOM_ICU_LIB}" "SKIA_EXTRA_CFLAGS" TRUE FALSE TRUE TRUE)
# TODO: copy_lib_define_properties
# TODO: copy_lib_link_properties
endif(DEFINED CUSTOM_ICU_LIB AND USE_CUSTOM_ICU)
#get_target_property(CUSTOM_ICU_INCLUDE_DIRECTORIES ${CUSTOM_ICU_LIB} INCLUDE_DIRECTORIES)
#message(STATUS "CUSTOM_ICU_INCLUDE_DIRECTORIES=${CUSTOM_ICU_INCLUDE_DIRECTORIES}")
#set(ICU_PARENT_FULL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/chromium_icu/)
#set(ICU_FULL_DIR ${ICU_PARENT_FULL_DIR}third_party/icu/)
#if(NOT EXISTS "${ICU_FULL_DIR}")
# message(FATAL_ERROR "NOT FOUND: ${ICU_FULL_DIR}")
#endif(NOT EXISTS "${ICU_FULL_DIR}")
#set(OWN_ICU_INCLUDE_DIRS
# ${ICU_PARENT_FULL_DIR}
# ${ICU_FULL_DIR}
# ${ICU_FULL_DIR}source/common/unicode
# ${ICU_FULL_DIR}source/common
# ${ICU_FULL_DIR}source/i18n
#)
#message(STATUS "OWN_ICU_INCLUDE_DIRS=${OWN_ICU_INCLUDE_DIRS}")
#if(USE_CUSTOM_ICU)
# list(APPEND SKIA_CMAKE_ONLY_HEADERS
# ${CUSTOM_ICU_INCLUDE_DIRECTORIES}
# #${OWN_ICU_INCLUDE_DIRS}
# )
# #
# # NOTE: WITH trailing comma
# #set(SKIA_EXTRA_CFLAGS
# # "${SKIA_EXTRA_CFLAGS}\"-I${ICU_FULL_DIR}source/common\", "
# #)
# # NOTE: WITH trailing comma
# foreach(prop ${CUSTOM_ICU_INCLUDE_DIRECTORIES})
# # TODO: hack to pass library include dirs to GN
# set(SKIA_EXTRA_CFLAGS
# "${SKIA_EXTRA_CFLAGS}\"-I${prop}\", "
# )
# endforeach(prop)
#endif(USE_CUSTOM_ICU)
else(FORCE_USE_SKIA_HARFBUZZ)
set(SK_IS_harfbuzz "false")
set(SK_IS_icu "false")
endif(FORCE_USE_SKIA_HARFBUZZ)
if(HARFBUZZ_FROM_SKIA AND NOT SK_system_harfbuzz STREQUAL "skia_use_system_harfbuzz=false")
message(FATAL_ERROR "HARFBUZZ_FROM_SKIA requires skia_use_system_harfbuzz=false, but got: ${SK_system_harfbuzz}")
endif()
# NOTE: WITHOUT trailing comma
if(USE_LIBJPEG_TURBO)
if(NOT DEFINED GLIBJPEG_TURBO_DIR)
message(FATAL_ERROR "NOT DEFINED: GLIBJPEG_TURBO_DIR")
endif(NOT DEFINED GLIBJPEG_TURBO_DIR)
# TODO: hack to pass library include dirs to GN
set(SKIA_EXTRA_CFLAGS
"${SKIA_EXTRA_CFLAGS}\"-I${GLIBJPEG_TURBO_DIR}\""
)
endif(USE_LIBJPEG_TURBO)
if(ENABLE_SKOTTIE)
set(SK_IS_skottie "true")
else(ENABLE_SKOTTIE)
set(SK_IS_skottie "false")
endif(ENABLE_SKOTTIE)
# NOTE: modifying skia src requires full rebuild!
# NOTE: You can use `extra_cflags` and `extra_ldflags` to add include
# or library paths if needed.
set(GN_ARGS "${SK_TARGET_CPU} \
${SK_GL_STANDARD} \
ar=\"${CMAKE_AR}\" \
cc=\"${CMAKE_C_COMPILER}\" \
cxx=\"${CMAKE_CXX_COMPILER}\" \
extra_cflags=[${SKIA_EXTRA_CFLAGS}] \
extra_cflags_c=[${SKIA_C_FLAGS}] \
extra_cflags_cc=[${SKIA_CXX_FLAGS}] \
extra_ldflags=[${SKIA_LDFLAGS}] \
is_official_build=${SK_CONF_IS_OFFICIAL_BUILD} \
is_component_build=${SK_CONF_SHARED} \
is_debug=${SK_CONF_DEBUG} \
skia_enable_gpu=${SK_IS_GPU} \
skia_use_egl=${SK_IS_EGL} \
skia_use_vulkan=false \
skia_enable_vulkan_debug_layers=false \
skia_enable_spirv_validation=false \
skia_use_harfbuzz=${SK_IS_harfbuzz} \
${SK_system_harfbuzz} \
skia_use_icu=${SK_IS_icu} \
${SK_system_icu} \
skia_enable_ccpr=${SK_IS_ccpr} \
skia_enable_nvpr=false \
skia_use_expat=false \
skia_enable_skottie=${SK_IS_skottie} \
skia_use_libjpeg_turbo=${SK_IS_libjpeg_turbo} \
${SK_system_libjpeg_turbo} \
skia_use_libpng=true \
${SK_system_libpng} \
skia_use_zlib=${SK_IS_zlib} \
${SK_system_zlib} \
skia_use_wuffs=${SK_IS_wuffs} \
skia_use_libwebp=false \
skia_enable_pdf=false \
skia_use_sfntly=false \
skia_enable_atlas_text=false \
skia_use_fontconfig=false \
skia_use_freetype=true \
${SK_system_freetype2} \
skia_enable_tools=false \
skia_use_lua=false \
skia_use_piex=false \
skia_use_angle=false \
skia_use_dng_sdk=false \
skia_use_metal=false \
skia_enable_flutter_defines=false \
skia_enable_fontmgr_empty=false \
skia_enable_fontmgr_custom=true \
skia_use_libheif=false \
skia_enable_skpicture=true \
skia_enable_skshaper=${SK_IS_skshaper} \
skia_use_x11=${SK_IS_x11} \
skia_lex=false \
skia_compile_processors=${SK_IS_processors} \
skia_generate_workarounds=${SK_IS_workarounds}"
)
# \
#modules/skottie/utils/SkottieUtils.cpp
message(STATUS "GN_ARGS=${GN_ARGS}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/codegen/skia/args.gn.in" "${SKIA_BUILD_DIR}/args.gn" @ONLY)
# NOTE: will use args.gn generated by configure_file
set(CONFIGURE_COMMAND "${SKIA_SRC_DIR}/bin/gn;gen;--root=${SKIA_SRC_DIR};${SKIA_BUILD_DIR}")
message(STATUS "CONFIGURE_COMMAND=${CONFIGURE_COMMAND}")
set(BUILD_COMMAND "ninja;-C;${SKIA_BUILD_DIR};-d;keepdepfile;-j8")
message(STATUS "BUILD_COMMAND=${BUILD_COMMAND}")
include(ExternalProject)
ExternalProject_Add(SKIA_build
# LIST_SEPARATOR is needed for list expansion of C(XX)_FLAGS.
LIST_SEPARATOR "^^"
SOURCE_DIR ${SKIA_SRC_DIR}
CONFIGURE_COMMAND "${CONFIGURE_COMMAND}"
BUILD_COMMAND "${BUILD_COMMAND}"
# there is no install step provided
#INSTALL_COMMAND true # TODO: true???
INSTALL_COMMAND ""
)
# NOTE: ninja can't handle target dependencies with external libs, so use `--target` before build:
# cmake --build . --config Debug --parallel 8 --target SKIA_build_alwaysbuild
add_custom_target(SKIA_build_alwaysbuild ALL DEPENDS SKIA_build)
# TODO: make PRINT_ALL_GN_ARGS as target dependant of SKIA_build
#if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/skia/args.gn")
# set(PRINT_ALL_GN_ARGS TRUE)
# message(WARING "skia debug info: ${CMAKE_CURRENT_BINARY_DIR}/skia/args.gn")
#else()
# message(WARING "not found for skia debug info: ${CMAKE_CURRENT_BINARY_DIR}/skia/args.gn")
# set(PRINT_ALL_GN_ARGS FALSE)
#endif()
#if(PRINT_ALL_GN_ARGS)
# execute_process(
# COMMAND "${SKIA_SRC_DIR}/bin/gn" "args" "--list" "${CMAKE_CURRENT_BINARY_DIR}/skia/"
# WORKING_DIRECTORY ${SKIA_SRC_DIR}
# #WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/skia
# OUTPUT_VARIABLE _gn_args_list
# #ERROR_QUIET
# OUTPUT_STRIP_TRAILING_WHITESPACE
# ERROR_VARIABLE _ERROR_VARIABLE
# RESULT_VARIABLE retcode
# )
# if(NOT "${retcode}" STREQUAL "0")
# message( FATAL_ERROR "Bad exit status ${_ERROR_VARIABLE} ${_gn_args_list} ${retcode}")
# endif()
# message( STATUS "gn_args_list=${_gn_args_list}")
#endif(PRINT_ALL_GN_ARGS)
if(EXT_SKIA_ALWAYS_BUILD)
message(STATUS "Forced skia rebuild")
# Make sure the target is always rebuilt.
# Without this changing Skia sources doesn't trigger a ninja build. With this
# ninja build is always triggered. This is not needed if you never touch the
# Skia sources. Please note that enabling this ends up with re-building of
# targets that depend on the library. :(
ExternalProject_Add_Step(SKIA_build ForceBuild COMMAND "" DEPENDERS build ALWAYS 1)
endif()
#message(FATAL_ERROR ${SKIA_EXT_PARENT_DIR}/skia/config/sk_ref_cnt_ext_release.h)
# taken from BUILD.gn (skia_public_includes, minus things that are obviously useless for us)
if(HARFBUZZ_FROM_SKIA)
list(APPEND SKIA_CMAKE_ONLY_HEADERS
${SKIA_SRC_DIR}/third_party/externals/harfbuzz
${SKIA_SRC_DIR}/third_party/externals/harfbuzz/src
)
set(SKIA_HB_DIR "${SKIA_SRC_DIR}/third_party/harfbuzz")
endif(HARFBUZZ_FROM_SKIA)
if(ENABLE_SKOTTIE)
list(APPEND SKIA_CMAKE_ONLY_HEADERS
${SKIA_SRC_DIR}/modules/skottie/include
)
endif(ENABLE_SKOTTIE)
if(ENABLE_SKSG)
list(APPEND SKIA_CMAKE_ONLY_HEADERS
${SKIA_SRC_DIR}/modules/sksg/include
)
endif(ENABLE_SKSG)
if(ENABLE_SKSHAPER)
list(APPEND SKIA_CMAKE_ONLY_HEADERS
${SKIA_SRC_DIR}/modules/skshaper/include
)
endif(ENABLE_SKSHAPER)
list(APPEND SKIA_CMAKE_ONLY_HEADERS
#src/chromium/third_party/
${SKIA_PARENT_DIR}
${SKIA_EXT_PARENT_DIR}
${SKIA_EXT_DIR}
${SKIA_SRC_DIR}
${SKIA_SRC_DIR}/tools
${SKIA_SRC_DIR}/modules/pathkit
# ${SKIA_SRC_DIR}/tools/timer
${SKIA_SRC_DIR}/src/gpu
${SKIA_SRC_DIR}/src/sksl
${SKIA_SRC_DIR}/src/gpu/gl
${SKIA_SRC_DIR}/src/shaders
${SKIA_SRC_DIR}/src/core
${SKIA_SRC_DIR}/src/image
${SKIA_SRC_DIR}/src/utils
# ${SKIA_SRC_DIR}/src/tools
${SKIA_SRC_DIR}/include/c
${SKIA_SRC_DIR}/include/codec
${SKIA_SRC_DIR}/include/config
${SKIA_SRC_DIR}/include/core
${SKIA_SRC_DIR}/include/effects
${SKIA_SRC_DIR}/include/gpu
${SKIA_SRC_DIR}/include/gpu/gl
${SKIA_SRC_DIR}/include/pathops
${SKIA_SRC_DIR}/include/ports
${SKIA_SRC_DIR}/include/svg
${SKIA_SRC_DIR}/include/utils
# ${SKIA_SRC_DIR}/include/views
${SKIA_SRC_DIR}/include/private
# ${SKIA_SRC_DIR}/third_party/angle2
# ${SKIA_SRC_DIR}/third_party/cpu-features
# ${SKIA_SRC_DIR}/third_party/dng_sdk
# ${SKIA_SRC_DIR}/third_party/etc1
# ${SKIA_SRC_DIR}/third_party/expat
# ${SKIA_SRC_DIR}/third_party/externals
${SKIA_SRC_DIR}/third_party/freetype2
${SKIA_SRC_DIR}/third_party/freetype2/include
${SKIA_SRC_DIR}/third_party/externals/freetype
${SKIA_SRC_DIR}/third_party/externals/freetype/include # for ft2build.h
# ${SKIA_SRC_DIR}/third_party/gif
${SKIA_HB_DIR}
# ${SKIA_SRC_DIR}/third_party/icu # see USE_CUSTOM_ICU
# ${SKIA_SRC_DIR}/third_party/imgui
# ${SKIA_SRC_DIR}/third_party/libjpeg-turbo
# ${SKIA_SRC_DIR}/third_party/libmicrohttpd
#
${SKIA_SRC_DIR}/third_party/libpng
# ${SKIA_SRC_DIR}/third_party/libsdl
# ${SKIA_SRC_DIR}/third_party/libwebp
# ${SKIA_SRC_DIR}/third_party/lua
# ${SKIA_SRC_DIR}/third_party/native_app_glue
${SKIA_SRC_DIR}/third_party/Nima-Cpp
# ${SKIA_SRC_DIR}/third_party/opencl
# ${SKIA_SRC_DIR}/third_party/piex
${SKIA_SRC_DIR}/third_party/skcms
# ${SKIA_SRC_DIR}/third_party/sfntly
# ${SKIA_SRC_DIR}/third_party/spirv-headers
# ${SKIA_SRC_DIR}/third_party/spirv-tools
# ${SKIA_SRC_DIR}/third_party/vulkanmemoryallocator
#
${SKIA_SRC_DIR}/third_party/zlib
)
if(ENABLE_WUFFS)
list(APPEND SKIA_CMAKE_ONLY_HEADERS
${SKIA_SRC_DIR}/third_party/wuffs
)
endif(ENABLE_WUFFS)
#include_directories(
# src/chromium/third_party
#)
# this must match what BUILD.gn sets
# if it's wrong it can result in all kinds of funny behavior
# see https://github.com/google/skia/blob/master/modules/pathkit/compile.sh#L94
# TODO:
# SK_RELEASE"
# PATHKIT_TESTING"
#"SK_INTERNAL"
#"SK_GAMMA_SRGB"
#"SK_GAMMA_APPLY_TO_A8"
#"SK_SCALAR_TO_FLOAT_EXCLUDED"
#"SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1"
#"SK_FORCE_DISTANCEFIELD_FONTS=0"
#"SK_SCALAR_IS_FLOAT"
#"SK_CAN_USE_FLOAT"
#"SK_BUILD_FOR_WIN32"
#"SK_BUILD_JSON_WRITER"
#"SK_DEBUG"
#"SK_DEVELOPER=1"
#"SK_VULKAN=1" # skia_use_vulkan
#"SK_ENABLE_VK_LAYERS=1" # skia_enable_vulkan_debug_layers
#"SK_ENABLE_SPIRV_VALIDATION=1" # skia_enable_spirv_validation
#"SK_SUPPORT_ATLAS_TEXT=0"
#"SK_SUPPORT_PDF=1" # skia_enable_pdf
#"SK_PDF_USE_SFNTLY=1" # skia_use_sfntly
#"SK_HAS_WEBP_LIBRARY=1" # skia_use_libwebp, skia_use_system_libwebp
#"SK_XML=1" # skia_use_expat
#"SK_HAS_HEIF_LIBRARY=1" # skia_use_libheif
#"SK_METAL"
#"SK_VULKAN"
#"SK_MOLTENVK"
#"SK_CODEC_DECODES_RAW"
# SKIA_IMPLEMENTATION # https://github.com/google/skia/blob/master/include/core/SkPreConfig.h#L187
# LIBGLESV2_IMPLEMENTATION # https://github.com/google/skia/blob/master/third_party/angle2/BUILD.gn
# ANGLE_ENABLE_GLSL
# ANGLE_ENABLE_OPENGL
#SK_BUILD_FOR_UNIX
#SK_BUILD_FOR_PATHKIT=1
#SK_BUILD_FOR_PATHKIT
#SK_DISABLE_READBUFFER=1
#SK_DISABLE_READBUFFER
# see https://skia-review.googlesource.com/c/skia/+/158341
#GL_GLEXT_PROTOTYPES
#EGL_EGLEXT_PROTOTYPES
#LIBEGL_IMPLEMENTATION
if(MSVC) # TODO
list(APPEND SKIA_DEFINES
HB_NO_MT=1
)
endif()
if(USE_SK_GPU)
list(APPEND SKIA_DEFINES
SK_SUPPORT_GPU=1 # skia_enable_gpu
#SK_SUPPORT_GPU
)
else()
list(APPEND SKIA_DEFINES
SK_SUPPORT_GPU=0 # skia_enable_gpu
)
endif(USE_SK_GPU)
list(APPEND SKIA_DEFINES
SKIA_IMPLEMENTATION
SK_SUPPORT_OPENCL=0
SK_SAMPLES_FOR_X=1 # always set for linux, even if there's no X used
#SK_SAMPLES_FOR_X
# see https://skia.org/user/api/skcanvas_creation
SK_HAS_PNG_LIBRARY=1 # skia_use_libpng
#SK_HAS_PNG_LIBRARY
# SK_HAS_GIF_LIBRARY
# SK_HAS_WEBP_LIBRARY
)
if(ENABLE_SKOTTIE)
list(APPEND SKIA_DEFINES
SK_INCLUDE_MANAGED_SKOTTIE=1
SK_INCLUDE_MANAGED_SKOTTIE
)
endif(ENABLE_SKOTTIE)
if(SUPPORTS_JPEG)
list(APPEND SKIA_DEFINES
SK_HAS_JPEG_LIBRARY=1 # skia_use_libjpeg_turbo
SK_HAS_JPEG_LIBRARY
)
elseif(USE_LIBJPEG_TURBO)
list(APPEND SKIA_DEFINES
SK_HAS_JPEG_LIBRARY=1 # skia_use_libjpeg_turbo
SK_HAS_JPEG_LIBRARY
)
endif()
#<listOptionValue builtIn="false" value="SK_DEFAULT_FONT_CACHE_LIMIT=20971520"/>
#<listOptionValue builtIn="false" value="SK_GAMMA_CONTRAST=0.2"/>
#<listOptionValue builtIn="false" value="SK_GAMMA_EXPONENT=1.2"/>
#<listOptionValue builtIn="false" value="SK_IGNORE_DW_GRAY_FIX"/>
#<listOptionValue builtIn="false" value="SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS"/>
#<listOptionValue builtIn="false" value="SK_SUPPORT_GPU=1"/>
# see https://github.com/xzwang2005/Prelude/blob/master/third_party/skia/src/pathops/SkPathOpsTypes.cpp#L106
#list(APPEND SKIA_DEFINES SKOTTIE_HACK)
#list(APPEND SKIA_DEFINES SKOTTIE_HACK=1)
if(EMSCRIPTEN)
list(APPEND SKIA_DEFINES OS_EMSCRIPTEN=1) # same as in base/WTF/blink
#if(ENABLE_WASM)
if(ENABLE_SIMD)
list(APPEND SKIA_DEFINES SK_CPU_SSE_LEVEL=0)
# TODO
#list(APPEND SKIA_DEFINES SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE1)
else()
list(APPEND SKIA_DEFINES SK_CPU_SSE_LEVEL=0)
list(APPEND SKIA_DEFINES SKNX_NO_SIMD) # see "-s SIMD=1" and -msimd128
list(APPEND SKIA_DEFINES SKNX_NO_SIMD=1) # see "-s SIMD=1" and -msimd128
endif(ENABLE_SIMD)
if(USE_SK_GPU)
list(APPEND SKIA_DEFINES SK_ASSUME_WEBGL)
list(APPEND SKIA_DEFINES SK_ASSUME_WEBGL=1)
list(APPEND SKIA_DEFINES IS_WEBGL)
list(APPEND SKIA_DEFINES IS_WEBGL=1)
#list(APPEND SKIA_DEFINES SK_ASSUME_GL_ES)
#list(APPEND SKIA_DEFINES SK_ASSUME_GL_ES=1)
#list(APPEND SKIA_DEFINES SK_ASSUME_GL)
#list(APPEND SKIA_DEFINES SK_ASSUME_GL=1)
#list(APPEND SKIA_DEFINES LIBANGLE_IMPLEMENTATION=1)
#list(APPEND SKIA_DEFINES LIBGLESV2_IMPLEMENTATION=1)
list(APPEND SKIA_DEFINES LIBEGL_IMPLEMENTATION=1)
#list(APPEND SKIA_DEFINES ANGLE_ENABLE_ESSL=1)
#list(APPEND SKIA_DEFINES ANGLE_ENABLE_GLSL=1)
#list(APPEND SKIA_DEFINES ANGLE_ENABLE_HLSL=1)
#list(APPEND SKIA_DEFINES ANGLE_ENABLE_OPENGL=1)
list(APPEND SKIA_DEFINES EGL_EGLEXT_PROTOTYPES=1)
#list(APPEND SKIA_DEFINES GL_GLEXT_PROTOTYPES=1)
endif(USE_SK_GPU)
# see https://github.com/endlessm/chromium-browser/blob/master/third_party/skia/third_party/skcms/skcms.cc#L1813
# see https://github.com/google/skia/blob/master/third_party/skcms/skcms.cc#L1836
# list(APPEND SKIA_DEFINES SKCMS_PORTABLE)
list(APPEND SKIA_DEFINES WEB_ASSEMBLY=1)
#list(APPEND SKIA_DEFINES SK_BUILD_FOR_PATHKIT=1)
# we don't deserialize anything.
list(APPEND SKIA_DEFINES SK_DISABLE_READBUFFER=1)
#list(APPEND SKIA_DEFINES SK_DISABLE_EFFECT_DESERIALIZATION=1)
else(EMSCRIPTEN)
# Remove software rasterizers to save some code size.
#list(APPEND SKIA_DEFINES SK_DISABLE_AAA=1)
# see https://github.com/flutter/flutter/issues/11402
if(USE_SK_GPU)
list(APPEND SKIA_DEFINES SK_ENABLE_DUMP_GPU=1)
endif(USE_SK_GPU)
endif(EMSCRIPTEN)
if(SK_CONF_SHARED)
list(APPEND SKIA_DEFINES SKIA_DLL=1)
endif()
## TODO
#list(APPEND SKIA_DEFINES LIB_ICU_I18N_STATIC=1)
#list(APPEND SKIA_DEFINES U_CHARSET_IS_UTF8=1)
#list(APPEND SKIA_DEFINES U_NO_DEFAULT_INCLUDE_UTF_HEADERS=0)
#
## TODO
#list(APPEND SKIA_DEFINES NEED_SHORT_EXTERNAL_NAMES=1)
# GN doesn't seem to do any fancy stuff with library dependencies - it just
# asks the compiler to link to them w/o any fany search strategies. This
# also means that whatever is found here is not guaranteed to be the same as
# what GN finds. :-(
# Anyway, using plain find_library() seems to be the next closest thing,
# so even if some libraries provide pkg_config or special packages for CMake,
# only find_library() is used here.
# This is needed only for static library build where the dependencies have
# to be added explicitly.
if(NOT EXT_SKIA_SHARED)
function(ADD_SKIA_LIBRARY_DEPENDENCY LIB_NAME_LIST)
foreach(LIB_NAME ${LIB_NAME_LIST})
message(STATUS "Searching for ${LIB_NAME}...")
find_library(LIB${LIB_NAME} ${LIB_NAME})
if(NOT LIB${LIB_NAME})
message(FATAL_ERROR "Can't find required library ${LIB_NAME}.")
else()
message(STATUS "Found library ${LIB_NAME} = ${LIB${LIB_NAME}}")
endif()
# NOTE: HARFBUZZ_LIBRARIES is SKIA here, prevent recursion
set(SKIA_DEPENDENCIES "${SKIA_DEPENDENCIES};${LIB${LIB_NAME}}")
endforeach()
endfunction()
if(TARGET_EMSCRIPTEN)
message(STATUS "building skia for EMSCRIPTEN")
elseif(TARGET_LINUX OR TARGET_WINDOWS)
message(STATUS "building skia for ${CMAKE_SYSTEM_NAME}")
# seem to be always required...
#ADD_SKIA_LIBRARY_DEPENDENCY("dl")
set(SKIA_DEPENDENCIES "${SKIA_DEPENDENCIES};${libDL_LIB}")
#ADD_SKIA_LIBRARY_DEPENDENCY("icuuc") # skia_use_system_icu
#ADD_SKIA_LIBRARY_DEPENDENCY("expat") #skia_use_system_expat
find_package(EXPAT REQUIRED)
set(SKIA_DEPENDENCIES "${SKIA_DEPENDENCIES};EXPAT::EXPAT")
# NOTE: HARFBUZZ_LIBRARIES is SKIA here, prevent recursion
#set(SKIA_DEPENDENCIES "${SKIA_DEPENDENCIES};${HARFBUZZ_LIBRARIES}")
#set(SKIA_DEPENDENCIES "${SKIA_DEPENDENCIES};${FOUND_OPENGL_LIBRARIES}")
#message(FATAL_ERROR FREETYPE_LIBRARIES=${FREETYPE_LIBRARIES})
set(SKIA_DEPENDENCIES "${SKIA_DEPENDENCIES};${FREETYPE_LIBRARIES}")