-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
1148 lines (1032 loc) · 41.7 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
#
# Copyright (c) 2018-2024, Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause
#
# ispc CMakeLists.txt
#
cmake_minimum_required(VERSION 3.15)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Set C++ standard to C++17.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set C standard to C11
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
if (UNIX)
if (NOT CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER "clang")
endif()
if (NOT CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER "clang++")
endif()
endif()
# Generate compile_commands.json by default - this enables VSCode to do better job interpretting
# C++ files form the project.
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON" CACHE BOOL "Export compile commands")
if (APPLE)
# Setting ISPC_MACOS_UNIVERSAL_BINARIES to ON is conventional way of building ISPC as Universal Binary.
# If cross compilation is needed (arm64->x86_64 or x86_64->arm64), specify CMAKE_OSX_ARCHITECTURES
# on the command line explicitly
option(ISPC_MACOS_UNIVERSAL_BINARIES "Build Universal Binaries on macOS" OFF)
if (ISPC_MACOS_UNIVERSAL_BINARIES)
message(STATUS "Building Universal Binaries (x86_64+arm64)")
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "OSX architectures")
endif()
# We need to target different minimum macOS versions on x86 and arm by default, but before
# we execute project() command, the regular CMAKE_* variables with host info are not initialized,
# so we do this hack to detect the platform. It's not perfect, but good enough.
execute_process(COMMAND uname -m OUTPUT_VARIABLE UNAME)
if (UNAME MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
# Note: it's ok to have 10.12 for Universal Binaries.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum macOS version to support")
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS version to support")
endif()
message(STATUS "Targeting minimum macOS version: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
set(PROJECT_NAME ispc)
set(ISPC_BUILD TRUE)
project(${PROJECT_NAME})
## Check PIE support
include(CheckPIESupported)
check_pie_supported(OUTPUT_VARIABLE CHECK_PIE_OUTPUT LANGUAGES CXX)
if(NOT CMAKE_CXX_LINK_PIE_SUPPORTED)
message(WARNING "PIE is not supported at link time: ${CHECK_PIE_OUTPUT}.\n"
"PIE link options will not be passed to linker.")
endif()
set(X86_HOST FALSE)
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "amd64|AMD64|86")
set(X86_HOST TRUE)
endif()
option(X86_ENABLED "Enable x86 support" ${X86_HOST})
option(ARM_ENABLED "Enable ARM support" ON)
option(WASM_ENABLED "Enable experimental Web Assembly support" OFF)
option(XE_ENABLED "Enable Intel Xe support" OFF)
option(ISPC_INCLUDE_EXAMPLES "Generate build targets for the ISPC examples" ON)
option(ISPC_INCLUDE_DPCPP_EXAMPLES "Generate build targets for the ISPC/DPCPP interoperability examples" OFF)
option(ISPC_INCLUDE_TESTS "Generate build targets for the ISPC tests." ON)
option(ISPC_INCLUDE_BENCHMARKS "Generate build targets for the ISPC tests." OFF)
option(ISPC_INCLUDE_RT "Generate build targets for ISPC runtime." ON)
option(ISPC_INCLUDE_UTILS "Generate build targets for the utils." ON)
option(ISPC_INCLUDE_UTILS_ONLY "Generate build targets only for the utils." OFF)
option(ISPC_PREPARE_PACKAGE "Generate build targets for ispc package" OFF)
option(ISPC_PACKAGE_EXAMPLES "Pack examples into the ISPC package" ON)
option(ISPC_SLIM_BINARY "Build ISPC as slim binary" OFF)
option(ISPC_OPAQUE_PTR_MODE "Build ISPC with usage of opaque pointers" OFF)
option(ISPC_CROSS "Build ISPC with cross compilation support" OFF)
# Default settings for cross compilation
if (ISPC_CROSS)
option(ISPC_WINDOWS_TARGET "Build ISPC with windows target support" ON)
option(ISPC_LINUX_TARGET "Build ISPC with linux target support" ON)
option(ISPC_FREEBSD_TARGET "Build ISPC with freebsd target support" ON)
# It's possbile to build macOS target on Windows or Linux, but we don't do that by default.
option(ISPC_MACOS_TARGET "Build ISPC with macos target support" OFF)
option(ISPC_IOS_TARGET "Build ISPC with ios target support" ON)
option(ISPC_ANDROID_TARGET "Build ISPC with android target support" ON)
option(ISPC_PS_TARGET "Build ISPC with ps4 and ps5 targets support" ON)
# We silently disable some of cross targets. We should probably warn user or issue an error,
# but it seems good enough.
if (WIN32)
set(ISPC_IOS_TARGET OFF)
if ((ISPC_LINUX_TARGET OR ISPC_ANDROID_TARGET OR ISPC_PS_TARGET) AND NOT ISPC_GNUWIN32_PATH)
message (FATAL_ERROR "Set ISPC_GNUWIN32_PATH variable for cross compilation to Linux/Android/PS4 e.g. C:/gnuwin32")
endif()
if (ISPC_MACOS_TARGET AND NOT ISPC_MACOS_SDK_PATH)
message (FATAL_ERROR "Set ISPC_MACOS_SDK_PATH variable for cross compilation to MacOS e.g. C:/iusers/MacOSX10.14.sdk")
endif()
elseif (APPLE)
set(ISPC_MACOS_TARGET ON)
set(ISPC_WINDOWS_TARGET OFF)
set(ISPC_PS_TARGET OFF)
set(ISPC_FREEBSD_TARGET OFF)
if ((ISPC_LINUX_TARGET OR ISPC_ANDROID_TARGET) AND NOT ISPC_ANDROID_NDK_PATH)
message (FATAL_ERROR "Set ISPC_ANDROID_NDK_PATH variable for cross compilation to Linux/Android e.g. /Users/Shared/android-ndk-r20")
endif()
if (ISPC_IOS_TARGET AND NOT ISPC_IOS_SDK_PATH)
# Use standard iOS SDK location if this is not specified.
set(command "xcrun" "--show-sdk-path" "--sdk" "iphoneos")
execute_process(COMMAND ${command}
OUTPUT_VARIABLE ISPC_IOS_SDK_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Using iOS SDK path ${ISPC_IOS_SDK_PATH}")
endif()
else()
set(ISPC_WINDOWS_TARGET OFF)
set(ISPC_PS_TARGET OFF)
set(ISPC_IOS_TARGET OFF)
if (ISPC_MACOS_TARGET AND NOT ISPC_MACOS_SDK_PATH)
message (FATAL_ERROR "Set ISPC_MACOS_SDK_PATH variable for cross compilation to MacOS e.g. /iusers/MacOSX10.14.sdk")
endif()
endif()
else()
if (WIN32)
set(ISPC_WINDOWS_TARGET ON)
elseif (APPLE)
set(ISPC_MACOS_TARGET ON)
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(ISPC_FREEBSD_TARGET ON)
else()
set(ISPC_LINUX_TARGET ON)
endif()
endif()
if (ISPC_LINUX_TARGET OR ISPC_ANDROID_TARGET OR ISPC_PS_TARGET
OR ISPC_FREEBSD_TARGET OR ISPC_IOS_TARGET OR ISPC_MACOS_TARGET)
set(ISPC_UNIX_TARGET ON)
else()
set(ISPC_UNIX_TARGET OFF)
endif()
if (APPLE)
# Use standard macOS SDK location if this is not specified.
if (NOT ISPC_MACOS_SDK_PATH)
set(command "xcrun" "--show-sdk-path")
execute_process(COMMAND ${command}
OUTPUT_VARIABLE ISPC_MACOS_SDK_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Using macOS SDK path ${ISPC_MACOS_SDK_PATH}")
endif()
# Workaround CMake/CPack issue https://gitlab.kitware.com/cmake/cmake/-/issues/24601
# When llvm toolchain is presented in PATH, llvm-strip is preferred over
# macOS strip. However, CPack fails to correctly call llvm-strip because it
# adds flags like `-u` that are macOS strip specific.
# It may be removed later when CMake fixes ambiguity.
if (${CMAKE_VERSION} VERSION_LESS "3.27.0")
set(CMAKE_STRIP strip)
endif()
endif()
set(ISPC_MACOS_ARM_TARGET OFF)
if (ISPC_MACOS_TARGET AND ISPC_MACOS_SDK_PATH)
# Get macOS SDK version.
# xcrun is known not to work for standalone SDK or in the default environment
# on some systems (without explicitly running "xcode-select -s <path>" first).
# So we try to get the version from the SDK path first, and then fall back
# to looking at the SDK folder name.
set(command "xcrun" "--sdk" ${ISPC_MACOS_SDK_PATH} "--show-sdk-version")
execute_process(COMMAND ${command}
OUTPUT_VARIABLE SDK_VER
RESULT_VARIABLE XCRUN_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT XCRUN_RESULT STREQUAL "0")
if (IS_SYMLINK ${ISPC_MACOS_SDK_PATH})
# Follow symlinks, relative and absolute.
file(READ_SYMLINK "${ISPC_MACOS_SDK_PATH}" ISPC_MACOS_SDK_PATH_NEW)
if (NOT IS_ABSOLUTE "${ISPC_MACOS_SDK_PATH_NEW}")
get_filename_component(ISPC_MACOS_SDK_PATH_DIR "${ISPC_MACOS_SDK_PATH}" DIRECTORY)
set(ISPC_MACOS_SDK_PATH_NEW "${ISPC_MACOS_SDK_PATH_DIR}/${ISPC_MACOS_SDK_PATH_NEW}")
endif()
set(ISPC_MACOS_SDK_PATH "${ISPC_MACOS_SDK_PATH_NEW}")
endif()
string(REGEX MATCH "MacOSX([0-9]*.[0-9]*).sdk" _ ${ISPC_MACOS_SDK_PATH})
set(SDK_VER "${CMAKE_MATCH_1}")
endif()
message(STATUS "MacOS_SDK version: ${SDK_VER}")
if ("${SDK_VER}" STREQUAL "")
message(WARNING "MacOS SDK version was not detected, assuming 11.0 or later, enabling ARM support")
set(ISPC_MACOS_ARM_TARGET ON)
elseif("${SDK_VER}" VERSION_GREATER_EQUAL "11.0")
message(STATUS "MacOS_SDK supports ARM (SDK ver >= 11.0)")
set(ISPC_MACOS_ARM_TARGET ON)
else()
message(STATUS "MacOS_SDK does NOT supports ARM (SDK ver < 11.0)")
endif()
endif()
# If Xe target is enabled, generate build targets for Xe examples and ISPCRT on Linux
if (XE_ENABLED)
option(ISPC_INCLUDE_XE_EXAMPLES "Generate build targets for the ISPC Xe examples" ON)
endif()
if (UNIX)
option(ISPC_STATIC_STDCXX_LINK "Link statically with libstdc++ and libgcc" OFF)
if (ISPC_PREPARE_PACKAGE AND (NOT APPLE))
option(ISPC_STATIC_LINK "Link statically (all except glibc)" ON)
else()
option(ISPC_STATIC_LINK "Link statically (all except glibc)" OFF)
endif()
option(ISPC_USE_ASAN "Build ispc with address sanitizer instrumentation using clang compiler" OFF)
endif()
# Use solution folders.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(OUTPUT_DEBUG Debug/bin)
set(OUTPUT_RELEASE Release/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin )
if(CMAKE_BUILD_TYPE)
# Validate build type
set(CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo")
string(FIND "${CONFIGURATION_TYPES}" "${CMAKE_BUILD_TYPE}" MATCHED_CONFIG)
if (${MATCHED_CONFIG} EQUAL -1)
message(FATAL_ERROR "CMAKE_BUILD_TYPE (${CMAKE_BUILD_TYPE}) allows only the following values: ${CONFIGURATION_TYPES}")
endif()
else(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: Use Release by default.")
endif(CMAKE_BUILD_TYPE)
# Build target for utility checking host ISA
if (ISPC_INCLUDE_UTILS)
add_executable(check_isa "")
target_sources(check_isa PRIVATE tools/check_isa.cpp)
set_target_properties(check_isa PROPERTIES FOLDER "Utils")
if (NOT ISPC_PREPARE_PACKAGE)
install (TARGETS check_isa DESTINATION bin)
endif()
if (ISPC_INCLUDE_UTILS_ONLY)
# Skip the below part of CMake. It is useful when only check_isa compiling is needed.
return()
endif()
endif()
set(BITCODE2CPP "${CMAKE_CURRENT_SOURCE_DIR}/scripts/bitcode2cpp.py")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ispcrt/cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FixWindowsPath.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLLVM.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Git.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CommonStdlibBuiltins.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateBuiltins.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Stdlib.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.cmake)
# Get ispc version
get_ispc_version("${CMAKE_CURRENT_SOURCE_DIR}/common/version.h")
find_package(Python3 REQUIRED)
if (NOT Python3_Interpreter_FOUND)
message(FATAL_ERROR "Python interpreter is not found")
endif()
find_package(BISON 3.0 REQUIRED)
if (BISON_FOUND)
set(BISON_INPUT src/parse.yy)
set(BISON_CPP_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/parse.cc)
set(BISON_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/parse.hh
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/parse.output)
add_custom_command (
OUTPUT ${BISON_CPP_OUTPUT} ${BISON_OUTPUT}
COMMAND ${BISON_EXECUTABLE} -d -t -v
--output=${BISON_CPP_OUTPUT}
${BISON_INPUT}
MAIN_DEPENDENCY ${BISON_INPUT}
COMMENT "Generating parse.cc"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
find_package(FLEX 2.6 REQUIRED)
if (FLEX_FOUND)
set(FLEX_INPUT src/lex.ll)
set(FLEX_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lex.cpp)
add_custom_command(
OUTPUT ${FLEX_OUTPUT}
COMMAND ${FLEX_EXECUTABLE}
--outfile=${FLEX_OUTPUT}
${FLEX_INPUT}
MAIN_DEPENDENCY ${FLEX_INPUT}
COMMENT "Generating lex.cpp"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
if (NOT X86_ENABLED AND NOT ARM_ENABLED AND NOT WASM_ENABLED AND NOT XE_ENABLED)
message( FATAL_ERROR "Either X86, ARM, WASM or XE targets need to be enabled.")
endif ()
# All possible ISPC targets
list(APPEND X86_TARGETS
sse2-i32x4 sse2-i32x8
sse4-i32x4 sse4-i32x8 sse4-i8x16 sse4-i16x8
# Note here that avx1-i32x4 is aliased to sse4-i32x4 plus avx attribute,
# sse41* targets are aliased to corresponding sse4 targets.
avx1-i32x8 avx1-i32x16 avx1-i64x4
avx2-i8x32 avx2-i16x16
avx2-i32x4 avx2-i32x8 avx2-i32x16 avx2-i64x4
avx2vnni-i32x4 avx2vnni-i32x8 avx2vnni-i32x16
avx512skx-x4 avx512skx-x8 avx512skx-x16
avx512skx-x32 avx512skx-x64
avx512icl-x4 avx512icl-x8 avx512icl-x16
avx512icl-x32 avx512icl-x64
avx512spr-x4 avx512spr-x8 avx512spr-x16 avx512spr-x32 avx512spr-x64)
# LLVM is removing support for Xeon Phi in 19.0
if (${LLVM_VERSION_NUMBER} VERSION_LESS "19.0.0")
list(APPEND X86_TARGETS avx512knl-x16)
endif()
list(APPEND ARM_TARGETS neon-i8x16 neon-i16x8 neon-i32x4 neon-i32x8)
list(APPEND WASM_TARGETS wasm-i32x4)
list(APPEND XE_TARGETS gen9-x16 gen9-x8 xelp-x16 xelp-x8 xehpg-x16 xehpg-x8 xehpc-x16 xehpc-x32 xelpg-x16 xelpg-x8
xe2hpg-x16 xe2hpg-x32 xe2lpg-x16 xe2lpg-x32)
if (X86_ENABLED)
list(APPEND ISPC_TARGETS ${X86_TARGETS})
endif()
if (ARM_ENABLED)
list(APPEND ISPC_TARGETS ${ARM_TARGETS})
endif()
if (WASM_ENABLED)
list(APPEND ISPC_TARGETS ${WASM_TARGETS})
endif()
if (XE_ENABLED)
list(APPEND ISPC_TARGETS ${XE_TARGETS})
endif()
if (WASM_ENABLED)
find_program(EMCC_EXECUTABLE emcc)
if (NOT EMCC_EXECUTABLE)
message(FATAL_ERROR "emcc not found!")
endif()
message(STATUS "EMCC_EXECUTABLE: ${EMCC_EXECUTABLE}")
endif()
if (${LLVM_VERSION_NUMBER} VERSION_LESS "16.0.0")
message(FATAL_ERROR "ISPC requires LLVM 16.0.0 or later")
endif()
set(CLANG_LIBRARY_LIST clangFrontend clangBasic clangEdit clangLex clangSupport clangASTMatchers)
set(LLVM_COMPONENTS engine ipo bitreader bitwriter instrumentation linker option frontendopenmp passes)
# windowsdriver is a small library introduced in LLVM 15. While it's targeted at Windows only,
# it's used in the LLVM code without any ifdef and is needed on all platforms.
# An interesting fact, that on Linux it is not required, because linker is smart enough to optimize out
# the calls to unresolved symbols. It's not the case on macOS though.
list(APPEND LLVM_COMPONENTS windowsdriver)
if (X86_ENABLED)
list(APPEND LLVM_COMPONENTS x86)
endif()
if (ARM_ENABLED)
list(APPEND LLVM_COMPONENTS arm aarch64)
endif()
if (WASM_ENABLED)
list(APPEND LLVM_COMPONENTS webassembly)
endif()
if (XE_ENABLED)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(TARGET_MODIFIER "32")
set(PB_PATH_MODIFIER "x86")
else()
set(TARGET_MODIFIER "64")
set(PB_PATH_MODIFIER "x64")
endif()
list(APPEND XE_LIBRARY_LIST LLVMGenXIntrinsics LLVMSPIRVLib)
endif()
# Set the flags responsible for generation of opaque pointers in builtins
set(ISPC_OPAQUE_FLAGS)
set(LLVM_TOOLS_OPAQUE_FLAGS)
# Starting LLVM version 17.0 enable opaque pointers by default for CPU build
if (${LLVM_VERSION_NUMBER} VERSION_GREATER_EQUAL "17.0.0")
set(ISPC_OPAQUE_PTR_MODE ON)
else()
# On Xe-enabled build, turn off opaque pointers before 17.0.
# IGC software stack is not ready yet.
if (XE_ENABLED)
set(ISPC_OPAQUE_PTR_MODE OFF)
endif()
endif()
if (NOT ISPC_OPAQUE_PTR_MODE)
# Explicitly disable opaque pointers starting LLVM 15.0 till LLVM 17.0
if (${LLVM_VERSION_NUMBER} VERSION_LESS "17.0.0")
set(ISPC_OPAQUE_FLAGS "-Xclang" "-no-opaque-pointers")
set(LLVM_TOOLS_OPAQUE_FLAGS "-opaque-pointers=0")
endif()
endif()
message(STATUS "ISPC opaque pointers mode is " ${ISPC_OPAQUE_PTR_MODE})
get_llvm_libfiles(LLVM_LIBRARY_LIST ${LLVM_COMPONENTS})
get_llvm_cppflags(LLVM_CPP_FLAGS)
if(CMAKE_GENERATOR MATCHES "Visual Studio")
# Visual Studio generator places binaries under bin/$(Configuration) subdirectory.
set(BITCODE_FOLDER ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/share/ispc)
set(INCLUDE_FOLDER ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/include)
else()
set(BITCODE_FOLDER ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../share/ispc)
set(INCLUDE_FOLDER ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../include)
endif()
message(STATUS "BITCODE_FOLDER is ${BITCODE_FOLDER}")
file(MAKE_DIRECTORY ${BITCODE_FOLDER})
# Defines builtin target
generate_builtins()
# Common sources between ispc-opt and ispc
list(APPEND COMMON_SOURCES
common/version.rc
common/version.h
src/bitcode_lib.cpp
src/bitcode_lib.h
src/builtins-decl.cpp
src/builtins-decl.h
src/ispc.cpp
src/ispc.h
src/ispc_version.h
src/llvmutil.cpp
src/llvmutil.h
src/target_enums.cpp
src/target_enums.h
src/target_registry.cpp
src/target_registry.h
src/util.cpp
src/util.h
)
# Source files used only in ispc
list(APPEND FRONTEND_SOURCES
${STDLIB_FILES}
${BISON_CPP_OUTPUT}
${FLEX_OUTPUT}
${CMAKE_CURRENT_SOURCE_DIR}/stdlib/stdlib.ispc
src/ast.cpp
src/ast.h
src/builtins.cpp
src/builtins.h
src/ctx.cpp
src/ctx.h
src/decl.cpp
src/decl.h
src/expr.cpp
src/expr.h
src/func.cpp
src/func.h
src/intrinsics.cpp
src/module.cpp
src/module.h
src/stmt.cpp
src/stmt.h
src/sym.cpp
src/sym.h
src/type.cpp
src/type.h
src/parse.yy
src/lex.ll
)
# ISPC optimization passes shared between ispc and ispc-opt
list(APPEND OPT_SOURCES
src/opt.cpp
src/opt.h
src/opt/CheckIRForXeTarget.cpp
src/opt/CheckIRForXeTarget.h
src/opt/GatherCoalescePass.cpp
src/opt/GatherCoalescePass.h
src/opt/IsCompileTimeConstant.cpp
src/opt/IsCompileTimeConstant.h
src/opt/ImproveMemoryOps.cpp
src/opt/ImproveMemoryOps.h
src/opt/InstructionSimplify.cpp
src/opt/InstructionSimplify.h
src/opt/IntrinsicsOptPass.cpp
src/opt/IntrinsicsOptPass.h
src/opt/LowerISPCIntrinsics.cpp
src/opt/LowerISPCIntrinsics.h
src/opt/MangleOpenCLBuiltins.cpp
src/opt/MangleOpenCLBuiltins.h
src/opt/PeepholePass.cpp
src/opt/PeepholePass.h
src/opt/RemovePersistentFuncs.cpp
src/opt/RemovePersistentFuncs.h
src/opt/ReplaceMaskedMemOps.cpp
src/opt/ReplaceMaskedMemOps.h
src/opt/ReplacePseudoMemoryOps.cpp
src/opt/ReplacePseudoMemoryOps.h
src/opt/ReplaceStdlibShiftPass.cpp
src/opt/ReplaceStdlibShiftPass.h
src/opt/ScalarizePass.cpp
src/opt/ScalarizePass.h
src/opt/XeGatherCoalescePass.cpp
src/opt/XeGatherCoalescePass.h
src/opt/XeReplaceLLVMIntrinsics.cpp
src/opt/XeReplaceLLVMIntrinsics.h
)
set(STDLIB_HEADERS core.isph stdlib.isph)
set(ALL_STDLIB_HEADERS
builtins.isph
core.isph
stdlib.isph
svml.isph
target.isph
)
set(STDLIB_ISPC_FILES stdlib/stdlib.ispc)
foreach (header ${ALL_STDLIB_HEADERS})
list(APPEND STDLIB_ISPC_FILES stdlib/include/${header})
endforeach()
# To show stdlib.ispc in VS solution:
if (WIN32)
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/stdlib/stdlib.ispc" PROPERTIES HEADER_FILE_ONLY TRUE)
source_group("ISPC" FILES "${CMAKE_CURRENT_SOURCE_DIR}/stdlib/stdlib.ispc")
endif()
# Build definitions
string(TIMESTAMP BUILD_DATE "%Y%m%d" UTC)
list(APPEND COMPILE_DEFINITIONS
BUILD_DATE=\"${BUILD_DATE}\"
BUILD_VERSION=\"${GIT_COMMIT_HASH}\"
)
if (UNIX)
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# Compile-time protection against static sized buffer overflows.
list(APPEND COMPILE_DEFINITIONS _FORTIFY_SOURCE=2)
endif()
else()
list(APPEND COMPILE_DEFINITIONS NOMINMAX)
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND COMPILE_DEFINITIONS NDEBUG)
endif()
endif()
# TODO: It may be confusing that some CMake variables start with ISPC but some
# not. It can be also useful to have same name for CMake var and the
# corresponding macro definition. It is not clear why it make sense to have
# different ones.
if (X86_ENABLED)
list(APPEND COMPILE_DEFINITIONS ISPC_X86_ENABLED)
endif()
if (ARM_ENABLED)
list(APPEND COMPILE_DEFINITIONS ISPC_ARM_ENABLED)
endif()
if (XE_ENABLED)
list(APPEND COMPILE_DEFINITIONS ISPC_XE_ENABLED)
endif()
if (WASM_ENABLED)
list(APPEND COMPILE_DEFINITIONS ISPC_WASM_ENABLED)
endif()
# Compile definitions for cross compilation
if (ISPC_WINDOWS_TARGET)
list(APPEND COMPILE_DEFINITIONS ISPC_WINDOWS_TARGET_ON)
else()
list(APPEND COMPILE_DEFINITIONS ISPC_WINDOWS_TARGET_OFF)
endif()
if (ISPC_LINUX_TARGET)
list(APPEND COMPILE_DEFINITIONS ISPC_LINUX_TARGET_ON)
else()
list(APPEND COMPILE_DEFINITIONS ISPC_LINUX_TARGET_OFF)
endif()
if (ISPC_FREEBSD_TARGET)
list(APPEND COMPILE_DEFINITIONS ISPC_FREEBSD_TARGET_ON)
else()
list(APPEND COMPILE_DEFINITIONS ISPC_FREEBSD_TARGET_OFF)
endif()
if (ISPC_MACOS_TARGET)
list(APPEND COMPILE_DEFINITIONS ISPC_MACOS_TARGET_ON)
else()
list(APPEND COMPILE_DEFINITIONS ISPC_MACOS_TARGET_OFF)
endif()
if (ISPC_IOS_TARGET)
list(APPEND COMPILE_DEFINITIONS ISPC_IOS_TARGET_ON)
else()
list(APPEND COMPILE_DEFINITIONS ISPC_IOS_TARGET_OFF)
endif()
if (ISPC_ANDROID_TARGET)
list(APPEND COMPILE_DEFINITIONS ISPC_ANDROID_TARGET_ON)
else()
list(APPEND COMPILE_DEFINITIONS ISPC_ANDROID_TARGET_OFF)
endif()
if (ISPC_PS_TARGET)
list(APPEND COMPILE_DEFINITIONS ISPC_PS_TARGET_ON)
else()
list(APPEND COMPILE_DEFINITIONS ISPC_PS_TARGET_OFF)
endif()
if (ISPC_UNIX_TARGET)
list(APPEND COMPILE_DEFINITIONS ISPC_UNIX_TARGET_ON)
else()
list(APPEND COMPILE_DEFINITIONS ISPC_UNIX_TARGET_OFF)
endif()
# Compile definition for opaque pointers mode
if (ISPC_OPAQUE_PTR_MODE)
list(APPEND COMPILE_DEFINITIONS ISPC_OPAQUE_PTR_MODE)
endif()
# Include directories
list(APPEND INCLUDE_DIRECTORIES
${LLVM_INCLUDE_DIRS}
${XE_DEPS_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/common
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
${CMAKE_BINARY_DIR}
)
list(APPEND COMPILE_OPTIONS)
# Compile options
if (MSVC)
list(APPEND COMPILE_OPTIONS
/W3
/wd4018
/wd4146
/wd4244
/wd4267
/wd4624
/wd4996
)
# Security options
list(APPEND COMPILE_OPTIONS
/GS
/EHsc
)
set_source_files_properties(${FLEX_OUTPUT} PROPERTIES COMPILE_FLAGS /wd4005)
set_source_files_properties(${BISON_OUTPUT} PROPERTIES COMPILE_FLAGS /wd4005)
else()
list(APPEND COMPILE_OPTIONS
-Wall
-Wextra
-Wno-unused-parameter
-Wno-sign-compare
-Wno-unused-function
${LLVM_CPP_FLAGS}
)
# Security options for both Debug and Release builds
list(APPEND COMPILE_OPTIONS
-fstack-protector-strong
-fno-delete-null-pointer-checks
-Wformat
-Wformat-security
-fwrapv
)
# Additional security options for Release mode
# Should be combined with link-time optimization (-Wl,--gc-sections during the linking phase)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
list(APPEND COMPILE_OPTIONS
-fdata-sections
-ffunction-sections
)
endif()
# Since 14.0 LLVM has switched default DWARF version from v4 to v5
# but gdb < 10.1 can't read DWARF v5.
# https://discourse.llvm.org/t/gdb-10-1-cant-read-clangs-dwarf-v5/6035
# Use DWARF v4 for ISPC build to allow debugging of ispc binary with gdb
# on Ubuntu 20.04
if (NOT CMAKE_BUILD_TYPE STREQUAL "Release")
list(APPEND COMPILE_OPTIONS -gdwarf-4)
endif()
endif()
if (NOT MSVC)
list(APPEND COMPILE_OPTIONS -fno-rtti)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND COMPILE_OPTIONS
-Wno-register
-Wno-error=comment
)
# The GCC warning issues false positives when one of the allocation and
# deallocation functions is inlined into its caller but not the other.
list(APPEND COMPILE_OPTIONS -Wno-mismatched-new-delete)
else()
list(APPEND COMPILE_OPTIONS
-Wno-c99-extensions
-Wno-deprecated-register
)
endif()
if (ISPC_USE_ASAN)
list(APPEND COMPILE_OPTIONS -fsanitize=address)
endif()
endif()
list(APPEND LINK_OPTIONS_PRIVATE)
list(APPEND LINK_OPTIONS_PUBLIC)
# Link options
if (WIN32)
list(APPEND LINK_OPTIONS_PRIVATE /DYNAMICBASE)
# Control flow guard
list(APPEND LINK_OPTIONS_PRIVATE /GUARD:CF)
# When resolving statically linked import dependencies of the module, limit
# the module search path to %windows%\system32 directory only.
list(APPEND LINK_OPTIONS_PRIVATE /DEPENDENTLOADFLAG:0x800)
if (MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
list(APPEND LINK_OPTIONS_PUBLIC /OPT:REF /OPT:ICF)
endif()
elseif (APPLE)
if(CMAKE_BUILD_TYPE MATCHES Release)
list(APPEND LINK_OPTIONS_PUBLIC "SHELL: -Wl,-dead_strip")
endif()
else()
# Common security hardening options for both Debug and Release
list(APPEND LINK_OPTIONS_PUBLIC
"SHELL: -z noexecstack"
"SHELL: -z relro"
"SHELL: -z now"
)
# Additional options for Release mode
if(CMAKE_BUILD_TYPE MATCHES Release)
list(APPEND LINK_OPTIONS_PUBLIC "SHELL: -Wl,--gc-sections")
endif()
endif()
if (ISPC_STATIC_STDCXX_LINK OR ISPC_STATIC_LINK)
list(APPEND LINK_OPTIONS_PUBLIC
-static-libgcc
-static-libstdc++
)
endif()
if (ISPC_USE_ASAN)
list(APPEND LINK_OPTIONS_PUBLIC -fsanitize=address)
endif()
list(APPEND LINK_LIBRARIES)
if (NOT WIN32 AND NOT APPLE)
# To resolve circular dependencies between libraries use --start-group/--end-group
list(APPEND LINK_LIBRARIES "-Wl,--start-group")
endif()
# Link against Clang libraries
foreach(clangLib ${CLANG_LIBRARY_LIST})
# Preferred way to build ISPC is to link it with individual clang static
# libraries. However, when they omitted it can be link with shared library
# libclang-cpp.so. Second approach would be utilized in some controlled
# environments, like in package managers for particular OSes (issue 2418).
find_library(${clangLib}Path
NAMES
"${CMAKE_STATIC_LIBRARY_PREFIX}${clangLib}${CMAKE_STATIC_LIBRARY_SUFFIX}"
clang-cpp
HINTS ${LLVM_LIBRARY_DIRS})
if (NOT ${${clangLib}Path} IN_LIST CLANG_LIBRARY_FULL_PATH_LIST)
list(APPEND CLANG_LIBRARY_FULL_PATH_LIST ${${clangLib}Path})
endif()
endforeach()
list(APPEND LINK_LIBRARIES ${CLANG_LIBRARY_FULL_PATH_LIST})
# Link against LLVM libraries
list(APPEND LINK_LIBRARIES ${LLVM_LIBRARY_LIST} ${CMAKE_DL_LIBS})
if (XE_ENABLED)
# Link against Xe libraries
foreach(xeLib ${XE_LIBRARY_LIST})
find_library(${xeLib}Path NAMES ${xeLib} HINTS ${XE_DEPS_DIR}/lib)
list(APPEND XE_LIBRARY_FULL_PATH_LIST ${${xeLib}Path})
endforeach()
list(APPEND LINK_LIBRARIES ${XE_LIBRARY_FULL_PATH_LIST})
endif()
if (NOT WIN32 AND NOT APPLE)
list(APPEND LINK_LIBRARIES "-Wl,--end-group")
endif()
# System libraries, our own and transitive dependencies from LLVM libs.
if (WIN32)
list(APPEND LINK_LIBRARIES version.lib shlwapi.lib odbc32.lib odbccp32.lib)
# Required after LLVM commit a5ffabc
if (${LLVM_VERSION_NUMBER} VERSION_GREATER_EQUAL "18.1.0")
list(APPEND LINK_LIBRARIES ws2_32.lib)
endif()
# Required after LLVM commit cb7690a
if (${LLVM_VERSION_NUMBER} VERSION_GREATER_EQUAL "19.1.0")
list(APPEND LINK_LIBRARIES ntdll.lib)
endif()
else()
run_llvm_config(LLVM_SYSTEM_LIBS "--system-libs")
if (LLVM_SYSTEM_LIBS MATCHES "pthread")
# ISPC doesn't use pthreads directly, but some LLVM does. Although, it
# looks like we do not use LLVM code that depend on pthreads, don't we?
find_library(PTHREAD_LIB REQUIRED NAMES pthread)
message(STATUS "Link with pthread library ${PTHREAD_LIB}")
list(APPEND LINK_LIBRARIES ${PTHREAD_LIB})
endif()
if (LLVM_SYSTEM_LIBS MATCHES "tinfo" OR LLVM_SYSTEM_LIBS MATCHES "curses")
find_library(TINFO_LIB REQUIRED NAMES terminfo tinfo curses ncurses ncursesw)
message(STATUS "Link with tinfo library ${TINFO_LIB}")
list(APPEND LINK_LIBRARIES ${TINFO_LIB})
endif()
endif()
# This function configures compile definitions, options and include dirs.
# It can be used for any objects or libraries that are built in the project.
function(configure_ispc_obj TARGET)
target_compile_definitions(${TARGET} PRIVATE ${COMPILE_DEFINITIONS})
target_include_directories(${TARGET} PRIVATE ${INCLUDE_DIRECTORIES})
target_compile_options(${TARGET} PRIVATE ${COMPILE_OPTIONS})
# Set hidden visibility for inline functions. This is needed to be in sync
# with LLVM libraries, we do include some template code from LLVM that requires
# this options to be in sync with LLVM. Otherwise it causes link warnings.
set_target_properties(${TARGET} PROPERTIES VISIBILITY_INLINES_HIDDEN ON)
if (NOT MSVC)
set_target_properties(${TARGET} PROPERTIES CXX_EXTENSIONS OFF)
endif()
endfunction()
# This function configures executable targets.
function(configure_ispc_exe TARGET)
configure_ispc_obj(${TARGET})
target_link_options(${TARGET} PRIVATE ${LINK_OPTIONS_PRIVATE})
target_link_options(${TARGET} PUBLIC ${LINK_OPTIONS_PUBLIC})
endfunction()
# This function creates and configures ispc-slim executable target under the given NAME.
function(add_ispc_slim NAME)
# Defines stdlib target
generate_stdlibs(${NAME})
# stdlib, stdlibs-bc, stdlibs-cpp targets are created in Stdlib.cmake
configure_ispc_obj(stdlib)
add_executable(${NAME} src/main.cpp src/binary_slim.cpp)
configure_ispc_exe(${NAME})
target_link_libraries(${NAME} ${LINK_LIBRARIES} optimization common frontend)
add_dependencies(${NAME} builtins-bc)
if (${NAME} STREQUAL "ispc")
set_target_properties(stdlibs-bc PROPERTIES EXCLUDE_FROM_ALL OFF)
endif()
endfunction()
# Define libraries that are built in the project. Some of them are shared across multiple executable targets.
add_library(optimization OBJECT EXCLUDE_FROM_ALL ${OPT_SOURCES})
configure_ispc_obj(optimization)
add_library(common OBJECT EXCLUDE_FROM_ALL ${COMMON_SOURCES})
configure_ispc_obj(common)
add_library(frontend OBJECT EXCLUDE_FROM_ALL ${FRONTEND_SOURCES})
configure_ispc_obj(frontend)
# builtin target is created in GenerateBuiltins.cmake
configure_ispc_obj(builtin)
# Define executable targets
add_executable(ispc-opt tools/ispc-opt.cpp)
configure_ispc_exe(ispc-opt)
# TODO! should we link against all the same LLVM/Clang libraries? Clang libs is definetely not needed
target_link_libraries(ispc-opt ${LINK_LIBRARIES} builtin optimization common)
# The final target has to be ispc due to two use-cases we do not want to
# interfere with: make ispc and $<TARGET_FILE:ispc>.
if (ISPC_SLIM_BINARY)
add_ispc_slim(ispc)
message(STATUS "ISPC will be built as a slim binary")
else()
add_ispc_slim(ispc-slim)
add_executable(ispc src/main.cpp src/binary_composite.cpp)
configure_ispc_exe(ispc)
target_link_libraries(ispc ${LINK_LIBRARIES} builtin stdlib optimization common frontend)
add_dependencies(ispc ispc-slim)
message(STATUS "ISPC will be built as a composite binary")
endif()
install (TARGETS ispc DESTINATION bin)
if (ISPC_SLIM_BINARY)
foreach (header ${STDLIB_HEADERS})
install (FILES "stdlib/include/${header}" DESTINATION include)
endforeach()
install(DIRECTORY ${BITCODE_FOLDER} DESTINATION share)
endif()
if (ISPC_INCLUDE_TESTS)
add_subdirectory(tests)
endif()
if (ISPC_INCLUDE_BENCHMARKS)
enable_testing()
add_subdirectory(benchmarks)
endif()
if (ISPC_INCLUDE_RT)
add_subdirectory(ispcrt)
endif()
if (NOT X86_ENABLED)
# examples use x86 targets
set(ISPC_INCLUDE_EXAMPLES OFF)
endif()
if (ISPC_INCLUDE_EXAMPLES AND NOT ISPC_PREPARE_PACKAGE)
include(ExternalProject)
ExternalProject_Add(ispc_cpu_examples
PREFIX cpu_examples
DEPENDS ispc stdlibs-bc stdlib-headers
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/examples/cpu"
CMAKE_CACHE_ARGS
-DISPC_BUILD:BOOL=TRUE
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_ISPC_COMPILER:PATH=$<TARGET_FILE:ispc>
-DISPC_EXECUTABLE:PATH=$<TARGET_FILE:ispc>
-DCMAKE_C_COMPILER:PATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:PATH=${CMAKE_CXX_COMPILER}
INSTALL_COMMAND ""
)
endif()
if (ISPC_INCLUDE_XE_EXAMPLES AND ISPC_INCLUDE_RT AND NOT ISPC_PREPARE_PACKAGE)
include(ExternalProject)
if (WIN32)
set(ISPCRT_LIB ${CMAKE_CURRENT_BINARY_DIR}/ispcrt/${CMAKE_CFG_INTDIR}/ispcrt.lib)
else()
set(ISPCRT_LIB $<TARGET_FILE:ispcrt>)
endif()
if (ISPC_INCLUDE_BENCHMARKS)
# Duplicated ExternalProject_Add for xpu examples when
# ISPC_INCLUDE_BENCHMARKS is on and off since all efforts of
# using cmake generator conditional expressions were unsuccessful.
ExternalProject_Add(ispc_xpu_examples
PREFIX xpu_examples
DEPENDS ispc stdlibs-bc stdlib-headers ispcrt benchmark
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/examples/xpu"
CMAKE_CACHE_ARGS
-DISPC_BUILD:BOOL=TRUE
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_ISPC_COMPILER:PATH=$<TARGET_FILE:ispc>
-DISPC_EXECUTABLE:PATH=$<TARGET_FILE:ispc>
-DISPCRT_LIB:PATH=${ISPCRT_LIB}
-DLEVEL_ZERO_ROOT:PATH=${LEVEL_ZERO_ROOT}
-DBENCHMARK_LIB:PATH=$<TARGET_FILE:benchmark>
-DCMAKE_C_COMPILER:PATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:PATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_FLAGS:PATH=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS:PATH=${CMAKE_CXX_FLAGS}
-DISPC_INCLUDE_BENCHMARKS:BOOL=${ISPC_INCLUDE_BENCHMARKS}
INSTALL_COMMAND ""
)
else()
ExternalProject_Add(ispc_xpu_examples
PREFIX xpu_examples
DEPENDS ispc stdlibs-bc stdlib-headers ispcrt
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/examples/xpu"
CMAKE_CACHE_ARGS
-DISPC_BUILD:BOOL=TRUE
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_ISPC_COMPILER:PATH=$<TARGET_FILE:ispc>
-DISPC_EXECUTABLE:PATH=$<TARGET_FILE:ispc>
-DISPCRT_LIB:PATH=${ISPCRT_LIB}
-DLEVEL_ZERO_ROOT:PATH=${LEVEL_ZERO_ROOT}