-
Notifications
You must be signed in to change notification settings - Fork 234
/
CMakeLists.txt
1030 lines (890 loc) · 38.3 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: MIT
#
cmake_minimum_required(VERSION 3.13.0 FATAL_ERROR)
if(NEO_ENABLE_INTERPROCEDURAL_OPTIMIZATION)
cmake_policy(SET CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
set(NEO_DISABLE_LD_LLD TRUE)
message(STATUS "Enabling interprocedural optimization")
endif()
# Set the runtime source directory
if(NOT DEFINED NEO_SOURCE_DIR)
set(NEO_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(CMAKE_GENERATOR_TOOLSET "host=x64")
endif()
if(NOT PROJECT_NAME)
set(PROJECT_NAME igdrcl)
endif()
project(${PROJECT_NAME})
file(READ ".branch" BRANCH_TYPE)
string(STRIP "${BRANCH_TYPE}" BRANCH_TYPE)
set(BRANCH_DIR_SUFFIX "/${BRANCH_TYPE}")
list(APPEND BRANCH_DIR_LIST "/")
if(NOT "${BRANCH_TYPE}" STREQUAL "")
list(APPEND BRANCH_DIR_LIST "/${BRANCH_TYPE}/")
set(BRANCH_DIR_SUFFIX "${BRANCH_DIR_SUFFIX}/")
endif()
message(STATUS "branch dir list: ${BRANCH_DIR_LIST}")
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(NEO_TARGET_PROCESSOR "x86_64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
set(NEO_TARGET_PROCESSOR "x86_64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(NEO_TARGET_PROCESSOR "aarch64")
if(NOT ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_SYSTEM_PROCESSOR})
set(NEO_DISABLE_LD_LLD TRUE)
set(NEO_DISABLE_LD_GOLD TRUE)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/sse2neon)
endif()
message(STATUS "Host processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message(STATUS "Target processor: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "Neo target processor: ${NEO_TARGET_PROCESSOR}")
if(NOT DEFINED NEO_TARGET_PROCESSOR)
message(FATAL_ERROR "Unsupported target processor: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
# Include custom configs
include("${BRANCH_TYPE}/custom_config.cmake" OPTIONAL)
# Include needed macros
include(cmake/common_macros.cmake)
if(CMAKE_CONFIGURATION_TYPES)
# Set custom build types for multi-configuration generators
set(CMAKE_CONFIGURATION_TYPES "Release;ReleaseInternal;Debug")
if(DEFINED CMAKE_BUILD_TYPE)
list(APPEND CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE})
endif()
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
endif()
include(GNUInstallDirs)
if(USE_SANITIZE_UB AND WIN32)
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker /NODEFAULTLIB:clang_rt.ubsan_standalone_cxx-x86_64.lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker /NODEFAULTLIB:clang_rt.ubsan_standalone_cxx-x86_64.lib")
endif()
if(NOT DEFINED NEO_USE_CL_CACHE)
set(NEO_USE_CL_CACHE FALSE CACHE BOOL "use cl_cache when running ocloc" FORCE)
endif()
if(NEO_USE_CL_CACHE)
set(NEO_DISABLE_BUILTINS_COMPILATION FALSE)
endif()
# define global property where we will collect component list to package
define_property(GLOBAL PROPERTY NEO_OCL_COMPONENTS_LIST BRIEF_DOCS "List of components" FULL_DOCS "List of components to create packages")
set(GLOBAL PROPERTY NEO_OCL_COMPONENTS_LIST "")
define_property(GLOBAL PROPERTY NEO_L0_COMPONENTS_LIST BRIEF_DOCS "List of components" FULL_DOCS "List of components to create packages")
set(GLOBAL PROPERTY NEO_L0_COMPONENTS_LIST "")
string(REPLACE " " ";" NEO_RUN_INTERCEPTOR_LIST "${NEO_RUN_INTERCEPTOR}")
if(TR_DEPRECATED)
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1)
endif()
if(RELEASE_WITH_REGKEYS)
message(STATUS "Enabling RegKey reading in release build")
add_definitions(-D_RELEASE_BUILD_WITH_REGKEYS)
endif()
if(ENABLE_DYNAMIC_MEMORY_TRACKING)
message(STATUS "Enabling dynamic memory tracking")
add_definitions(-DENABLE_DYNAMIC_MEMORY_TRACKING)
endif()
if(NEO_SERIALIZED_BUILTINS_COMPILATION)
message(STATUS "Enabling serialized builtins compilation")
endif()
if(DEFINED NEO_EXTRA_DEFINES)
string(REPLACE "," ";" NEO_EXTRA_DEFINES "${NEO_EXTRA_DEFINES}")
foreach(_tmp ${NEO_EXTRA_DEFINES})
message(STATUS "adding extra define: ${_tmp}")
add_definitions(-D${_tmp})
endforeach()
endif()
include("${BRANCH_TYPE}/${BRANCH_TYPE}.cmake" OPTIONAL)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE not specified, using Release")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type: [Release, ReleaseInternal, Debug]" FORCE)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(NEO_BITS "64")
set(NEO_ARCH "x64")
else()
set(NEO_BITS "32")
set(NEO_ARCH "x86")
endif()
if(NOT DEFINED NEO_BUILD_WITH_OCL)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/opencl/CMakeLists.txt)
set(NEO_BUILD_WITH_OCL TRUE)
endif()
endif()
if(NOT DEFINED BUILD_WITH_L0)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/level_zero/CMakeLists.txt)
if("${NEO_BITS}" STREQUAL "64")
set(BUILD_WITH_L0 TRUE)
endif()
endif()
endif()
if(NOT "${NEO_BITS}" STREQUAL "64")
set(BUILD_WITH_L0 FALSE)
endif()
add_definitions(
-DCL_USE_DEPRECATED_OPENCL_1_1_APIS
-DCL_USE_DEPRECATED_OPENCL_1_2_APIS
-DCL_USE_DEPRECATED_OPENCL_2_0_APIS
-DCL_USE_DEPRECATED_OPENCL_2_1_APIS
-DCL_USE_DEPRECATED_OPENCL_2_2_APIS
)
add_definitions(-D__user= -D__packed=)
set(CMAKE_C_FLAGS_RELEASEINTERNAL "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASEINTERNAL "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASEINTERNAL "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
if(MSVC AND ENABLE_VS_FASTLINK)
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " /debug:FASTLINK")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " /debug:FASTLINK")
string(APPEND CMAKE_STATIC_LINKER_FLAGS_DEBUG " /debug:FASTLINK")
string(APPEND CMAKE_MODULE_LINKER_FLAGS_DEBUG " /debug:FASTLINK")
endif()
include(CheckCXXCompilerFlag)
if(UNIX)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" AND(
${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 9.0 OR
(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 12.0 AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 13.0
)))
message(STATUS "Disabling LTO because compiler is ${CMAKE_CXX_COMPILER_ID} v${CMAKE_CXX_COMPILER_VERSION}")
set(NEO_DISABLE_LTO TRUE)
endif()
if(NOT NEO_DISABLE_LTO)
check_cxx_compiler_flag("-flto=auto" COMPILER_SUPPORTS_FLTO_AUTO)
if(COMPILER_SUPPORTS_FLTO_AUTO)
message(STATUS "enabling lto=auto, disabling ld.lld")
set(NEO_DISABLE_LD_LLD TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=auto")
check_cxx_compiler_flag("-ffat-lto-objects" COMPILER_SUPPORTS_FAT_LTO_OBJECTS)
if(COMPILER_SUPPORTS_FAT_LTO_OBJECTS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffat-lto-objects")
endif()
endif()
endif()
find_program(__LD_GOLD_FOUND ld.gold)
find_program(__LD_LLD_FOUND ld.lld)
check_cxx_compiler_flag(-fuse-ld=lld COMPILER_SUPPORTS_LLD)
check_cxx_compiler_flag(-fuse-ld=gold COMPILER_SUPPORTS_GOLD)
if(NOT NEO_DISABLE_LD_LLD AND COMPILER_SUPPORTS_LLD AND __LD_LLD_FOUND)
message(STATUS "Using linker: ld.lld")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -Wl,--build-id=sha1")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld -Wl,--build-id=sha1")
elseif(NOT NEO_DISABLE_LD_GOLD AND COMPILER_SUPPORTS_GOLD AND __LD_GOLD_FOUND)
message(STATUS "Using linker: ld.gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
else()
message(STATUS "Using linker: default")
endif()
if(ENABLE_DYNAMIC_MEMORY_TRACKING)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic")
endif()
if(NEO_BUILD_DEBUG_SYMBOLS_PACKAGE)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -g")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -g")
endif()
set(CMAKE_C_FLAGS_RELEASEINTERNAL "${CMAKE_C_FLAGS_RELEASEINTERNAL} -g")
set(CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL} -g")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASEINTERNAL "${CMAKE_SHARED_LINKER_FLAGS_RELEASEINTERNAL} -g")
set(CMAKE_EXE_LINKER_FLAGS_RELEASEINTERNAL "${CMAKE_EXE_LINKER_FLAGS_RELEASEINTERNAL} -g")
endif()
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_lower)
if("${BUILD_TYPE_lower}" STREQUAL "releaseinternal")
add_definitions(-D_RELEASE_INTERNAL)
endif("${BUILD_TYPE_lower}" STREQUAL "releaseinternal")
message(STATUS "${CMAKE_BUILD_TYPE} build configuration")
# Set the ocloc directory
if(NOT DEFINED OCLOC_DIRECTORY)
set(OCLOC_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/shared/offline_compiler)
endif()
# Set the shared source directory
if(NOT DEFINED NEO_SHARED_DIRECTORY)
set(NEO_SHARED_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/shared/source)
endif()
# Set the shared test directory
if(NOT DEFINED NEO_SHARED_TEST_DIRECTORY)
set(NEO_SHARED_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/shared/test)
endif()
# leave temporarily for compatibitlity
if(DEFINED SKIP_UNIT_TESTS)
set(NEO_SKIP_UNIT_TESTS ${SKIP_UNIT_TESTS})
endif()
if(NEO_SKIP_UNIT_TESTS)
set(NEO_SKIP_SHARED_UNIT_TESTS TRUE)
set(NEO_SKIP_OCL_UNIT_TESTS TRUE)
set(NEO_SKIP_L0_UNIT_TESTS TRUE)
set(NEO_SKIP_L0_BLACK_BOX_TESTS TRUE)
endif()
if(DEFINED NEO_GENERATE_AUBS_FOR)
if(DEFINED NEO_SKIP_AUB_TESTS_RUN AND NEO_SKIP_AUB_TESTS_RUN)
message(FATAL_ERROR "Invalid cmake flags combination, NEO_GENERATE_AUBS_FOR assumes aub tests execution is not skipped")
endif()
set(NEO_SKIP_AUB_TESTS_RUN FALSE)
endif()
if(NOT DEFINED NEO_SKIP_AUB_TESTS_RUN)
set(NEO_SKIP_AUB_TESTS_RUN TRUE)
endif()
if(NOT DEFINED NEO_SKIP_AUB_TESTS)
set(NEO_SKIP_AUB_TESTS TRUE)
endif()
if(NOT NEO_SKIP_AUB_TESTS_RUN)
set(NEO_SKIP_AUB_TESTS FALSE)
endif()
if(NEO_IGNORE_INVALID_TEST_EXCLUDES)
add_definitions(-DNEO_IGNORE_INVALID_TEST_EXCLUDES)
endif()
message(STATUS "NEO_SKIP_AUB_TESTS: ${NEO_SKIP_AUB_TESTS}")
message(STATUS "NEO_SKIP_AUB_TESTS_RUN: ${NEO_SKIP_AUB_TESTS_RUN}")
# Set our build directory
if(NOT DEFINED NEO_BUILD_DIR)
set(NEO_BUILD_DIR ${CMAKE_BINARY_DIR})
endif()
if(NOT NEO_BINARY_DIR)
set(NEO_BINARY_DIR ${CMAKE_BINARY_DIR})
endif()
# we use c++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# we force using response files
set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)
# set output paths
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${NEO_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${NEO_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${NEO_BINARY_DIR}/lib)
# determine Neo version
include(version.cmake)
# set variables for symbols stripping
if(UNIX AND NEO_BUILD_DEBUG_SYMBOLS_PACKAGE)
set_property(GLOBAL PROPERTY DEBUG_SYMBOL_FILES "")
set_property(GLOBAL PROPERTY IGDRCL_SYMBOL_FILE "")
set_property(GLOBAL APPEND PROPERTY NEO_OCL_COMPONENTS_LIST "opencl-debuginfo")
set(STRIP_SYMBOLS_TARGET strip_debug_symbols)
set(DEBUG_SYMBOL_INSTALL_DIR "/usr/lib/debug${CMAKE_INSTALL_FULL_LIBDIR}")
add_custom_target(${STRIP_SYMBOLS_TARGET} ALL)
endif()
# We want to build with the static, multithreaded runtime libraries (as opposed
# to the multithreaded runtime DLLs)
if(WIN32)
if(MSVC)
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL}")
string(REPLACE "/GR" "/GR-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_definitions(-D_HAS_STATIC_RTTI=0)
else()
string(REPLACE "-D_DLL " "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "-D_DLL " "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "-D_DLL " "" CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL}")
endif()
add_definitions(-DPURGE_DEBUG_KEY_NAMES=1)
else()
add_definitions(-DPURGE_DEBUG_KEY_NAMES=0)
endif()
if(NOT NEO_SKIP_UNIT_TESTS)
if(NOT DEFINED GTEST_REPEAT)
set(GTEST_REPEAT 1)
endif()
message(STATUS "GTest repeat count set to ${GTEST_REPEAT}")
if(NOT DEFINED GTEST_SHUFFLE)
set(GTEST_SHUFFLE --gtest_shuffle --gtest_random_seed=0)
endif()
message(STATUS "GTest shuffle set to ${GTEST_SHUFFLE}")
endif()
if(NOT KMDAF_HEADERS_DIR)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../kmdaf/inc/common/kmDaf.h")
get_filename_component(KMDAF_HEADERS_DIR "../kmdaf/inc/common/" ABSOLUTE)
message(STATUS "KM-DAF headers dir: ${KMDAF_HEADERS_DIR}")
endif()
endif()
get_filename_component(AUB_STREAM_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}aub_stream" ABSOLUTE)
if(IS_DIRECTORY ${AUB_STREAM_HEADERS_DIR})
message(STATUS "Aub Stream Headers dir: ${AUB_STREAM_HEADERS_DIR}")
else()
message(FATAL_ERROR "Aub Stream headers not available!")
endif()
if(TARGET aub_stream)
set(AUB_STREAM_PROJECT_NAME "aub_stream")
get_target_property(AUB_STREAM_HEADERS_DIR ${AUB_STREAM_PROJECT_NAME} INTERFACE_INCLUDE_DIRECTORIES)
else()
if(NOT DEFINED AUB_STREAM_DIR)
get_filename_component(TEMP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../aub_stream/aub_mem_dump" ABSOLUTE)
if(IS_DIRECTORY ${TEMP_DIR})
get_filename_component(AUB_STREAM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../aub_stream" ABSOLUTE)
message(STATUS "Aub Stream dir: ${AUB_STREAM_DIR}")
endif()
endif()
if(DISABLE_AUB_STREAM)
unset(AUB_STREAM_DIR)
endif()
endif()
if(NOT DEFINED KHRONOS_HEADERS_DIR)
get_filename_component(DIR_tmp "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opencl_headers" ABSOLUTE)
if(IS_DIRECTORY ${DIR_tmp})
set(KHRONOS_HEADERS_DIR ${DIR_tmp})
add_definitions(-DCL_TARGET_OPENCL_VERSION=300)
else()
message(FATAL_ERROR "Khronos OpenCL headers not available!")
endif()
elseif(DEFINED CL_TARGET_OPENCL_VERSION)
add_definitions(-DCL_TARGET_OPENCL_VERSION=${CL_TARGET_OPENCL_VERSION})
else()
add_definitions(-DCL_TARGET_OPENCL_VERSION=300)
endif()
message(STATUS "Khronos OpenCL headers dir: ${KHRONOS_HEADERS_DIR}")
set(OCL_HEADERS_DIR ${KHRONOS_HEADERS_DIR})
if(NOT DEFINED KHRONOS_GL_HEADERS_DIR)
get_filename_component(GL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opengl_headers" ABSOLUTE)
if(IS_DIRECTORY ${GL_DIR})
set(KHRONOS_GL_HEADERS_DIR ${GL_DIR})
add_definitions(-DGL_TARGET_OPENGL_VERSION=210)
endif()
elseif(DEFINED GL_TARGET_OPENGL_VERSION)
add_definitions(-DGL_TARGET_OPENGL_VERSION=${GL_TARGET_OPENGL_VERSION})
else()
add_definitions(-DGL_TARGET_OPENGL_VERSION=210)
endif()
message(STATUS "Khronos OpenGL headers dir: ${KHRONOS_GL_HEADERS_DIR}")
if(NOT DEFINED AOT_CONFIG_HEADERS_DIR)
get_filename_component(AOT_CONFIG_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}aot_config_headers" ABSOLUTE)
message(STATUS "AOT config headers dir: ${AOT_CONFIG_HEADERS_DIR}")
endif()
# Intel Graphics Compiler detection
include(cmake/find_igc.cmake)
# GmmLib detection
include(cmake/find_gmmlib.cmake)
# Metrics detection
include(cmake/find_metrics.cmake)
# LibVA detection
if(NOT DISABLE_LIBVA)
if(UNIX)
set(NEO__LIBVA_IS_REQUIRED "")
if(IGDRCL_FORCE_USE_LIBVA)
set(NEO__LIBVA_IS_REQUIRED "REQUIRED")
endif()
if(DEFINED LIBVA_SOURCE_DIR)
get_filename_component(LIBVA_SOURCE_DIR "${LIBVA_SOURCE_DIR}" ABSOLUTE)
else()
get_filename_component(LIBVA_SOURCE_DIR_tmp "${NEO_SOURCE_DIR}/../libva" ABSOLUTE)
if(IS_DIRECTORY "${LIBVA_SOURCE_DIR_tmp}")
set(LIBVA_SOURCE_DIR "${LIBVA_SOURCE_DIR_tmp}")
endif()
endif()
find_package(PkgConfig)
if(DEFINED LIBVA_SOURCE_DIR AND IS_DIRECTORY "${LIBVA_SOURCE_DIR}/lib/pkgconfig/")
set(OLD_PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH})
set(ENV{PKG_CONFIG_PATH} "${LIBVA_SOURCE_DIR}/lib/pkgconfig/")
endif()
pkg_check_modules(NEO__LIBVA ${NEO__LIBVA_IS_REQUIRED} libva>=1.0.0)
include(CheckLibraryExists)
if(DEFINED LIBVA_SOURCE_DIR AND IS_DIRECTORY "${LIBVA_SOURCE_DIR}/lib/pkgconfig/")
set(ENV{PKG_CONFIG_PATH} ${OLD_PKG_CONFIG_PATH})
endif()
if(NEO__LIBVA_FOUND)
CHECK_LIBRARY_EXISTS(va vaGetLibFunc ${NEO__LIBVA_LIBDIR} HAVE_VAGETLIBFUNC)
add_definitions(-DLIBVA)
message(STATUS "Using libva ")
if(DEFINED LIBVA_SOURCE_DIR AND IS_DIRECTORY "${LIBVA_SOURCE_DIR}/lib/pkgconfig/")
string(REPLACE "${NEO__LIBVA_INCLUDEDIR}" "${LIBVA_SOURCE_DIR}/include" NEO__LIBVA_INCLUDE_DIRS "${NEO__LIBVA_INCLUDE_DIRS}")
string(REPLACE "${NEO__LIBVA_LIBDIR}" "${LIBVA_SOURCE_DIR}/lib" NEO__LIBVA_LIBDIR "${NEO__LIBVA_LIBDIR}")
set(NEO__LIBVA_LIBRARY_PATH "${NEO__LIBVA_LIBDIR}")
endif()
list(LENGTH NEO__LIBVA_INCLUDE_DIRS __len)
if(__len GREATER 0)
set(NEO__LIBVA_INCLUDE_DIR ${NEO__LIBVA_INCLUDE_DIRS})
include_directories("${NEO__LIBVA_INCLUDE_DIR}")
message(STATUS "LibVA include dirs: ${NEO__LIBVA_INCLUDE_DIR}")
endif()
endif()
endif()
endif()
include(cmake/find_gtest.cmake)
message(STATUS "AUB_STREAM_DIR = ${AUB_STREAM_DIR}")
if(DEFINED AUB_STREAM_DIR)
set(AUB_STREAM_PROJECT_NAME "aub_stream")
add_subdirectory_unique(${AUB_STREAM_DIR} ${CMAKE_BINARY_DIR}/aub_stream EXCLUDE_FROM_ALL)
get_target_property(ENGINE_NODE_DIR ${AUB_STREAM_PROJECT_NAME} INTERFACE_INCLUDE_DIRECTORIES)
if(NOT EXISTS ${ENGINE_NODE_DIR}/aubstream/engine_node.h)
set(ENGINE_NODE_DIR ${AUB_STREAM_HEADERS_DIR})
endif()
else()
set(ENGINE_NODE_DIR ${AUB_STREAM_HEADERS_DIR})
endif()
message(STATUS "Engine node dir: ${ENGINE_NODE_DIR}")
if(NEO_FORCE_USE_AUB_STREAM AND NOT DEFINED AUB_STREAM_PROJECT_NAME)
message(FATAL_ERROR "Aubstream is not available but required by user")
endif()
# We want to organize our IDE targets into folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Get available platforms
if(DEFINED NEO_ALLOW_LEGACY_PLATFORMS_SUPPORT AND NOT DEFINED NEO_LEGACY_PLATFORMS_SUPPORT)
set(NEO_LEGACY_PLATFORMS_SUPPORT ${NEO_ALLOW_LEGACY_PLATFORMS_SUPPORT})
endif()
if(NOT DEFINED NEO_LEGACY_PLATFORMS_SUPPORT)
set(NEO_LEGACY_PLATFORMS_SUPPORT FALSE)
endif()
if(NOT DEFINED NEO_CURRENT_PLATFORMS_SUPPORT)
set(NEO_CURRENT_PLATFORMS_SUPPORT TRUE)
endif()
set(NEO__LEGACY_NAME_SUFFIX "_legacy1")
if(NEO_LEGACY_PLATFORMS_SUPPORT AND NOT NEO_CURRENT_PLATFORMS_SUPPORT)
if(NOT DEFINED NEO_OCLOC_VERSION_MODE)
set(NEO_OCLOC_VERSION_MODE "0")
endif()
set(NEO__SO_NAME_SUFFIX ${NEO__LEGACY_NAME_SUFFIX})
endif()
if(NOT DEFINED NEO_OCLOC_VERSION_MODE)
set(NEO_OCLOC_VERSION_MODE "1")
endif()
include(platforms.cmake)
list(LENGTH ALL_PRODUCT_FAMILY_LIST ALL_PRODUCT_FAMILY_LIST_COUNT)
if(1 EQUAL ${ALL_PRODUCT_FAMILY_LIST_COUNT})
SET(NEO_SINGLE_SKU_BUILD TRUE)
message(STATUS "Single Sku Build detected")
endif()
if(WIN32)
set(DISABLE_WDDM_LINUX TRUE)
endif()
if(PLATFORMS_TO_HAVE_WDDM_DISABLED AND NOT DISABLE_WDDM_LINUX)
message(STATUS "Platforms to have WDDM_LINUX disabled: ${PLATFORMS_TO_HAVE_WDDM_DISABLED}")
set(PLATFORMS_TO_HAVE_WDDM_ENABLED ${SUPPORTED_PLATFORM_LIST})
foreach(SKU_NAME ${PLATFORMS_TO_HAVE_WDDM_DISABLED})
list(REMOVE_ITEM PLATFORMS_TO_HAVE_WDDM_ENABLED ${SKU_NAME})
endforeach()
if(NOT PLATFORMS_TO_HAVE_WDDM_ENABLED)
set(DISABLE_WDDM_LINUX TRUE)
endif()
unset(PLATFORMS_TO_HAVE_WDDM_ENABLED)
endif()
unset(PLATFORMS_TO_HAVE_WDDM_DISABLED)
include(cmake/find_wdk.cmake)
if(WIN32)
set(DRIVER_MODEL wddm)
else()
if(DISABLE_WDDM_LINUX)
set(DRIVER_MODEL drm)
else()
set(DRIVER_MODEL drm_or_wddm)
endif()
endif()
message(STATUS "Driver model : ${DRIVER_MODEL}")
if(WIN32 OR NOT DISABLE_WDDM_LINUX)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DWDDM_VERSION_NUMBER=23 -DNOMINMAX)
add_definitions(-DLEGACY_D3DAPI_VERSION=20)
if(NOT WIN32)
add_definitions(-DWDDM_LINUX=1)
endif()
endif()
if(UNIX)
# prelim headers detection
if(NOT ("${BRANCH_TYPE}" STREQUAL ""))
set(NEO_ENABLE_I915_PRELIM_DETECTION TRUE)
elseif(NOT DEFINED NEO_ENABLE_I915_PRELIM_DETECTION)
set(NEO_ENABLE_I915_PRELIM_DETECTION FALSE)
endif()
message(STATUS "i915 prelim headers detection: ${NEO_ENABLE_I915_PRELIM_DETECTION}")
if(NOT ("${BRANCH_TYPE}" STREQUAL ""))
set(NEO_ENABLE_XE_PRELIM_DETECTION TRUE)
elseif(NOT DEFINED NEO_ENABLE_XE_PRELIM_DETECTION)
set(NEO_ENABLE_XE_PRELIM_DETECTION FALSE)
endif()
message(STATUS "xe prelim headers detection: ${NEO_ENABLE_XE_PRELIM_DETECTION}")
# drm-xe support
if(NOT ("${BRANCH_TYPE}" STREQUAL ""))
set(NEO_ENABLE_XE_EU_DEBUG_SUPPORT TRUE)
elseif(NOT DEFINED NEO_ENABLE_XE_EU_DEBUG_SUPPORT)
set(NEO_ENABLE_XE_EU_DEBUG_SUPPORT FALSE)
endif()
message(STATUS "Xe EU Debug support: ${NEO_ENABLE_XE_EU_DEBUG_SUPPORT}")
if((NEO_USE_XE_EU_DEBUG_EXP_UPSTREAM OR NOT NEO_ENABLE_XE_PRELIM_DETECTION) AND ("${BRANCH_TYPE}" STREQUAL ""))
get_filename_component(XE_DEBUG_INCLUDE_DIR "${NEO_SOURCE_DIR}/shared/source/debugger/linux/" ABSOLUTE)
else()
get_filename_component(XE_DEBUG_INCLUDE_DIR "${NEO_SOURCE_DIR}/shared/source/debugger/linux/prelim" ABSOLUTE)
endif()
include_directories(BEFORE ${XE_DEBUG_INCLUDE_DIR})
endif()
include(cmake${BRANCH_DIR_SUFFIX}/find_drm.cmake)
# Enable/Disable BuiltIns compilation during build
set(COMPILE_BUILT_INS TRUE CACHE BOOL "Enable built-in kernels compilation")
if(NOT DEFINED NEO_KERNELS_BIN_DIR)
string(REPLACE "internal" "" NEO_KERNELS_BUILD_TYPE_DIR "${BUILD_TYPE_lower}")
message(STATUS "Neo kernels build type dir: ${NEO_KERNELS_BUILD_TYPE_DIR}")
if(WIN32)
get_filename_component(NEO_KERNELS_BIN_DIR "${NEO_SOURCE_DIR}/../kernels_bin/windows/${NEO_KERNELS_BUILD_TYPE_DIR}" ABSOLUTE)
else()
get_filename_component(NEO_KERNELS_BIN_DIR "${NEO_SOURCE_DIR}/../kernels_bin/linux" ABSOLUTE)
endif()
endif()
# Changing the default executable and library output directories
set(IGDRCL_OUTPUT_DIR "${IGDRCL_OPTION__OUTPUT_DIR}")
# do not add rpath
set(CMAKE_SKIP_RPATH YES CACHE BOOL "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
option(APPVERIFIER_ALLOWED "allow use of AppVerifier" OFF)
option(CCACHE_ALLOWED "allow use of ccache" TRUE)
if((CMAKE_HOST_UNIX OR("${CMAKE_GENERATOR}" STREQUAL "Ninja")) AND CCACHE_ALLOWED)
find_program(CCACHE_EXE_FOUND ccache)
if(CCACHE_EXE_FOUND)
message(STATUS "Found ccache: ${CCACHE_EXE_FOUND}")
if(NOT NEO_DONT_SET_CCACHE_BASEDIR AND NOT DEFINED ENV{CCACHE_BASEDIR})
get_filename_component(__tmp_dir "../infra" ABSOLUTE)
if(IS_DIRECTORY ${__tmp_dir})
get_filename_component(NEO_CCACHE_BASEDIR ".." ABSOLUTE)
if(CMAKE_HOST_WIN32)
list(APPEND NEO_RULE_LAUNCH_LIST "\"${CMAKE_COMMAND}\" -E env CCACHE_BASEDIR=${NEO_CCACHE_BASEDIR}")
else()
list(APPEND NEO_RULE_LAUNCH_LIST "CCACHE_BASEDIR=${NEO_CCACHE_BASEDIR}")
endif()
message(STATUS "setting ccache base dir: ${NEO_CCACHE_BASEDIR}")
endif()
elseif(DEFINED ENV{CCACHE_BASEDIR})
message(STATUS "Using ccache base dir: $ENV{CCACHE_BASEDIR}")
endif()
list(APPEND NEO_RULE_LAUNCH_LIST "${CCACHE_EXE_FOUND}")
string(REPLACE ";" " " NEO_RULE_LAUNCH_STR "${NEO_RULE_LAUNCH_LIST}")
message(STATUS "Using rule: ${NEO_RULE_LAUNCH_STR}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${NEO_RULE_LAUNCH_STR})
if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${NEO_RULE_LAUNCH_STR})
else()
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_EXE_FOUND}")
endif()
endif()
endif()
# Miscs options
option(IGDRCL_GCOV "generate gcov report" OFF)
option(NEO_SHOW_VERBOSE_ULT_RESULTS "Use the default/verbose test output" OFF)
if(NOT NEO_SHOW_VERBOSE_ULT_RESULTS)
set(NEO_TESTS_LISTENER_OPTION "--disable_default_listener")
else()
set(NEO_TESTS_LISTENER_OPTION "--enable_default_listener")
endif()
if(MSVC)
# Force to treat warnings as errors
if(NOT CMAKE_CXX_FLAGS MATCHES "/WX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4189 /we4388")
endif()
endif()
# Disable generating manifest
set(LINKER_FLAGS "/MANIFEST:NO")
# Disable COMDAT folding optimization
set(LINKER_FLAGS "${LINKER_FLAGS} /OPT:NOICF")
# Use legacy float rounding
set(LINKER_FLAGS "${LINKER_FLAGS} legacy_stdio_float_rounding.obj")
set(LINKER_FLAGS "${LINKER_FLAGS} /CETCOMPAT")
# Support for WUD
set(CMAKE_CXX_STANDARD_LIBRARIES "onecore.lib")
foreach(IT kernel32.lib;user32.lib;gdi32.lib;advapi32.lib;ole32.lib;)
set(LINKER_FLAGS "${LINKER_FLAGS} /NODEFAULTLIB:${IT}")
endforeach()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
add_definitions(-DUNICODE -D_UNICODE)
else()
if(IGDRCL_GCOV)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage --coverage")
endif()
option(USE_ASAN "Link with address sanitization support" OFF)
if(USE_ASAN)
if(CMAKE_COMPILER_IS_GNUCC)
set(ASAN_FLAGS " -fsanitize=address -fno-omit-frame-pointer -DSANITIZER_BUILD")
set(ASAN_LIBS "asan")
set(GTEST_ENV ${GTEST_ENV} LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/opencl/test/unit_test/lsan_suppressions.txt)
else()
message(STATUS "Address sanitization with clang not yet support")
endif()
endif()
if(USE_TSAN)
if(CMAKE_COMPILER_IS_GNUCC AND USE_ASAN)
message(STATUS "Cannot use thread sanitization with address sanitization in gcc")
else()
set(TSAN_FLAGS " -fsanitize=thread -DSANITIZER_BUILD")
set(TSAN_LIBS "tsan")
endif()
endif()
endif()
# increase the maximum number of sections in .obj files
if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /bigobj")
set(CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL} /bigobj")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()
# setup variables needed for custom configuration type
# generate PDB files even for release build on MSVC
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF")
set(CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL} /Zi")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASEINTERNAL "${CMAKE_SHARED_LINKER_FLAGS_RELEASEINTERNAL} /DEBUG /OPT:REF")
if(NO_PDB)
string(REGEX REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REGEX REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL}")
string(REGEX REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
endif()
elseif(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT NO_PDB)
add_compile_options(-gcodeview)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g")
set(CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL} -g")
endif()
# spectre mitigation
if(NOT NEO_DISABLE_MITIGATIONS)
if(MSVC)
check_cxx_compiler_flag(/Qspectre COMPILER_SUPPORTS_QSPECTRE)
check_cxx_compiler_flag(/d2guardspecload COMPILER_SUPPORTS_D2GUARDSPECLOAD)
if(COMPILER_SUPPORTS_QSPECTRE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qspectre")
elseif(COMPILER_SUPPORTS_D2GUARDSPECLOAD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /d2guardspecload")
else()
message(WARNING "Spectre mitigation is not supported by the compiler")
endif()
else()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
check_cxx_compiler_flag(-mretpoline COMPILER_SUPPORTS_RETPOLINE)
if(COMPILER_SUPPORTS_RETPOLINE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mretpoline")
else()
message(WARNING "Spectre mitigation -mretpoline flag is not supported by the compiler")
endif()
else()
check_cxx_compiler_flag(-mindirect-branch=thunk COMPILER_SUPPORTS_INDIRECT_BRANCH_THUNK)
if(COMPILER_SUPPORTS_INDIRECT_BRANCH_THUNK)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mindirect-branch=thunk")
else()
message(WARNING "Spectre mitigation -mindirect-branch=thunk flag is not supported by the compiler")
endif()
check_cxx_compiler_flag(-mfunction-return=thunk COMPILER_SUPPORTS_FUNCTION_RETURN_THUNK)
if(COMPILER_SUPPORTS_FUNCTION_RETURN_THUNK)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfunction-return=thunk")
else()
message(WARNING "Spectre mitigation -mfunction-return=thunk flag is not supported by the compiler")
endif()
check_cxx_compiler_flag(-mindirect-branch-register COMPILER_SUPPORTS_INDIRECT_BRANCH_REGISTER)
if(COMPILER_SUPPORTS_INDIRECT_BRANCH_REGISTER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mindirect-branch-register")
else()
message(WARNING "Spectre mitigation -mindirect-branch-register flag is not supported by the compiler")
endif()
endif()
endif()
else()
message(WARNING "Spectre mitigation DISABLED")
endif()
if(NOT MSVC)
check_cxx_compiler_flag(-msse4.2 COMPILER_SUPPORTS_SSE42)
check_cxx_compiler_flag(-mavx2 COMPILER_SUPPORTS_AVX2)
check_cxx_compiler_flag(-march=armv8-a+simd COMPILER_SUPPORTS_NEON)
endif()
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
endif()
# intrinsics (_mm_clflushopt and waitpkg) support
if(NOT MSVC)
check_cxx_compiler_flag(-mclflushopt SUPPORTS_CLFLUSHOPT)
check_cxx_compiler_flag(-mwaitpkg SUPPORTS_WAITPKG)
if(SUPPORTS_CLFLUSHOPT)
add_compile_definitions(SUPPORTS_CLFLUSHOPT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mclflushopt")
endif()
if(SUPPORTS_WAITPKG)
add_compile_definitions(SUPPORTS_WAITPKG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwaitpkg")
else()
message(WARNING "-mwaitpkg flag is not supported by the compiler")
endif()
else()
add_compile_definitions(SUPPORTS_CLFLUSHOPT)
add_compile_definitions(SUPPORTS_WAITPKG)
endif()
# Compiler warning flags
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wempty-body")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wignored-qualifiers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wtype-limits")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Winvalid-pch")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
# clang only
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshorten-64-to-32 -Wno-extern-c-compat -Wno-instantiation-after-specialization")
if(NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs -DSANITIZER_BUILD")
endif()
if(NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register") # Added for htons()
endif()
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy")
endif()
else()
# gcc only
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs -Wno-unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wclobbered")
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough=4")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-noexcept-type") # Added for gtest
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=vla")
if(USE_SANITIZE_UB)
check_cxx_compiler_flag(-fsanitize=undefined COMPILER_SUPPORTS_UNDEFINED_BEHAVIOR_SANITIZER)
if(COMPILER_SUPPORTS_UNDEFINED_BEHAVIOR_SANITIZER)
message(STATUS "Enabling undefined behavior sanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fsanitize-recover=vptr -fno-rtti -DSANITIZER_BUILD")
if(NOT SANITIZE_UB_ALLOW_CONTINUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=undefined")
endif()
endif()
endif()
endif()
# Compile code with defenses enabled (settings to be used for production release code)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GS")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /sdl")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NXCompat")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DynamicBase")
if("${NEO_ARCH}" STREQUAL "x86")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /SafeSEH")
endif()
else()
string(FIND ${CMAKE_CXX_FLAGS} "-D_FORTIFY_SOURCE=3" __FORTIFY_SOURCE_3_SET)
if(${__FORTIFY_SOURCE_3_SET} LESS 0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -D_FORTIFY_SOURCE=2")
endif()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security")
else()
# gcc, g++ only
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,-z,noexecstack")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,-z,relro")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,-z,now")
endif()
endif()
endif()
# Project-wide include paths
# Please keep alphabetical order
include_directories(${NEO_BUILD_DIR})
include_directories(${NEO_SOURCE_DIR})
include_directories(${NEO_SHARED_DIRECTORY}/aub_mem_dump/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/built_ins/builtinops${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/command_container/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/command_stream/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/debug_settings/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/kernel/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/gen_common${BRANCH_DIR_SUFFIX})
if(WIN32)
include_directories(${NEO_SHARED_DIRECTORY}/gmm_helper/windows/gmm_memory${BRANCH_DIR_SUFFIX})
else()
include_directories(${NEO_LINUX_KMD_HEADERS_DIR}
${NEO_SHARED_DIRECTORY}/gmm_helper/windows/gmm_memory
)
if("${BRANCH_TYPE}" STREQUAL "")
include_directories(${NEO_SOURCE_DIR}/third_party/uapi/prelim)
endif()
endif()
include_directories(${NEO_SHARED_DIRECTORY}/helpers/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/memory_properties${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/release_helper/definitions${BRANCH_DIR_SUFFIX})
include_directories(${NEO_SHARED_DIRECTORY}/sku_info/definitions${BRANCH_DIR_SUFFIX})
macro(macro_for_each_platform)
string(TOLOWER ${PLATFORM_IT} PLATFORM_IT_LOWER)
foreach(PLATFORM_DIRECTORY
${NEO_SHARED_DIRECTORY}/${CORE_TYPE_LOWER}/${PLATFORM_IT_LOWER}/definitions${BRANCH_DIR_SUFFIX}
${NEO_SHARED_DIRECTORY}/ail/${CORE_TYPE_LOWER}/${PLATFORM_IT_LOWER}/definitions${BRANCH_DIR_SUFFIX}
)
if(EXISTS ${PLATFORM_DIRECTORY})
include_directories(${PLATFORM_DIRECTORY})
endif()
endforeach()
endmacro()
macro(macro_for_each_core_type)
foreach(PLATFORM_DIRECTORY ${NEO_SHARED_DIRECTORY}/${CORE_TYPE_LOWER}/definitions${BRANCH_DIR_SUFFIX} ${NEO_SOURCE_DIR}/opencl/source/${CORE_TYPE_LOWER}/definitions${BRANCH_DIR_SUFFIX})
if(EXISTS ${PLATFORM_DIRECTORY})
include_directories(${PLATFORM_DIRECTORY})
endif()
endforeach()
apply_macro_for_each_platform("SUPPORTED")
endmacro()
apply_macro_for_each_core_type("SUPPORTED")
# Define where to put binaries
set(TargetDir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if(MSVC)
if(NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(TargetDir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
endif()
endif()
add_subdirectory_unique(shared/source/release_helper)
add_subdirectory_unique(${OCLOC_DIRECTORY} ${NEO_BUILD_DIR}/offline_compiler)
target_compile_definitions(ocloc_lib
PRIVATE MOCKABLE_VIRTUAL=
)
include(cmake/ocloc_cmd_prefix.cmake)
if(DONT_CARE_OF_VIRTUALS)
set(NEO_SHARED_RELEASE_LIB_NAME "neo_shared")
set(NEO_SHARED_MOCKABLE_LIB_NAME ${NEO_SHARED_RELEASE_LIB_NAME})
else()
set(NEO_SHARED_RELEASE_LIB_NAME "neo_shared")
if(NOT NEO_SKIP_UNIT_TESTS)
set(NEO_SHARED_MOCKABLE_LIB_NAME "neo_shared_mockable")
endif()
endif()
set(BIKSIM_LIB_NAME "biksim")
set(BUILTINS_SOURCES_LIB_NAME "builtins_sources")
set(BUILTINS_BINARIES_STATELESS_LIB_NAME "builtins_binaries_stateless")
set(BUILTINS_BINARIES_STATELESS_HEAPLESS_LIB_NAME "builtins_binaries_stateless_heapless")
set(BUILTINS_BINARIES_BINDFUL_LIB_NAME "builtins_binaries_bindful")
set(BUILTINS_BINARIES_BINDLESS_LIB_NAME "builtins_binaries_bindless")
set(BUILTINS_SPIRV_LIB_NAME "builtins_spirv")
if(WIN32)
set(NEO_EXTRA_LIBS Ws2_32 winmm)
else()
set(NEO_EXTRA_LIBS dl pthread rt)
endif()
add_subdirectory_unique(shared)
if(NEO_BUILD_WITH_OCL)
add_subdirectory_unique(opencl)
else()