forked from GPUOpen-Drivers/xgl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
501 lines (427 loc) · 21.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
##
#######################################################################################################################
#
# Copyright (c) 2017-2020 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
#######################################################################################################################
cmake_minimum_required(VERSION 3.5)
# This part set before "project(XGL VERSION 1 LANGUAGES C CXX)".
# In a system has both gcc and clang compiler. The cmake output log will be more reasonable.
### Clang build ########################################################################################################
option(XGL_USE_CLANG "Build with clang?" OFF)
if(UNIX)
if(XGL_USE_CLANG)
set(CMAKE_CXX_COMPILER_ID "Clang")
foreach(major RANGE 8 20)
find_program(CLANG_VER clang-${major})
if(CLANG_VER)
set(CLANG_VER ${major})
break()
endif()
endforeach()
find_program(CLANG_C_COMPILER clang)
if (CLANG_C_COMPILER)
set(CMAKE_C_COMPILER ${CLANG_C_COMPILER} CACHE FILEPATH "" FORCE)
else()
find_program(CLANG_C_COMPILER clang-${CLANG_VER})
if (CLANG_C_COMPILER)
set(CMAKE_C_COMPILER ${CLANG_C_COMPILER} CACHE FILEPATH "" FORCE)
else()
message(FATAL_ERROR "clang cannot be found!")
endif()
endif()
find_program(CLANG_CXX_COMPILER clang++)
if (CLANG_CXX_COMPILER)
set(CMAKE_CXX_COMPILER ${CLANG_CXX_COMPILER} CACHE FILEPATH "" FORCE)
else()
find_program(CLANG_CXX_COMPILER clang++-${CLANG_VER})
if (CLANG_CXX_COMPILER)
set(CMAKE_CXX_COMPILER ${CLANG_CXX_COMPILER} CACHE FILEPATH "" FORCE)
else()
message(FATAL_ERROR "clang++ cannot be found!")
endif()
endif()
find_program(CLANG_AR llvm-ar)
if (CLANG_AR)
set(CMAKE_AR ${CLANG_AR} CACHE FILEPATH "" FORCE)
else()
find_program(CLANG_AR llvm-ar-${CLANG_VER})
if (CLANG_AR)
set(CMAKE_AR ${CLANG_AR} CACHE FILEPATH "" FORCE)
else()
message(FATAL_ERROR "llvm-ar cannot be found!")
endif()
endif()
find_program(CLANG_LINKER llvm-link)
if (CLANG_LINKER)
set(CMAKE_LINKER ${CLANG_LINKER} CACHE FILEPATH "" FORCE)
else()
find_program(CLANG_LINKER llvm-link-${CLANG_VER})
if (CLANG_LINKER)
set(CMAKE_LINKER ${CLANG_LINKER} CACHE FILEPATH "" FORCE)
else()
message(FATAL_ERROR "llvm-link cannot be found!")
endif()
endif()
find_program(CLANG_NM llvm-nm)
if (CLANG_NM)
set(CMAKE_NM ${CLANG_NM} CACHE FILEPATH "" FORCE)
else()
find_program(CLANG_NM llvm-nm-${CLANG_VER})
if (CLANG_NM)
set(CMAKE_NM ${CLANG_NM} CACHE FILEPATH "" FORCE)
else()
message(FATAL_ERROR "llvm-nm cannot be found!")
endif()
endif()
find_program(CLANG_OBJDUMP llvm-objdump)
if (CLANG_OBJDUMP)
set(CMAKE_OBJDUMP ${CLANG_OBJDUMP} CACHE FILEPATH "" FORCE)
else()
find_program(CLANG_OBJDUMP llvm-objdump-${CLANG_VER})
if (CLANG_OBJDUMP)
set(CMAKE_OBJDUMP ${CLANG_OBJDUMP} CACHE FILEPATH "" FORCE)
else()
message(FATAL_ERROR "llvm-objdump cannot be found!")
endif()
endif()
find_program(CLANG_RANLIB llvm-ranlib)
if (CLANG_RANLIB)
set(CMAKE_RANLIB ${CLANG_RANLIB} CACHE FILEPATH "" FORCE)
else()
find_program(CLANG_RANLIB llvm-ranlib-${CLANG_VER})
if (CLANG_RANLIB)
set(CMAKE_RANLIB ${CLANG_RANLIB} CACHE FILEPATH "" FORCE)
else()
message(FATAL_ERROR "llvm-ranlib cannot be found!")
endif()
endif()
endif()
endif()
project(XGL VERSION 1 LANGUAGES C CXX)
# Before GCC7, when LTO is enabled, undefined reference error was observed when linking static libraries.
# Use the gcc-ar wrapper instead of ar, this invokes ar with the right plugin arguments
# --plugin /usr/lib/gcc/.../liblto_plugin.so
if(UNIX)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
find_program(GCC_AR gcc-ar)
if (GCC_AR)
set(CMAKE_AR ${GCC_AR})
else()
message(FATAL_ERROR "gcc-ar cannot be found!")
endif()
find_program(GCC_RANLIB gcc-ranlib)
if (GCC_RANLIB)
set(CMAKE_RANLIB ${GCC_RANLIB})
else()
message(FATAL_ERROR "gcc-ranlib cannot be found!")
endif()
endif()
endif()
### Set Default Build Type #############################################################################################
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to release")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE)
endif()
### CMake Includes #####################################################################################################
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/../pal/cmake/Modules)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/icd/imported/pal/cmake/Modules)
set(GLOBAL_ROOT_SRC_DIR ${PROJECT_SOURCE_DIR}/../../ CACHE PATH "" FORCE)
# Generate a CompilationDatabase (compile_commands.json file) for our build
# for intellisense used by VScode, YouCompleteMe, etc
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
include(CMakeDependentOption)
include(AmdCmakeHelper)
include(SetupAmdGlobalRoots)
### Strip the symbols for release build ################################################################################
if(UNIX)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " -s")
endif()
endif()
### Cached Project Options #############################################################################################
option(XGL_ENABLE_LTO "Build with LTO enabled?" ON)
option(ICD_BUILD_LLPC "Build LLPC?" ON)
cmake_dependent_option(ICD_COMPILER_DEFAULT "Default value of compiler" ON "ICD_BUILD_LLPC" OFF)
option(XGL_BUILD_VEGA20 "Build open source vulkan for Vega20?" ON)
option(XGL_BUILD_RAVEN2 "Build open source vulkan for Raven2?" ON)
option(XGL_BUILD_RENOIR "Build open source vulkan for Renoir?" ON)
option(XGL_BUILD_LIT "Build with Lit test?" OFF)
option(XGL_BUILD_GFX10 "Build open source vulkan for GFX10" ON)
cmake_dependent_option(XGL_BUILD_NAVI14 "Build open source vulkan for Navi14" ON "XGL_BUILD_GFX10" OFF)
#if VKI_KHR_SHADER_SUBGROUP_EXTENDED_TYPES
option(VKI_KHR_SHADER_SUBGROUP_EXTENDED_TYPES "Build vulkan with KHR_SHADER_SUBGROUP_EXTENDED_TYPES" OFF)
#endif
#if VKI_EXT_EXTENDED_DYNAMIC_STATE
option(VKI_EXT_EXTENDED_DYNAMIC_STATE "Build vulkan with EXTENDED_DYNAMIC_STATE extention" OFF)
#endif
option(ICD_BUILD_LLPCONLY "Build LLPC Only?" OFF)
if(ICD_BUILD_LLPCONLY)
set(ICD_BUILD_LLPC ON CACHE BOOL "ICD_BUILD_LLPCONLY override." FORCE)
endif()
set(XGL_USE_SANITIZER "" CACHE STRING "Build with sanitizers, e.g. Address;Undefined")
if(XGL_USE_SANITIZER)
set(LLVM_USE_SANITIZER "${XGL_USE_SANITIZER}" CACHE BOOL "LLVM_USE_SANITIZER is overridden." FORCE)
endif()
option(XGL_LLVM_UPSTREAM "Build with upstreamed LLVM?" OFF)
option(XGL_ENABLE_ASSERTIONS "Enable assertions in release builds" OFF)
if(XGL_ENABLE_ASSERTIONS)
set(LLVM_ENABLE_ASSERTIONS "${XGL_ENABLE_ASSERTIONS}" CACHE BOOL "LLVM_ENABLE_ASSERTIONS is overridden." FORCE)
endif()
if(NOT ICD_BUILD_LLPC)
set(XGL_LLVM_UPSTREAM OFF CACHE BOOL "XGL_LLVM_UPSTREAM is overrided to false." FORCE)
endif()
option(ICD_GPUOPEN_DEVMODE_BUILD "Build ${PROJECT_NAME} with GPU Open Developer Mode driver support?" ON)
option(ICD_MEMTRACK "Turn on memory tracking?" ${CMAKE_BUILD_TYPE_DEBUG})
option(BUILD_WAYLAND_SUPPORT "Build XGL with Wayland support" ON)
option(BUILD_XLIB_XRANDR_SUPPORT "Build Xlib with xrandr 1.6 support" OFF)
option(BUILD_DRI3_SUPPORT "Build XGL with Dri3 support" ON)
option(ICD_ANALYSIS_WARNINGS_AS_ERRORS "Warnings as errors?" OFF)
set(VAM_ENABLE_WERROR ${ICD_ANALYSIS_WARNINGS_AS_ERRORS} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(ADDR_ENABLE_WERROR ${ICD_ANALYSIS_WARNINGS_AS_ERRORS} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(METROHASH_ENABLE_WERROR ${ICD_ANALYSIS_WARNINGS_AS_ERRORS} CACHE BOOL "${PROJECT_NAME} override." FORCE)
# Option Overrides #################################################################################
# These are options that override XGL subproject options. As these overrides are managed and force
# set by XGL, mark_as_advanced is used to hide them from the CMake GUI.
# This will become the value of PAL_CLIENT_INTERFACE_MAJOR_VERSION. It describes the version of the PAL interface
# that the ICD supports. PAL uses this value to enable backwards-compatibility for older interface versions. It must
# be updated on each PAL promotion after handling all of the interface changes described in palLib.h.
file(STRINGS icd/make/importdefs PAL_MAJOR_VERSION REGEX "^ICD_PAL_CLIENT_MAJOR_VERSION = [0-9]+")
if(PAL_MAJOR_VERSION STREQUAL "")
message(STATUS "Failed to find ICD_PAL_CLIENT_MAJOR_VERSION")
else()
string(REGEX REPLACE "ICD_PAL_CLIENT_MAJOR_VERSION = " "" PAL_MAJOR_VERSION ${PAL_MAJOR_VERSION})
message(STATUS "Detected ICD_PAL_CLIENT_MAJOR_VERSION is " ${PAL_MAJOR_VERSION})
endif()
set(ICD_PAL_CLIENT_MAJOR_VERSION ${PAL_MAJOR_VERSION})
# Handle MINOR_VERSION in the same way
file(STRINGS icd/make/importdefs PAL_MINOR_VERSION REGEX "^ICD_PAL_CLIENT_MINOR_VERSION = [0-9]+")
if(PAL_MINOR_VERSION STREQUAL "")
message(STATUS "Failed to find ICD_PAL_CLIENT_MINOR_VERSION")
else()
string(REGEX REPLACE "ICD_PAL_CLIENT_MINOR_VERSION = " "" PAL_MINOR_VERSION ${PAL_MINOR_VERSION})
message(STATUS "Detected ICD_PAL_CLIENT_MINOR_VERSION is " ${PAL_MINOR_VERSION})
endif()
set(ICD_PAL_CLIENT_MINOR_VERSION ${PAL_MINOR_VERSION})
# This will become the value of LLPC_CLIENT_INTERFACE_MAJOR_VERSION. It describes the version of the LLPC interface
# that the ICD supports. LLPC uses this value to enable backwards-compatibility for older interface versions. It must
# be updated on each LLPC promotion after handling all of the interface changes described in llpc.h
file(STRINGS icd/make/importdefs LLPC_MAJOR_VERSION REGEX "^ICD_LLPC_CLIENT_MAJOR_VERSION = [0-9]+")
if(LLPC_MAJOR_VERSION STREQUAL "")
message(STATUS "Failed to find ICD_LLPC_CLIENT_MAJOR_VERSION")
else()
string(REGEX REPLACE "ICD_LLPC_CLIENT_MAJOR_VERSION = " "" LLPC_MAJOR_VERSION ${LLPC_MAJOR_VERSION})
message(STATUS "Detected ICD_LLPC_CLIENT_MAJOR_VERSION is " ${LLPC_MAJOR_VERSION})
endif()
set(ICD_LLPC_CLIENT_MAJOR_VERSION ${LLPC_MAJOR_VERSION})
# GPUOPEN
if(ICD_GPUOPEN_DEVMODE_BUILD)
file(STRINGS icd/make/importdefs GPUOPEN_MAJOR_VERSION REGEX "^ICD_GPUOPEN_CLIENT_MAJOR_VERSION = [0-9]+")
if(GPUOPEN_MAJOR_VERSION STREQUAL "")
message(STATUS "Failed to find ICD_GPUOPEN_CLIENT_MAJOR_VERSION")
else()
string(REGEX REPLACE "ICD_GPUOPEN_CLIENT_MAJOR_VERSION = " "" GPUOPEN_MAJOR_VERSION ${GPUOPEN_MAJOR_VERSION})
message(STATUS "Detected ICD_GPUOPEN_CLIENT_MAJOR_VERSION is " ${GPUOPEN_MAJOR_VERSION})
endif()
set(GPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION ${GPUOPEN_MAJOR_VERSION})
endif()
# PAL
if(EXISTS ${PROJECT_SOURCE_DIR}/../pal)
set(XGL_PAL_PATH ${PROJECT_SOURCE_DIR}/../pal CACHE PATH "Specify the path to the PAL project.")
endif()
set(PAL_BUILD_JEMALLOC OFF CACHE BOOL "Force jemalloc off" FORCE)
set(PAL_CLIENT_INTERFACE_MAJOR_VERSION ${ICD_PAL_CLIENT_MAJOR_VERSION} CACHE STRING "${PROJECT_NAME} override." FORCE)
set(PAL_CLIENT_INTERFACE_MINOR_VERSION ${ICD_PAL_CLIENT_MINOR_VERSION} CACHE STRING "${PROJECT_NAME} override." FORCE)
set(PAL_CLIENT "VULKAN" CACHE STRING "${PROJECT_NAME} override." FORCE)
set(PAL_ENABLE_LTO ${XGL_ENABLE_LTO} CACHE BOOL "XGL override to build PAL with LTO support" FORCE)
set(PAL_MEMTRACK ${ICD_MEMTRACK} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_GPUOPEN ${ICD_GPUOPEN_DEVMODE_BUILD} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_RAVEN2 ${XGL_BUILD_RAVEN2} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_RENOIR ${XGL_BUILD_RENOIR} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_VEGA20 ${XGL_BUILD_VEGA20} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_GFX10 ${XGL_BUILD_GFX10} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(PAL_BUILD_NAVI14 ${XGL_BUILD_NAVI14} CACHE BOOL "${PROJECT_NAME} override." FORCE)
# Wayland
if (BUILD_WAYLAND_SUPPORT)
set(PAL_BUILD_WAYLAND ON CACHE BOOL "Build PAL with Wayland support" FORCE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND REQUIRED wayland-client)
endif()
# Dri3
if (BUILD_DRI3_SUPPORT)
set(PAL_BUILD_DRI3 ON CACHE BOOL "PAL build with Dri3 enabled" FORCE)
endif()
# Sanitizers
# Temporary variables
set(ICD_SANITIZER_LINK_FLAGS "")
set(ICD_SANITIZER_COMPILE_FLAGS "")
macro(xgl_append_common_sanitizer_flags)
if(NOT MSVC)
# Append -fno-omit-frame-pointer and turn on debug info to get better stack traces.
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -fno-omit-frame-pointer")
if (NOT CMAKE_BUILD_TYPE_DEBUG)
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -gline-tables-only")
else()
# Use -O1 even in debug mode, otherwise sanitizers slowdown is too large.
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -O1")
endif()
elseif(CLANG_CL)
# Keep frame pointers around.
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " /Oy-")
# Always ask the linker to produce symbols with asan.
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " /Z7")
string(APPEND ICD_SANITIZER_LINK_FLAGS " -debug")
endif()
endmacro()
if(XGL_USE_SANITIZER)
# -pthread is needed sometimes to fix a cmake bug: https://gitlab.kitware.com/cmake/cmake/issues/16609
string(APPEND ICD_SANITIZER_LINK_FLAGS " -pthread")
if(UNIX)
if(XGL_USE_SANITIZER MATCHES "Address")
string(APPEND ICD_SANITIZER_LINK_FLAGS " -shared-libasan")
endif()
if(XGL_USE_SANITIZER STREQUAL "Address")
xgl_append_common_sanitizer_flags()
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -fsanitize=address")
string(APPEND ICD_SANITIZER_LINK_FLAGS " -fsanitize=address")
elseif(XGL_USE_SANITIZER STREQUAL "Undefined")
xgl_append_common_sanitizer_flags()
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -fsanitize=undefined -fno-sanitize=vptr,function \
-fno-sanitize-recover=all")
string(APPEND ICD_SANITIZER_LINK_FLAGS " -fsanitize=undefined")
elseif(XGL_USE_SANITIZER STREQUAL "Thread")
xgl_append_common_sanitizer_flags()
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -fsanitize=thread")
string(APPEND ICD_SANITIZER_LINK_FLAGS " -fsanitize=thread")
elseif(XGL_USE_SANITIZER STREQUAL "Address;Undefined" OR
XGL_USE_SANITIZER STREQUAL "Undefined;Address")
xgl_append_common_sanitizer_flags()
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -fsanitize=address,undefined -fno-sanitize=vptr,function \
-fno-sanitize-recover=all")
string(APPEND ICD_SANITIZER_LINK_FLAGS " -fsanitize=address,undefined")
else()
message(FATAL_ERROR "Unsupported value of XGL_USE_SANITIZER: ${XGL_USE_SANITIZER}")
endif()
elseif(MSVC)
if(XGL_USE_SANITIZER STREQUAL "Address")
xgl_append_common_sanitizer_flags()
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -fsanitize=address")
string(APPEND ICD_SANITIZER_LINK_FLAGS " -fsanitize=address")
else()
message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${XGL_USE_SANITIZER}")
endif()
else()
message(FATAL_ERROR "XGL_USE_SANITIZER is not supported on this platform.")
endif()
if(XGL_USE_SANITIZER MATCHES "(Undefined;)?Address(;Undefined)?")
string(APPEND ICD_SANITIZER_COMPILE_FLAGS " -fsanitize-address-use-after-scope")
endif()
endif()
string(APPEND CMAKE_EXE_LINKER_FLAGS "${ICD_SANITIZER_LINK_FLAGS}")
string(APPEND CMAKE_SHARED_LINKER_FLAGS "${ICD_SANITIZER_LINK_FLAGS}")
string(APPEND CMAKE_C_FLAGS "${ICD_SANITIZER_COMPILE_FLAGS}")
string(APPEND CMAKE_CXX_FLAGS "${ICD_SANITIZER_COMPILE_FLAGS}")
# Assertions
if(XGL_ENABLE_ASSERTIONS)
# MSVC doesn't like _DEBUG on release builds.
if(NOT MSVC)
add_definitions(-D_DEBUG)
endif()
# On non-Debug builds CMake automatically defines NDEBUG, so we explicitly undefine it:
if(NOT CMAKE_BUILD_TYPE_DEBUG)
add_definitions(-UNDEBUG)
# Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
foreach(flags_var_to_scrub
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL)
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " "
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
endforeach()
endif()
endif()
### Generator Dependencies #############################################################################################
find_package(PythonInterp 3)
if(NOT PYTHONINTERP_FOUND)
if(UNIX)
message(FATAL_ERROR "Python 3 is needed to generate some source files.")
endif()
else()
if(UNIX)
if(${PYTHON_VERSION_MINOR} LESS "6")
message(FATAL_ERROR "Python 3.6(CPython) or higher is needed to generate some source files.")
endif()
endif()
endif()
set(PYTHON_CMD ${PYTHON_EXECUTABLE})
find_package(Perl 5)
if(NOT PERL_FOUND)
if(UNIX)
message(FATAL_ERROR "Perl 5 is needed to generate some source files.")
endif()
endif()
set(PERL_CMD ${PERL_EXECUTABLE})
### Add Subdirectories #################################################################################################
### Metrohash ##########################################################
if(EXISTS ${PROJECT_SOURCE_DIR}/../MetroHash)
set(XGL_METROHASH_PATH ${PROJECT_SOURCE_DIR}/../MetroHash CACHE PATH "The path of metrohash.")
else()
set(XGL_METROHASH_PATH ${PROJECT_SOURCE_DIR}/../third_party/metrohash CACHE PATH "The path of metrohash.")
endif()
if(EXISTS ${XGL_METROHASH_PATH} AND NOT TARGET metrohash)
add_subdirectory(${XGL_METROHASH_PATH} ${PROJECT_BINARY_DIR}/metrohash)
set(PAL_METROHASH_PATH ${XGL_METROHASH_PATH} CACHE PATH "${PROJECT_NAME} override." FORCE)
endif()
### cwpack #############################################################
if(EXISTS ${PROJECT_SOURCE_DIR}/../CWPack)
set(XGL_CWPACK_PATH ${PROJECT_SOURCE_DIR}/../CWPack CACHE PATH "The path of cwpack.")
else()
set(XGL_CWPACK_PATH ${PROJECT_SOURCE_DIR}/../third_party/cwpack CACHE PATH "The path of cwpack.")
endif()
if(EXISTS ${XGL_CWPACK_PATH} AND NOT TARGET cwpack)
add_subdirectory(${XGL_CWPACK_PATH} ${PROJECT_BINARY_DIR}/cwpack)
set(PAL_CWPACK_PATH ${XGL_CWPACK_PATH} CACHE PATH "${PROJECT_NAME} override." FORCE)
endif()
### VKGC ###############################################################
set(XGL_ICD_PATH ${PROJECT_SOURCE_DIR}/icd CACHE PATH "The path of xgl, it is read-only.")
if (EXISTS ${XGL_ICD_PATH}/api/compiler/CMakeLists.txt)
set(XGL_VKGC_PATH ${XGL_ICD_PATH}/api/compiler CACHE PATH "Specify the path to the compiler." FORCE)
else()
# On github, the default repo name is llpc instead of compiler
set(XGL_VKGC_PATH ${PROJECT_SOURCE_DIR}/../llpc CACHE PATH "Specify the path to the llpc repository." FORCE)
endif()
set(LLPC_CLIENT_INTERFACE_MAJOR_VERSION ${ICD_LLPC_CLIENT_MAJOR_VERSION} CACHE STRING "${PROJECT_NAME} override." FORCE)
set(LLPC_BUILD_LIT ${XGL_BUILD_LIT} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(LLPC_BUILD_GFX10 ${XGL_BUILD_GFX10} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(LLPC_BUILD_NAVI14 ${XGL_BUILD_NAVI14} CACHE BOOL "${PROJECT_NAME} override." FORCE)
if(ICD_BUILD_LLPC)
set(LLPC_BUILD_RAVEN2 ${XGL_BUILD_RAVEN2} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(LLPC_BUILD_RENOIR ${XGL_BUILD_RENOIR} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(LLPC_BUILD_VEGA20 ${XGL_BUILD_VEGA20} CACHE BOOL "${PROJECT_NAME} override." FORCE)
set(LLPC_ENABLE_WERROR ${ICD_ANALYSIS_WARNINGS_AS_ERRORS} CACHE BOOL "${PROJECT_NAME} override." FORCE)
endif()
add_subdirectory(${XGL_VKGC_PATH} ${CMAKE_BINARY_DIR}/compiler)
if(NOT ICD_BUILD_LLPCONLY)
add_subdirectory(icd)
endif()