blob: 9dd2808423ad79fbbb63fde0b66d2dccf800a46c [file] [log] [blame]
Ben Clayton3c690342020-03-24 22:38:59 +00001# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Antonio Maioranobccfe712020-04-20 17:48:53 -040015cmake_minimum_required(VERSION 3.13)
Corentin Wallez0866b292015-12-09 13:49:40 -050016
Ben Clayton3cc0aea2020-01-08 19:09:25 +000017set(CMAKE_CXX_STANDARD 14)
18
Ben Clayton30b6b592019-08-07 15:04:11 +010019project(SwiftShader C CXX ASM)
Corentin Wallez0866b292015-12-09 13:49:40 -050020
Corentin Wallez0866b292015-12-09 13:49:40 -050021###########################################################
22# Detect system
23###########################################################
24
Nicolas Capens6f422092015-12-23 15:12:45 -050025if(CMAKE_SYSTEM_NAME MATCHES "Linux")
Nicolas Capens1dfcdb02020-03-12 21:12:52 +000026 set(LINUX TRUE)
Stephen Whitee6ab01f2019-04-04 14:31:25 -040027elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
Nicolas Capens1dfcdb02020-03-12 21:12:52 +000028 set(ANDROID TRUE)
Stephen Whitee6ab01f2019-04-04 14:31:25 -040029 set(CMAKE_CXX_FLAGS "-DANDROID_NDK_BUILD")
Corentin Wallez0866b292015-12-09 13:49:40 -050030elseif(WIN32)
31elseif(APPLE)
David 'Digit' Turnerd3717932019-11-19 17:54:00 +010032elseif(FUCHSIA)
33 # NOTE: Building for Fuchsia requires a Fuchsia CMake-based SDK.
34 # See https://fuchsia-review.googlesource.com/c/fuchsia/+/379673
David 'Digit' Turner08090462020-04-17 15:53:21 +020035 find_package(FuchsiaLibraries)
Corentin Wallez0866b292015-12-09 13:49:40 -050036else()
37 message(FATAL_ERROR "Platform is not supported")
38endif()
39
Nicolas Capens30cd7d42017-04-25 15:17:25 -040040if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch")
41 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
42 set(ARCH "aarch64")
43 else()
44 set(ARCH "arm")
45 endif()
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +020046elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "mips*")
47 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
48 set(ARCH "mips64el")
49 else()
50 set(ARCH "mipsel")
51 endif()
Colin Samplesf63a3ab2019-06-13 12:53:09 -040052elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc*")
53 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
54 set(ARCH "ppc64le")
55 else()
56 message(FATAL_ERROR "Architecture is not supported")
57 endif()
Corentin Wallez0866b292015-12-09 13:49:40 -050058else()
Nicolas Capens30cd7d42017-04-25 15:17:25 -040059 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
60 set(ARCH "x86_64")
61 else()
62 set(ARCH "x86")
63 endif()
Corentin Wallez0866b292015-12-09 13:49:40 -050064endif()
65
Nicolas Capens1dfcdb02020-03-12 21:12:52 +000066set(CMAKE_MACOSX_RPATH TRUE)
Nicolas Capens007c6c52017-06-09 11:21:48 -040067
Nicolas Capensd7a21cc2018-09-11 13:09:28 -040068if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (CMAKE_GENERATOR_TOOLSET STREQUAL ""))
69 message(WARNING "Visual Studio generators use the x86 host compiler by "
70 "default, even for 64-bit targets. This can result in linker "
71 "instability and out of memory errors. To use the 64-bit "
72 "host compiler, pass -Thost=x64 on the CMake command line.")
73endif()
74
Ben Clayton4901ffd2019-06-27 10:39:07 +010075# Use CCache if available
76find_program(CCACHE_FOUND ccache)
77if(CCACHE_FOUND)
78 message(STATUS "Using ccache")
79 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
80 set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
Ben Clayton1e8486b2020-01-22 17:01:52 +000081endif()
Ben Clayton4901ffd2019-06-27 10:39:07 +010082
Corentin Wallez0866b292015-12-09 13:49:40 -050083###########################################################
Ben Claytona9af8832019-08-14 13:09:43 +010084# Host libraries
85###########################################################
86
87find_library(X11 X11)
88find_library(XCB xcb)
Nicolas Caramellia681d122020-07-20 23:47:56 +020089if(SWIFTSHADER_BUILD_WSI_WAYLAND)
90 find_library(WAYLAND wayland-client)
91endif(SWIFTSHADER_BUILD_WSI_WAYLAND)
Nicolas Caramelli08596c42020-08-01 07:55:00 +020092if(SWIFTSHADER_BUILD_WSI_DIRECTFB)
93 find_library(DIRECTFB directfb)
94 find_path(DIRECTFB_INCLUDE_DIR directfb/directfb.h)
95endif(SWIFTSHADER_BUILD_WSI_DIRECTFB)
Ben Claytona9af8832019-08-14 13:09:43 +010096
97###########################################################
Nicolas Capens18b8d682017-07-25 15:31:45 -040098# Options
99###########################################################
100
101if(NOT CMAKE_BUILD_TYPE)
102 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The type of build: Debug Release MinSizeRel RelWithDebInfo." FORCE)
Antonio Maiorano31038ea2020-04-15 16:47:00 -0400103 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo)
Nicolas Capens18b8d682017-07-25 15:31:45 -0400104endif()
Nicolas Capens18b8d682017-07-25 15:31:45 -0400105
Ben Clayton5837d872020-01-20 16:23:36 +0000106function (option_if_not_defined name description default)
107 if(NOT DEFINED ${name})
108 option(${name} ${description} ${default})
109 endif()
110endfunction()
Nicolas Capens18b8d682017-07-25 15:31:45 -0400111
Ben Clayton9cc163c2020-01-20 16:26:36 +0000112function (set_if_not_defined name value)
113 if(NOT DEFINED ${name})
114 set(${name} ${value} PARENT_SCOPE)
115 endif()
116endfunction()
117
Nicolas Capens1dfcdb02020-03-12 21:12:52 +0000118option_if_not_defined(SWIFTSHADER_BUILD_EGL "Build the EGL library" TRUE)
119option_if_not_defined(SWIFTSHADER_BUILD_GLESv2 "Build the OpenGL ES 2 library" TRUE)
120option_if_not_defined(SWIFTSHADER_BUILD_GLES_CM "Build the OpenGL ES 1.1 library" TRUE)
121option_if_not_defined(SWIFTSHADER_BUILD_VULKAN "Build the Vulkan library" TRUE)
Nicolas Caramellia681d122020-07-20 23:47:56 +0200122option_if_not_defined(SWIFTSHADER_BUILD_WSI_WAYLAND "Build the Wayland WSI support" FALSE)
Nicolas Caramelli08596c42020-08-01 07:55:00 +0200123option_if_not_defined(SWIFTSHADER_BUILD_WSI_DIRECTFB "Build the DirectFB WSI support" FALSE)
Nicolas Capens13943ba2020-03-17 22:36:24 -0400124option_if_not_defined(SWIFTSHADER_BUILD_PVR "Build the PowerVR examples" TRUE)
125option_if_not_defined(SWIFTSHADER_GET_PVR "Check out the PowerVR submodule" FALSE)
Antonio Maiorano4e397792020-07-27 15:14:52 -0400126option_if_not_defined(SWIFTSHADER_BUILD_ANGLE "Build angle" FALSE)
Nicolas Capens18b8d682017-07-25 15:31:45 -0400127
Nicolas Capens1dfcdb02020-03-12 21:12:52 +0000128option_if_not_defined(SWIFTSHADER_USE_GROUP_SOURCES "Group the source files in a folder tree for Visual Studio" TRUE)
Nicolas Capens18b8d682017-07-25 15:31:45 -0400129
Nicolas Capens45755df2020-03-30 12:42:40 -0400130option_if_not_defined(SWIFTSHADER_BUILD_TESTS "Build unit tests" TRUE)
Nicolas Capens1dfcdb02020-03-12 21:12:52 +0000131option_if_not_defined(SWIFTSHADER_BUILD_BENCHMARKS "Build benchmarks" FALSE)
Ben Clayton5837d872020-01-20 16:23:36 +0000132
Nicolas Capens1dfcdb02020-03-12 21:12:52 +0000133option_if_not_defined(SWIFTSHADER_MSAN "Build with memory sanitizer" FALSE)
134option_if_not_defined(SWIFTSHADER_ASAN "Build with address sanitizer" FALSE)
135option_if_not_defined(SWIFTSHADER_TSAN "Build with thread sanitizer" FALSE)
136option_if_not_defined(SWIFTSHADER_UBSAN "Build with undefined behavior sanitizer" FALSE)
Ben Clayton063fc022020-03-23 13:18:09 +0000137option_if_not_defined(SWIFTSHADER_EMIT_COVERAGE "Emit code coverage information" FALSE)
Nicolas Capens1dfcdb02020-03-12 21:12:52 +0000138option_if_not_defined(SWIFTSHADER_WARNINGS_AS_ERRORS "Treat all warnings as errors" TRUE)
139option_if_not_defined(SWIFTSHADER_DCHECK_ALWAYS_ON "Check validation macros even in release builds" FALSE)
140option_if_not_defined(REACTOR_EMIT_DEBUG_INFO "Emit debug info for JIT functions" FALSE)
141option_if_not_defined(REACTOR_EMIT_PRINT_LOCATION "Emit printing of location info for JIT functions" FALSE)
142option_if_not_defined(REACTOR_ENABLE_PRINT "Enable RR_PRINT macros" FALSE)
143option_if_not_defined(REACTOR_VERIFY_LLVM_IR "Check reactor-generated LLVM IR is valid even in release builds" FALSE)
144option_if_not_defined(SWIFTSHADER_LESS_DEBUG_INFO "Generate less debug info to reduce file size" FALSE)
145option_if_not_defined(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER "Enable Vulkan debugger support" FALSE)
146option_if_not_defined(SWIFTSHADER_ENABLE_ASTC "Enable ASTC compressed textures support" TRUE) # TODO(b/150130101)
Nicolas Capensbf8fd5b2018-06-21 00:42:00 -0400147
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500148set(BUILD_MARL ${SWIFTSHADER_BUILD_VULKAN})
Ben Clayton5e4d55f2019-12-10 19:40:58 +0000149
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500150if(${SWIFTSHADER_BUILD_VULKAN} AND ${SWIFTSHADER_ENABLE_VULKAN_DEBUGGER})
Nicolas Capens1dfcdb02020-03-12 21:12:52 +0000151 set_if_not_defined(SWIFTSHADER_BUILD_CPPDAP TRUE)
Ben Clayton5e4d55f2019-12-10 19:40:58 +0000152else()
Nicolas Capens1dfcdb02020-03-12 21:12:52 +0000153 set_if_not_defined(SWIFTSHADER_BUILD_CPPDAP FALSE)
Ben Clayton5e4d55f2019-12-10 19:40:58 +0000154endif()
Ben Claytone693b622019-09-05 12:48:37 +0100155
Nicolas Capens5f8a16a2019-08-15 10:36:13 -0400156set(DEFAULT_REACTOR_BACKEND "LLVM")
Nicolas Capens3957b7f2018-10-15 12:54:41 -0400157set(REACTOR_BACKEND ${DEFAULT_REACTOR_BACKEND} CACHE STRING "JIT compiler back-end used by Reactor")
Nicolas Capens18b8d682017-07-25 15:31:45 -0400158set_property(CACHE REACTOR_BACKEND PROPERTY STRINGS LLVM Subzero)
159
Antonio Maiorano6a6ae442020-07-20 14:11:48 -0400160set(DEFAULT_SWIFTSHADER_LLVM_VERSION "10.0")
Ben Claytoncafff782020-03-26 11:18:05 +0000161set(SWIFTSHADER_LLVM_VERSION ${DEFAULT_SWIFTSHADER_LLVM_VERSION} CACHE STRING "LLVM version to use")
Antonio Maiorano6a6ae442020-07-20 14:11:48 -0400162set_property(CACHE SWIFTSHADER_LLVM_VERSION PROPERTY STRINGS "10.0")
Ben Claytoncafff782020-03-26 11:18:05 +0000163
Antonio Maiorano062dc182019-12-09 11:52:31 -0500164# If defined, overrides the default optimization level of the current reactor backend.
165# Set to one of the rr::Optimization::Level enum values.
166set(REACTOR_DEFAULT_OPT_LEVEL "Default" CACHE STRING "Reactor default optimization level")
167set_property(CACHE REACTOR_DEFAULT_OPT_LEVEL PROPERTY STRINGS "None" "Less" "Default" "Aggressive")
168
Ben Claytoncbb5a102020-10-03 11:15:47 +0100169if(NOT DEFINED SWIFTSHADER_LOGGING_LEVEL)
170 set(SWIFTSHADER_LOGGING_LEVEL "Info" CACHE STRING "SwiftShader logging level")
171 set_property(CACHE SWIFTSHADER_LOGGING_LEVEL PROPERTY STRINGS "Verbose" "Debug" "Info" "Warn" "Error" "Fatal" "Disabled")
172endif()
173
Nicolas Capens18b8d682017-07-25 15:31:45 -0400174# LLVM disallows calling cmake . from the main LLVM dir, the reason is that
175# it builds header files that could overwrite the orignal ones. Here we
176# want to include LLVM as a subdirectory and even though it wouldn't cause
177# the problem, if cmake . is called from the main dir, the condition that
Erwin Jansend46faeb2018-11-19 16:01:37 -0800178# LLVM checkes, "CMAKE_CURRENT_SOURCE_DIR == CMAKE_CURRENT_BINARY_DIR" will be true. So we
Nicolas Capens18b8d682017-07-25 15:31:45 -0400179# disallow it ourselves too to. In addition if there are remining CMakeFiles
180# and CMakeCache in the directory, cmake .. from a subdirectory will still
181# try to build from the main directory so we instruct users to delete these
182# files when they get the error.
Erwin Jansend46faeb2018-11-19 16:01:37 -0800183if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
Nicolas Capens18b8d682017-07-25 15:31:45 -0400184 message(FATAL_ERROR "In source builds are not allowed by LLVM, please create a build/ directory and build from there. You may have to delete the CMakeCache.txt file and CMakeFiles directory that are next to the CMakeLists.txt.")
185endif()
186
Nicolas Capens1dfcdb02020-03-12 21:12:52 +0000187set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
Nicolas Capens18b8d682017-07-25 15:31:45 -0400188
189###########################################################
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400190# Directories
191###########################################################
192
Antonio Maiorano8772b422020-04-15 15:00:36 -0400193set(SWIFTSHADER_DIR ${CMAKE_CURRENT_SOURCE_DIR})
194set(SOURCE_DIR ${SWIFTSHADER_DIR}/src)
195set(THIRD_PARTY_DIR ${SWIFTSHADER_DIR}/third_party)
196set(TESTS_DIR ${SWIFTSHADER_DIR}/tests)
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400197
198###########################################################
Nicolas Capensfe5861b2018-08-03 16:01:48 -0400199# Initialize submodules
200###########################################################
201
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400202function(InitSubmodule target submodule_dir)
203 if (NOT TARGET ${target})
204 if(NOT EXISTS ${submodule_dir}/.git)
Ben Clayton55890e12020-01-31 14:07:21 +0000205 message(WARNING "
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400206 Target ${target} from submodule ${submodule_dir} missing.
Ben Clayton55890e12020-01-31 14:07:21 +0000207 Running 'git submodule update --init' to download it:
208 ")
Nicolas Capensfe5861b2018-08-03 16:01:48 -0400209
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400210 execute_process(COMMAND git -C ${SWIFTSHADER_DIR} submodule update --init ${submodule_dir})
Ben Clayton55890e12020-01-31 14:07:21 +0000211 endif()
Dan Sinclair6480d4e2019-03-11 10:48:19 -0400212 endif()
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400213endfunction()
214
215if (SWIFTSHADER_BUILD_TESTS)
216 InitSubmodule(gtest ${THIRD_PARTY_DIR}/googletest)
Nicolas Capensfe5861b2018-08-03 16:01:48 -0400217endif()
218
Ben Clayton55890e12020-01-31 14:07:21 +0000219if(SWIFTSHADER_BUILD_BENCHMARKS)
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400220 InitSubmodule(benchmark::benchmark ${THIRD_PARTY_DIR}/benchmark)
Nicolas Capensaca9fb22020-06-10 12:53:31 -0400221 InitSubmodule(glslang ${THIRD_PARTY_DIR}/glslang)
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400222endif()
Ben Clayton55890e12020-01-31 14:07:21 +0000223
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400224if(REACTOR_EMIT_DEBUG_INFO)
225 InitSubmodule(libbacktrace ${THIRD_PARTY_DIR}/libbacktrace/src)
Ben Clayton755467c2019-03-23 11:57:02 +0000226endif()
227
Nicolas Capens13943ba2020-03-17 22:36:24 -0400228if(SWIFTSHADER_GET_PVR)
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400229 InitSubmodule(PVRCore ${THIRD_PARTY_DIR}/PowerVR_Examples)
Nicolas Capens13943ba2020-03-17 22:36:24 -0400230 set(SWIFTSHADER_GET_PVR FALSE CACHE BOOL "Check out the PowerVR submodule" FORCE)
231endif()
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400232if(EXISTS ${THIRD_PARTY_DIR}/PowerVR_Examples/.git)
Nicolas Capens13943ba2020-03-17 22:36:24 -0400233 set(HAVE_PVR_SUBMODULE TRUE)
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500234endif()
235
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400236if(SWIFTSHADER_BUILD_CPPDAP)
237 InitSubmodule(json ${THIRD_PARTY_DIR}/json)
238 InitSubmodule(cppdap ${THIRD_PARTY_DIR}/cppdap)
239endif()
240
Antonio Maiorano4e397792020-07-27 15:14:52 -0400241if(SWIFTSHADER_BUILD_ANGLE)
242 InitSubmodule(angle ${THIRD_PARTY_DIR}/angle/angle)
243endif()
Antonio Maiorano1e2fba32020-04-15 16:02:58 -0400244
Nicolas Capensfe5861b2018-08-03 16:01:48 -0400245###########################################################
Corentin Wallez0866b292015-12-09 13:49:40 -0500246# Convenience macros
247###########################################################
248
249# Recursively calls source_group on the files of the directory
250# so that Visual Studio has the files in a folder tree
251macro(group_all_sources directory)
Antonio Maiorano8772b422020-04-15 15:00:36 -0400252 file(GLOB files RELATIVE ${SWIFTSHADER_DIR}/${directory} ${SWIFTSHADER_DIR}/${directory}/*)
Corentin Wallez0866b292015-12-09 13:49:40 -0500253 foreach(file ${files})
Antonio Maiorano8772b422020-04-15 15:00:36 -0400254 if(IS_DIRECTORY ${SWIFTSHADER_DIR}/${directory}/${file})
Corentin Wallez0866b292015-12-09 13:49:40 -0500255 group_all_sources(${directory}/${file})
256 else()
257 string(REPLACE "/" "\\" groupname ${directory})
Antonio Maiorano8772b422020-04-15 15:00:36 -0400258 source_group(${groupname} FILES ${SWIFTSHADER_DIR}/${directory}/${file})
Corentin Wallez0866b292015-12-09 13:49:40 -0500259 endif()
260 endforeach()
261endmacro()
262
263# Takes target library and a directory where the export map is
264# and add the linker options so that only the API symbols are
265# exported.
Nicolas Capens499bb762018-06-29 13:30:57 -0400266macro(set_shared_library_export_map TARGET DIR)
Corentin Wallez0866b292015-12-09 13:49:40 -0500267 if(MSVC)
Nicolas Capens499bb762018-06-29 13:30:57 -0400268 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " /DEF:\"${DIR}/${TARGET}.def\"")
Ben Clayton8565e772019-06-10 11:58:37 +0100269 elseif(APPLE)
270 # The exported symbols list only exports the API functions and
271 # hides all the others.
272 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS "-exported_symbols_list ${DIR}/${TARGET}.exports")
273 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_DEPENDS "${DIR}/${TARGET}.exports;")
274 # Don't allow undefined symbols, unless it's a Sanitizer build.
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500275 if(NOT SWIFTSHADER_MSAN AND NOT SWIFTSHADER_ASAN AND NOT SWIFTSHADER_TSAN AND NOT SWIFTSHADER_UBSAN)
Ben Clayton8565e772019-06-10 11:58:37 +0100276 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-undefined,error")
277 endif()
David 'Digit' Turnerd3717932019-11-19 17:54:00 +0100278 elseif(LINUX OR FUCHSIA)
David 'Digit' Turner6e445042020-04-17 16:27:56 +0200279 # NOTE: The Fuchsia linker script is needed to export the vk_icdInitializeConnectToServiceCallback
280 # entry point (a private implementation detail betwen the Fuchsia Vulkan loader and the ICD).
281 if ((FUCHSIA) AND ("${TARGET}" STREQUAL "vk_swiftshader"))
282 set(LINKER_VERSION_SCRIPT "fuchsia_vk_swiftshader.lds")
283 else()
284 set(LINKER_VERSION_SCRIPT "${TARGET}.lds")
285 endif()
286
Corentin Wallez0866b292015-12-09 13:49:40 -0500287 # The version script only exports the API functions and
Nicolas Capens499bb762018-06-29 13:30:57 -0400288 # hides all the others.
David 'Digit' Turner6e445042020-04-17 16:27:56 +0200289 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--version-script=${DIR}/${LINKER_VERSION_SCRIPT}")
290 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_DEPENDS "${DIR}/${LINKER_VERSION_SCRIPT};")
Nicolas Capensbf8fd5b2018-06-21 00:42:00 -0400291
Nicolas Capense3621dc2020-02-25 22:45:42 -0500292 # -Bsymbolic binds symbol references to their global definitions within
293 # a shared object, thereby preventing symbol preemption.
James Price126720b2020-03-03 10:20:00 -0500294 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-Bsymbolic")
Nicolas Capens517a57f2018-06-29 13:30:57 -0400295
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100296 if(ARCH STREQUAL "mipsel" OR ARCH STREQUAL "mips64el")
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200297 # MIPS supports sysv hash-style only.
298 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--hash-style=sysv")
David 'Digit' Turnerd3717932019-11-19 17:54:00 +0100299 elseif(LINUX)
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200300 # Both hash-style are needed, because we want both gold and
301 # GNU ld to be able to read our libraries.
302 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--hash-style=both")
303 endif()
Nicolas Capens499bb762018-06-29 13:30:57 -0400304
Ben Clayton063fc022020-03-23 13:18:09 +0000305 if(NOT ${SWIFTSHADER_EMIT_COVERAGE})
306 # Gc sections is used in combination with each functions being
307 # in its own section, to reduce the binary size.
308 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--gc-sections")
309 endif()
Nicolas Capens499bb762018-06-29 13:30:57 -0400310
311 # Don't allow undefined symbols, unless it's a Sanitizer build.
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500312 if(NOT SWIFTSHADER_MSAN AND NOT SWIFTSHADER_ASAN AND NOT SWIFTSHADER_TSAN AND NOT SWIFTSHADER_UBSAN)
Nicolas Capensbf8fd5b2018-06-21 00:42:00 -0400313 set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined")
314 endif()
Corentin Wallez0866b292015-12-09 13:49:40 -0500315 endif()
316endmacro()
317
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500318if(SWIFTSHADER_USE_GROUP_SOURCES)
Corentin Wallez0866b292015-12-09 13:49:40 -0500319 group_all_sources(src)
320endif()
321
322###########################################################
Corentin Wallez0866b292015-12-09 13:49:40 -0500323# Compile flags
324###########################################################
325
Ben Clayton4ceb77d2019-04-24 12:09:59 +0100326# Flags for project code (non 3rd party)
327set(SWIFTSHADER_COMPILE_OPTIONS "")
Ben Clayton063fc022020-03-23 13:18:09 +0000328set(SWIFTSHADER_LINK_FLAGS "")
329set(SWIFTSHADER_LIBS "")
Ben Clayton4ceb77d2019-04-24 12:09:59 +0100330
Nicolas Capens6f422092015-12-23 15:12:45 -0500331macro(set_cpp_flag FLAG)
332 if(${ARGC} GREATER 1)
333 set(CMAKE_CXX_FLAGS_${ARGV1} "${CMAKE_CXX_FLAGS_${ARGV1}} ${FLAG}")
Corentin Wallez0866b292015-12-09 13:49:40 -0500334 else()
Nicolas Capens6f422092015-12-23 15:12:45 -0500335 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
Corentin Wallez0866b292015-12-09 13:49:40 -0500336 endif()
337endmacro()
338
Ben Clayton48c8a182019-05-21 20:00:20 +0100339macro(set_linker_flag FLAG)
340 if(${ARGC} GREATER 1)
Nicolas Capens5d4c9812020-07-02 10:06:25 -0400341 set(CMAKE_EXE_LINKER_FLAGS_${ARGV1} "${CMAKE_EXE_LINKER_FLAGS_${ARGV1}} ${FLAG}")
Ben Clayton48c8a182019-05-21 20:00:20 +0100342 else()
343 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}")
344 endif()
345endmacro()
346
Corentin Wallez0866b292015-12-09 13:49:40 -0500347if(MSVC)
348 set_cpp_flag("/MP")
349 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
Antonio Maiorano5bce1f42019-05-10 16:03:49 -0400350 add_definitions(-D_SCL_SECURE_NO_WARNINGS)
Nicolas Capens4c9f04b2019-01-31 22:09:03 -0500351 add_definitions(-D_SBCS) # Single Byte Character Set (ASCII)
Ben Clayton30b6b592019-08-07 15:04:11 +0100352 add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) # Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8
Antonio Maiorano5bce1f42019-05-10 16:03:49 -0400353
Nicolas Capens5d4c9812020-07-02 10:06:25 -0400354 set_linker_flag("/DEBUG:FASTLINK" DEBUG)
355 set_linker_flag("/DEBUG:FASTLINK" RELWITHDEBINFO)
Nicolas Capensf554c542020-01-09 17:19:35 +0000356
Antonio Maiorano5bce1f42019-05-10 16:03:49 -0400357 # Disable specific warnings
358 # TODO: Not all of these should be disabled, but for now, we want a warning-free msvc build. Remove these one by one
359 # and fix the actual warnings in code.
360 list(APPEND SWIFTSHADER_COMPILE_OPTIONS
361 "/wd4005" # 'identifier' : macro redefinition
362 "/wd4018" # 'expression' : signed/unsigned mismatch
Ben Clayton4d4a1902019-05-15 11:15:42 +0100363 "/wd4065" # switch statement contains 'default' but no 'case' labels
Antonio Maiorano5bce1f42019-05-10 16:03:49 -0400364 "/wd4141" # 'modifier' : used more than once
Antonio Maiorano5bce1f42019-05-10 16:03:49 -0400365 "/wd4244" # 'conversion' conversion from 'type1' to 'type2', possible loss of data
366 "/wd4267" # 'var' : conversion from 'size_t' to 'type', possible loss of data
367 "/wd4291" # 'void X new(size_t,unsigned int,unsigned int)': no matching operator delete found; memory will not be freed if initialization throws an exception
368 "/wd4309" # 'conversion' : truncation of constant value
369 "/wd4624" # 'derived class' : destructor was implicitly defined as deleted because a base class destructor is inaccessible or deleted
370 "/wd4800" # 'type' : forcing value to bool 'true' or 'false' (performance warning)
371 "/wd4838" # conversion from 'type_1' to 'type_2' requires a narrowing conversion
372 "/wd5030" # attribute 'attribute' is not recognized
373 "/wd5038" # data member 'member1' will be initialized after data member 'member2' data member 'member' will be initialized after base class 'base_class'
374 )
375
376 # Treat specific warnings as errors
377 list(APPEND SWIFTSHADER_COMPILE_OPTIONS
378 "/we4018" # 'expression' : signed/unsigned mismatch
Antonio Maiorano23da0732019-05-14 22:32:16 -0400379 "/we4471" # 'enumeration': a forward declaration of an unscoped enumeration must have an underlying type (int assumed)
Antonio Maiorano5bce1f42019-05-10 16:03:49 -0400380 "/we4838" # conversion from 'type_1' to 'type_2' requires a narrowing conversion
381 "/we5038" # data member 'member1' will be initialized after data member 'member2' data member 'member' will be initialized after base class 'base_class'
382 )
Corentin Wallez0866b292015-12-09 13:49:40 -0500383else()
Ben Claytona5f07632020-02-04 11:43:25 +0000384 # Explicitly enable these warnings.
Ben Clayton4ceb77d2019-04-24 12:09:59 +0100385 list(APPEND SWIFTSHADER_COMPILE_OPTIONS
Ben Clayton4ceb77d2019-04-24 12:09:59 +0100386 "-Wall"
Ben Clayton8a983f72019-06-18 17:56:36 +0100387 "-Wreorder"
388 "-Wsign-compare"
389 "-Wmissing-braces"
Ben Clayton4ceb77d2019-04-24 12:09:59 +0100390 )
Corentin Wallez0866b292015-12-09 13:49:40 -0500391
Ben Clayton5e828762019-04-24 19:16:52 +0100392 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Ben Clayton4ceb77d2019-04-24 12:09:59 +0100393 list(APPEND SWIFTSHADER_COMPILE_OPTIONS
Ben Clayton54709882020-04-16 10:40:08 +0100394 "-Wextra"
395 "-Wunreachable-code-loop-increment"
Ben Clayton8a983f72019-06-18 17:56:36 +0100396 "-Wunused-lambda-capture"
397 "-Wstring-conversion"
398 "-Wextra-semi"
399 "-Wignored-qualifiers"
Ben Claytona5f07632020-02-04 11:43:25 +0000400 )
401 endif()
402
Ben Clayton063fc022020-03-23 13:18:09 +0000403 if (SWIFTSHADER_EMIT_COVERAGE)
404 if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
405 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "--coverage")
406 list(APPEND SWIFTSHADER_LIBS "gcov")
407 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
408 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fprofile-instr-generate" "-fcoverage-mapping")
409 list(APPEND SWIFTSHADER_LINK_FLAGS "-fprofile-instr-generate" "-fcoverage-mapping")
410 else()
411 message(FATAL_ERROR "Coverage generation not supported for the ${CMAKE_CXX_COMPILER_ID} toolchain")
412 endif()
413 endif()
414
Ben Claytona5f07632020-02-04 11:43:25 +0000415 # Disable pedanitc warnings
416 if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
417 list(APPEND SWIFTSHADER_COMPILE_OPTIONS
418 "-Wno-ignored-attributes" # ignoring attributes on template argument 'X'
419 "-Wno-attributes" # 'X' attribute ignored
420 "-Wno-strict-aliasing" # dereferencing type-punned pointer will break strict-aliasing rules
421 "-Wno-comment" # multi-line comment
422 )
423 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
424 list(APPEND SWIFTSHADER_COMPILE_OPTIONS
425 "-Wno-init-list-lifetime" # assignment from temporary initializer_list does not extend the lifetime of the underlying array
426 )
427 endif()
428 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
429 list(APPEND SWIFTSHADER_COMPILE_OPTIONS
430 "-Wno-unneeded-internal-declaration" # function 'X' is not needed and will not be emitted
431 "-Wno-unused-private-field" # private field 'offset' is not used - TODO: Consider enabling this once Vulkan is further implemented.
432 "-Wno-comment" # multi-line comment
433 "-Wno-undefined-var-template" # instantiation of variable 'X' required here, but no definition is available
Ben Claytona7bc2b92020-03-26 11:24:49 +0000434 "-Wno-extra-semi" # extra ';' after member function definition
Ben Clayton54709882020-04-16 10:40:08 +0100435 "-Wno-unused-parameter" # unused parameter 'X'
David 'Digit' Turner08090462020-04-17 15:53:21 +0200436 "-Wno-deprecated-copy" # implicit copy constructor for 'X' is deprecated because of user-declared copy assignment operator.
Ben Claytona5f07632020-02-04 11:43:25 +0000437
Nicolas Capens67180a02019-06-17 15:27:03 -0400438 # Silence errors caused by unknown warnings when building with older
439 # versions of Clang. This demands checking that warnings added above
440 # are spelled correctly and work as intended!
441 "-Wno-unknown-warning-option"
Ben Clayton4ceb77d2019-04-24 12:09:59 +0100442 )
Nicolas Capens825d3442018-11-06 23:50:05 -0500443 endif()
444
Corentin Wallez0866b292015-12-09 13:49:40 -0500445 # Remove xor, and, or and friends from the list of keywords, they are used
446 # by Reactor
Ben Clayton4ceb77d2019-04-24 12:09:59 +0100447 list(APPEND SWIFTSHADER_COMPILE_OPTIONS
448 "-fno-operator-names"
449 )
Corentin Wallez0866b292015-12-09 13:49:40 -0500450
Nicolas Capens499bb762018-06-29 13:30:57 -0400451 if(ARCH STREQUAL "x86")
Corentin Wallez0866b292015-12-09 13:49:40 -0500452 set_cpp_flag("-m32")
453 set_cpp_flag("-msse2")
Nicolas Capens0424edc2018-01-03 14:06:30 -0500454 set_cpp_flag("-mfpmath=sse")
455 set_cpp_flag("-march=pentium4")
456 set_cpp_flag("-mtune=generic")
Corentin Wallez0866b292015-12-09 13:49:40 -0500457 endif()
Nicolas Capens499bb762018-06-29 13:30:57 -0400458 if(ARCH STREQUAL "x86_64")
Corentin Wallez0866b292015-12-09 13:49:40 -0500459 set_cpp_flag("-m64")
460 set_cpp_flag("-fPIC")
Nicolas Capens0424edc2018-01-03 14:06:30 -0500461 set_cpp_flag("-march=x86-64")
462 set_cpp_flag("-mtune=generic")
Corentin Wallez0866b292015-12-09 13:49:40 -0500463 endif()
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200464 if(ARCH STREQUAL "mipsel")
Jiaxun Yang55275c32020-02-09 14:52:42 +0800465 set_cpp_flag("-EL")
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200466 set_cpp_flag("-march=mips32r2")
467 set_cpp_flag("-fPIC")
468 set_cpp_flag("-mhard-float")
469 set_cpp_flag("-mfp32")
Jiaxun Yang55275c32020-02-09 14:52:42 +0800470 set_cpp_flag("-mxgot")
Gordana Cmiljanovic082dfec2018-10-19 11:36:15 +0200471 endif()
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100472 if(ARCH STREQUAL "mips64el")
Jiaxun Yang55275c32020-02-09 14:52:42 +0800473 set_cpp_flag("-EL")
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100474 set_cpp_flag("-march=mips64r2")
475 set_cpp_flag("-mabi=64")
476 set_cpp_flag("-fPIC")
Jiaxun Yang55275c32020-02-09 14:52:42 +0800477 set_cpp_flag("-mxgot")
Gordana Cmiljanovic20622c02018-11-05 15:00:11 +0100478 endif()
Nicolas Capens499bb762018-06-29 13:30:57 -0400479
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500480 if(SWIFTSHADER_LESS_DEBUG_INFO)
Paul Thomson09b50792019-10-17 12:55:56 +0100481 # Use -g1 to be able to get stack traces
482 set_cpp_flag("-g -g1" DEBUG)
483 set_cpp_flag("-g -g1" RELWITHDEBINFO)
484 else()
485 # Use -g3 to have even more debug info
486 set_cpp_flag("-g -g3" DEBUG)
487 set_cpp_flag("-g -g3" RELWITHDEBINFO)
488 endif()
489
Ben Clayton09a91e42019-02-05 17:58:38 +0000490 if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
491 # Treated as an unused argument with clang
492 set_cpp_flag("-s" RELEASE)
493 endif()
Corentin Wallez0866b292015-12-09 13:49:40 -0500494
495 # For distribution it is more important to be slim than super optimized
Alexis Hetu2c0546d2017-05-24 11:16:26 -0400496 set_cpp_flag("-Os" RELEASE)
497 set_cpp_flag("-Os" RELWITHDEBINFO)
Corentin Wallez0866b292015-12-09 13:49:40 -0500498
499 set_cpp_flag("-DNDEBUG" RELEASE)
500 set_cpp_flag("-DNDEBUG" RELWITHDEBINFO)
501 set_cpp_flag("-DANGLE_DISABLE_TRACE" RELEASE)
502 set_cpp_flag("-DANGLE_DISABLE_TRACE" RELWITHDEBINFO)
503
504 # Put each variable and function in its own section so that when linking
505 # with -gc-sections unused functions and variables are removed.
506 set_cpp_flag("-ffunction-sections" RELEASE)
507 set_cpp_flag("-fdata-sections" RELEASE)
508 set_cpp_flag("-fomit-frame-pointer" RELEASE)
Nicolas Capensbf8fd5b2018-06-21 00:42:00 -0400509
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500510 if(SWIFTSHADER_MSAN)
Ben Claytondae97922019-05-17 12:09:31 +0100511 set_cpp_flag("-fsanitize=memory")
Ben Clayton48c8a182019-05-21 20:00:20 +0100512 set_linker_flag("-fsanitize=memory")
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500513 elseif(SWIFTSHADER_ASAN)
Ben Claytondae97922019-05-17 12:09:31 +0100514 set_cpp_flag("-fsanitize=address")
Ben Clayton48c8a182019-05-21 20:00:20 +0100515 set_linker_flag("-fsanitize=address")
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500516 elseif(SWIFTSHADER_TSAN)
Ben Claytondae97922019-05-17 12:09:31 +0100517 set_cpp_flag("-fsanitize=thread")
Ben Clayton48c8a182019-05-21 20:00:20 +0100518 set_linker_flag("-fsanitize=thread")
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500519 elseif(SWIFTSHADER_UBSAN)
Ben Claytondae97922019-05-17 12:09:31 +0100520 set_cpp_flag("-fsanitize=undefined")
Ben Clayton48c8a182019-05-21 20:00:20 +0100521 set_linker_flag("-fsanitize=undefined")
Nicolas Capensbf8fd5b2018-06-21 00:42:00 -0400522 endif()
Corentin Wallez0866b292015-12-09 13:49:40 -0500523endif()
524
Antonio Maiorano4b8b0782020-03-23 14:11:01 -0400525if(SWIFTSHADER_DCHECK_ALWAYS_ON)
526 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DDCHECK_ALWAYS_ON")
527endif()
528
Nicolas Capens8c13b2f2020-03-06 01:12:01 -0500529if(SWIFTSHADER_WARNINGS_AS_ERRORS)
530 if(MSVC)
531 set(WARNINGS_AS_ERRORS "/WX") # Treat all warnings as errors
532 else()
533 set(WARNINGS_AS_ERRORS "-Werror") # Treat all warnings as errors
534 endif()
535endif()
536
Antonio Maioranof448d8e2019-04-26 16:19:16 -0400537if(REACTOR_EMIT_PRINT_LOCATION)
Antonio Maiorano415d1812020-02-11 16:22:55 -0500538 # This feature depends on REACTOR_EMIT_DEBUG_INFO and REACTOR_ENABLE_PRINT
Antonio Maioranof448d8e2019-04-26 16:19:16 -0400539 set(REACTOR_EMIT_DEBUG_INFO "On")
Antonio Maiorano415d1812020-02-11 16:22:55 -0500540 set(REACTOR_ENABLE_PRINT "On")
Antonio Maioranof448d8e2019-04-26 16:19:16 -0400541 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_EMIT_PRINT_LOCATION")
542endif()
543
544if(REACTOR_EMIT_DEBUG_INFO)
545 message(WARNING "REACTOR_EMIT_DEBUG_INFO is enabled. This will likely affect performance.")
546 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_DEBUG_INFO")
547endif()
548
Antonio Maiorano415d1812020-02-11 16:22:55 -0500549if(REACTOR_ENABLE_PRINT)
550 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_PRINT")
551endif()
552
Ben Clayton5375f472019-06-24 13:33:11 +0100553if(REACTOR_VERIFY_LLVM_IR)
554 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_LLVM_IR_VERIFICATION")
555endif()
556
Antonio Maiorano062dc182019-12-09 11:52:31 -0500557if(REACTOR_DEFAULT_OPT_LEVEL)
558 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DREACTOR_DEFAULT_OPT_LEVEL=${REACTOR_DEFAULT_OPT_LEVEL}")
559endif()
560
Ben Claytoncbb5a102020-10-03 11:15:47 +0100561if(DEFINED SWIFTSHADER_LOGGING_LEVEL)
562 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DSWIFTSHADER_LOGGING_LEVEL=${SWIFTSHADER_LOGGING_LEVEL}")
563endif()
564
Nicolas Capensbf8fd5b2018-06-21 00:42:00 -0400565if(WIN32)
Corentin Wallez0866b292015-12-09 13:49:40 -0500566 add_definitions(-DWINVER=0x501 -DNOMINMAX -DSTRICT)
Nicolas Capens6f422092015-12-23 15:12:45 -0500567 set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib")
Corentin Wallez0866b292015-12-09 13:49:40 -0500568endif()
569
Antonio Maiorano61022762020-03-30 11:11:16 -0400570set(USE_EXCEPTIONS
571 ${REACTOR_EMIT_DEBUG_INFO} # boost::stacktrace uses exceptions
572)
573if(NOT MSVC)
574 if (${USE_EXCEPTIONS})
575 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fexceptions")
576 else()
577 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fno-exceptions")
578 endif()
579endif()
Antonio Maiorano9418b512020-04-08 23:18:13 -0400580unset(USE_EXCEPTIONS)
Antonio Maiorano61022762020-03-30 11:11:16 -0400581
Corentin Wallez0866b292015-12-09 13:49:40 -0500582###########################################################
Antonio Maioranofa8f48d2020-03-30 16:41:48 -0400583# libbacktrace and boost
584###########################################################
585if(REACTOR_EMIT_DEBUG_INFO)
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400586 add_subdirectory(${THIRD_PARTY_DIR}/libbacktrace EXCLUDE_FROM_ALL)
587 add_subdirectory(${THIRD_PARTY_DIR}/boost EXCLUDE_FROM_ALL)
Antonio Maioranofa8f48d2020-03-30 16:41:48 -0400588endif()
589
590###########################################################
Corentin Wallez0866b292015-12-09 13:49:40 -0500591# LLVM
592###########################################################
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400593add_subdirectory(${THIRD_PARTY_DIR}/llvm-${SWIFTSHADER_LLVM_VERSION} EXCLUDE_FROM_ALL)
Antonio Maiorano0f14b7a2020-09-11 10:02:16 -0400594set_target_properties(llvm PROPERTIES FOLDER "third_party")
Ben Clayton8f71f732019-02-01 09:38:45 +0000595
Antonio Maiorano4bde1c32020-03-27 15:01:53 -0400596###########################################################
597# Subzero
598###########################################################
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400599add_subdirectory(${THIRD_PARTY_DIR}/llvm-subzero EXCLUDE_FROM_ALL)
600add_subdirectory(${THIRD_PARTY_DIR}/subzero EXCLUDE_FROM_ALL)
Antonio Maiorano0f14b7a2020-09-11 10:02:16 -0400601set_target_properties(llvm-subzero PROPERTIES FOLDER "third_party")
602set_target_properties(subzero PROPERTIES FOLDER "third_party")
Antonio Maiorano8bce0672020-02-28 13:13:45 -0500603
604###########################################################
605# marl
606###########################################################
607if(BUILD_MARL)
608 set(MARL_THIRD_PARTY_DIR ${THIRD_PARTY_DIR})
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400609 add_subdirectory(${THIRD_PARTY_DIR}/marl)
Antonio Maiorano0f14b7a2020-09-11 10:02:16 -0400610 set_target_properties(marl PROPERTIES FOLDER "third_party")
Antonio Maiorano8bce0672020-02-28 13:13:45 -0500611endif()
612
Ben Clayton377573c2020-04-03 20:36:40 +0100613if(MARL_THREAD_SAFETY_ANALYSIS_SUPPORTED)
614 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-Wthread-safety")
615endif()
616
Antonio Maiorano8bce0672020-02-28 13:13:45 -0500617###########################################################
618# cppdap
619###########################################################
620if(SWIFTSHADER_BUILD_CPPDAP)
621 set(CPPDAP_THIRD_PARTY_DIR ${THIRD_PARTY_DIR})
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400622 add_subdirectory(${THIRD_PARTY_DIR}/cppdap)
Antonio Maiorano8bce0672020-02-28 13:13:45 -0500623endif()
624
Antonio Maioranob02a7082020-03-30 21:55:20 -0400625###########################################################
626# astc-encoder
627###########################################################
628if(SWIFTSHADER_ENABLE_ASTC)
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400629 add_subdirectory(${THIRD_PARTY_DIR}/astc-encoder)
Antonio Maiorano0f14b7a2020-09-11 10:02:16 -0400630 set_target_properties(astc-encoder PROPERTIES FOLDER "third_party")
Antonio Maioranob02a7082020-03-30 21:55:20 -0400631endif()
Nicolas Capens19291ef2017-01-09 13:35:14 -0500632
Nicolas Capensf53adbd2017-01-06 12:47:46 -0500633###########################################################
Antonio Maiorano8f02f582020-03-31 11:01:43 -0400634# gtest and gmock
635###########################################################
636if(SWIFTSHADER_BUILD_TESTS)
637 # For Win32, force gtest to match our CRT (shared)
638 set(gtest_force_shared_crt TRUE CACHE BOOL "" FORCE)
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400639 add_subdirectory(${THIRD_PARTY_DIR}/googletest EXCLUDE_FROM_ALL)
Antonio Maiorano8f02f582020-03-31 11:01:43 -0400640 # gtest finds python, which picks python 2 first, if present.
641 # We need to undo this so that SPIR-V can later find python3.
642 unset(PYTHON_EXECUTABLE CACHE)
Antonio Maiorano0f14b7a2020-09-11 10:02:16 -0400643 set_target_properties(gmock PROPERTIES FOLDER "third_party")
644 set_target_properties(gmock_main PROPERTIES FOLDER "third_party")
645 set_target_properties(gtest PROPERTIES FOLDER "third_party")
646 set_target_properties(gtest_main PROPERTIES FOLDER "third_party")
Antonio Maiorano8f02f582020-03-31 11:01:43 -0400647endif()
648
649###########################################################
Corentin Wallez0866b292015-12-09 13:49:40 -0500650# File Lists
651###########################################################
652
Corentin Wallez0866b292015-12-09 13:49:40 -0500653###########################################################
654# Append OS specific files to lists
655###########################################################
656
657if(WIN32)
Corentin Wallez0866b292015-12-09 13:49:40 -0500658 set(OS_LIBS odbc32 odbccp32 WS2_32 dxguid)
659elseif(LINUX)
Nicolas Capens681d97b2016-05-17 16:02:32 -0400660 set(OS_LIBS dl pthread)
Nicolas Caramellia681d122020-07-20 23:47:56 +0200661 if(SWIFTSHADER_BUILD_WSI_WAYLAND)
662 list(APPEND OS_LIBS "${WAYLAND}")
663 endif(SWIFTSHADER_BUILD_WSI_WAYLAND)
Nicolas Caramelli08596c42020-08-01 07:55:00 +0200664 if(SWIFTSHADER_BUILD_WSI_DIRECTFB)
665 list(APPEND OS_LIBS "${DIRECTFB}")
666 include_directories(${DIRECTFB_INCLUDE_DIR}/directfb)
667 endif(SWIFTSHADER_BUILD_WSI_DIRECTFB)
David 'Digit' Turnerd3717932019-11-19 17:54:00 +0100668elseif(FUCHSIA)
669 set(OS_LIBS zircon)
Corentin Wallezcd0a4572015-12-10 15:59:28 -0500670elseif(APPLE)
671 find_library(COCOA_FRAMEWORK Cocoa)
672 find_library(QUARTZ_FRAMEWORK Quartz)
Alexis Hetud23cf632018-04-10 10:48:42 -0400673 find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
674 find_library(IOSURFACE_FRAMEWORK IOSurface)
Corentin Wallezcb586622020-03-27 17:38:29 +0100675 find_library(METAL_FRAMEWORK Metal)
676 set(OS_LIBS "${COCOA_FRAMEWORK}" "${QUARTZ_FRAMEWORK}" "${CORE_FOUNDATION_FRAMEWORK}" "${IOSURFACE_FRAMEWORK}" "${METAL_FRAMEWORK}")
Corentin Wallez0866b292015-12-09 13:49:40 -0500677endif()
678
679###########################################################
Nicolas Capens5a105bc2015-12-22 22:04:28 -0500680# SwiftShader Targets
Corentin Wallez0866b292015-12-09 13:49:40 -0500681###########################################################
682
Antonio Maioranofa8f48d2020-03-30 16:41:48 -0400683add_subdirectory(src/Reactor) # Add ReactorSubzero and ReactorLLVM targets
Nicolas Capense329f012020-03-13 14:54:21 +0000684
Ben Claytonb99bc1f2019-04-15 13:56:08 -0400685if(${REACTOR_BACKEND} STREQUAL "LLVM")
Nicolas Capensf53adbd2017-01-06 12:47:46 -0500686 set(Reactor ReactorLLVM)
687elseif(${REACTOR_BACKEND} STREQUAL "Subzero")
688 set(Reactor ReactorSubzero)
689else()
690 message(FATAL_ERROR "REACTOR_BACKEND must be 'LLVM' or 'Subzero'")
691endif()
Corentin Wallez0866b292015-12-09 13:49:40 -0500692
Antonio Maiorano4ce6a882020-04-06 16:16:21 -0400693add_subdirectory(src/Common) # Add gl_common target
694add_subdirectory(src/Main) # Add gl_main target
695add_subdirectory(src/Shader) # Add gl_shader target
696add_subdirectory(src/Renderer) # Add gl_renderer target
697
698# Combine all gl_* targets into an interface target
699# along with other dependencies
700add_library(gl_swiftshader_core INTERFACE)
701target_link_libraries(gl_swiftshader_core INTERFACE
702 # Transitively depends on shader, main, core, Reactor,
703 # OS_LIBS and SWIFTSHADER_LIBS
704 gl_renderer
705)
706
Antonio Maioranoa71aff22020-04-07 10:09:41 -0400707add_subdirectory(src/OpenGL/common EXCLUDE_FROM_ALL) # Add libGLESCommon target
708add_subdirectory(src/OpenGL/compiler EXCLUDE_FROM_ALL) # Add GLCompiler target
Nicolas Capens6f422092015-12-23 15:12:45 -0500709
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500710if(SWIFTSHADER_BUILD_EGL)
Antonio Maioranoa71aff22020-04-07 10:09:41 -0400711 add_subdirectory(src/OpenGL/libEGL) # Add libEGL target
Corentin Wallez0866b292015-12-09 13:49:40 -0500712endif()
713
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500714if(SWIFTSHADER_BUILD_GLESv2)
Antonio Maioranoa71aff22020-04-07 10:09:41 -0400715 add_subdirectory(src/OpenGL/libGLESv2) # Add libGLESv2 target
Corentin Wallez0866b292015-12-09 13:49:40 -0500716endif()
717
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500718if(SWIFTSHADER_BUILD_GLES_CM)
Antonio Maioranoa71aff22020-04-07 10:09:41 -0400719 add_subdirectory(src/OpenGL/libGLES_CM) # Add libGLES_CM target
Ben Clayton1e8486b2020-01-22 17:01:52 +0000720endif(SWIFTSHADER_BUILD_GLES_CM)
Corentin Wallez0866b292015-12-09 13:49:40 -0500721
Sean Risserf6d3cbb2020-01-08 14:44:53 -0500722if(SWIFTSHADER_BUILD_VULKAN)
Dan Sinclair6480d4e2019-03-11 10:48:19 -0400723 if (NOT TARGET SPIRV-Tools)
724 # This variable is also used by SPIRV-Tools to locate SPIRV-Headers
Ben Claytonafb4ebd2019-12-02 19:33:17 +0000725 set(SPIRV-Headers_SOURCE_DIR "${THIRD_PARTY_DIR}/SPIRV-Headers")
Antonio Maiorano8f02f582020-03-31 11:01:43 -0400726 set(SPIRV_SKIP_TESTS TRUE CACHE BOOL "" FORCE)
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400727 add_subdirectory(${THIRD_PARTY_DIR}/SPIRV-Tools) # Add SPIRV-Tools target
Ben Clayton1e8486b2020-01-22 17:01:52 +0000728 endif()
Nicolas Capens4c9f04b2019-01-31 22:09:03 -0500729
Antonio Maiorano9418b512020-04-08 23:18:13 -0400730 # Add a vk_base interface library for shared vulkan build options.
731 # TODO: Create src/Base and make this a lib target, and move stuff from
732 # src/Vulkan into it that is needed by vk_pipeline, vk_device, and vk_wsi.
733 add_library(vk_base INTERFACE)
Ben Clayton4cdbb542020-04-14 22:51:50 +0100734
Antonio Maiorano9418b512020-04-08 23:18:13 -0400735 if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
736 target_compile_definitions(vk_base INTERFACE "ENABLE_VK_DEBUGGER")
David 'Digit' Turnerd3717932019-11-19 17:54:00 +0100737 endif()
Antonio Maiorano9418b512020-04-08 23:18:13 -0400738
Nicolas Capensd3545372019-08-09 13:59:18 -0400739 if(WIN32)
Antonio Maiorano9418b512020-04-08 23:18:13 -0400740 target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_WIN32_KHR")
Nicolas Capensd3545372019-08-09 13:59:18 -0400741 elseif(LINUX)
Ben Claytona9af8832019-08-14 13:09:43 +0100742 if(X11)
Antonio Maiorano9418b512020-04-08 23:18:13 -0400743 target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_XLIB_KHR")
Ben Clayton1e8486b2020-01-22 17:01:52 +0000744 endif()
Ben Claytona9af8832019-08-14 13:09:43 +0100745 if(XCB)
Antonio Maiorano9418b512020-04-08 23:18:13 -0400746 target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_XCB_KHR")
Ben Clayton1e8486b2020-01-22 17:01:52 +0000747 endif()
Nicolas Caramellia681d122020-07-20 23:47:56 +0200748 if(SWIFTSHADER_BUILD_WSI_WAYLAND)
749 if(WAYLAND)
750 target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_WAYLAND_KHR")
751 endif()
752 endif(SWIFTSHADER_BUILD_WSI_WAYLAND)
Nicolas Caramelli08596c42020-08-01 07:55:00 +0200753 if(SWIFTSHADER_BUILD_WSI_DIRECTFB)
754 if(DIRECTFB AND DIRECTFB_INCLUDE_DIR)
755 target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_DIRECTFB_EXT")
756 endif()
757 endif(SWIFTSHADER_BUILD_WSI_DIRECTFB)
Nicolas Capensd3545372019-08-09 13:59:18 -0400758 elseif(APPLE)
Antonio Maiorano9418b512020-04-08 23:18:13 -0400759 target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_MACOS_MVK")
David 'Digit' Turnerd3717932019-11-19 17:54:00 +0100760 elseif(FUCHSIA)
Antonio Maiorano9418b512020-04-08 23:18:13 -0400761 target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_FUCHSIA")
Nicolas Capens29a98092019-04-03 14:35:10 -0400762 else()
763 message(FATAL_ERROR "Platform does not support Vulkan yet")
Nicolas Capensd3545372019-08-09 13:59:18 -0400764 endif()
765
Antonio Maiorano9418b512020-04-08 23:18:13 -0400766 add_subdirectory(src/System) # Add vk_system target
767 add_subdirectory(src/Pipeline) # Add vk_pipeline target
768 add_subdirectory(src/WSI) # Add vk_wsi target
769 add_subdirectory(src/Device) # Add vk_device target
770 add_subdirectory(src/Vulkan) # Add vk_swiftshader target
Ben Claytonac736122020-03-24 17:48:31 +0000771
Ben Clayton6ce626b2020-05-05 12:39:23 +0100772 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND # turbo-cov is only useful for clang coverage info
Ben Clayton6ce626b2020-05-05 12:39:23 +0100773 SWIFTSHADER_EMIT_COVERAGE)
Antonio Maiorano2430d662020-04-14 17:04:36 -0400774 add_subdirectory(${TESTS_DIR}/regres/cov/turbo-cov)
Ben Claytonac736122020-03-24 17:48:31 +0000775 endif()
776
Nicolas Capens29a98092019-04-03 14:35:10 -0400777endif()
Chris Forbes3d27f2e2018-09-26 09:24:39 -0700778
Antonio Maiorano4e397792020-07-27 15:14:52 -0400779if(SWIFTSHADER_BUILD_ANGLE)
780 add_subdirectory(${THIRD_PARTY_DIR}/angle)
781
782 # Make angle depend on vk_swiftshader so we can test SWANGLE
783 if (TARGET vk_swiftshader)
784 add_dependencies(angle vk_swiftshader)
785 endif()
786endif()
787
788
Corentin Wallez0866b292015-12-09 13:49:40 -0500789###########################################################
Nicolas Capens29a98092019-04-03 14:35:10 -0400790# Sample programs and tests
Corentin Wallez0866b292015-12-09 13:49:40 -0500791###########################################################
792
Antonio Maiorano79248ab2020-07-23 11:24:33 -0400793# TODO(b/161976310): Add support for building PowerVR on MacOS
794if(APPLE AND HAVE_PVR_SUBMODULE AND SWIFTSHADER_BUILD_PVR)
795 message(WARNING "Building PowerVR examples for SwiftShader is not yet supported on Apple platforms.")
796 set(SWIFTSHADER_BUILD_PVR FALSE)
797endif()
798
Nicolas Capens13943ba2020-03-17 22:36:24 -0400799if(HAVE_PVR_SUBMODULE AND SWIFTSHADER_BUILD_PVR)
Nicolas Capens51b28002020-01-30 16:41:00 -0500800 if(UNIX AND NOT APPLE)
801 set(PVR_WINDOW_SYSTEM XCB)
Nicolas Capens7e857092020-03-06 13:21:10 -0500802
803 # Set the RPATH of the next defined build targets to $ORIGIN,
804 # allowing them to load shared libraries from the execution directory.
805 set(CMAKE_BUILD_RPATH "$ORIGIN")
Nicolas Capens51b28002020-01-30 16:41:00 -0500806 endif()
807
Nicolas Capens13943ba2020-03-17 22:36:24 -0400808 set(PVR_BUILD_EXAMPLES TRUE CACHE BOOL "Build the PowerVR SDK Examples" FORCE)
Antonio Maioranoda4315d2020-04-15 13:49:56 -0400809 add_subdirectory(${THIRD_PARTY_DIR}/PowerVR_Examples)
Nicolas Capens51b28002020-01-30 16:41:00 -0500810
Nicolas Capens51b28002020-01-30 16:41:00 -0500811 # Samples known to work well
812 set(PVR_VULKAN_TARGET_GOOD
813 VulkanBumpmap
Nicolas Capens3702e012020-03-30 09:08:47 -0400814 VulkanExampleUI
815 VulkanGaussianBlur
Nicolas Capens51b28002020-01-30 16:41:00 -0500816 VulkanGlass
817 VulkanGnomeHorde
818 VulkanHelloAPI
819 VulkanImageBasedLighting
Nicolas Capens3702e012020-03-30 09:08:47 -0400820 VulkanIntroducingPVRUtils
Nicolas Capens51b28002020-01-30 16:41:00 -0500821 VulkanMultiSampling
Nicolas Capens3702e012020-03-30 09:08:47 -0400822 VulkanNavigation2D
823 VulkanParticleSystem
Nicolas Capens51b28002020-01-30 16:41:00 -0500824 VulkanSkinning
825 )
826
Nicolas Capens3702e012020-03-30 09:08:47 -0400827 set(PVR_GLES_TARGET_GOOD
828 OpenGLESHelloAPI
829 OpenGLESIntroducingPVRUtils
830 OpenGLESNavigation2D
831 )
832
Nicolas Capens51b28002020-01-30 16:41:00 -0500833 set(PVR_VULKAN_TARGET_OTHER
834 VulkanDeferredShading
835 VulkanDeferredShadingPFX
Nicolas Capens51b28002020-01-30 16:41:00 -0500836 VulkanGameOfLife
Nicolas Capens51b28002020-01-30 16:41:00 -0500837 VulkanIBLMapsGenerator
838 VulkanIMGTextureFilterCubic
839 VulkanIntroducingPVRShell
Nicolas Capens51b28002020-01-30 16:41:00 -0500840 VulkanIntroducingPVRVk
841 VulkanIntroducingUIRenderer
842 VulkanMultithreading
Nicolas Capens51b28002020-01-30 16:41:00 -0500843 VulkanNavigation3D
Nicolas Capens51b28002020-01-30 16:41:00 -0500844 VulkanPostProcessing
845 VulkanPVRScopeExample
846 VulkanPVRScopeRemote
847 )
848
Nicolas Capens3702e012020-03-30 09:08:47 -0400849 set(PVR_GLES_TARGET_OTHER
850 OpenGLESDeferredShading
851 OpenGLESGaussianBlur
852 OpenGLESImageBasedLighting
853 OpenGLESIMGFramebufferDownsample
854 OpenGLESIMGTextureFilterCubic
855 OpenGLESIntroducingPVRCamera
856 OpenGLESIntroducingPVRShell
857 OpenGLESIntroducingUIRenderer
858 OpenGLESMultiviewVR
859 OpenGLESNavigation3D
860 OpenGLESOpenCLExample
861 OpenGLESParticleSystem
862 OpenGLESPostProcessing
863 OpenGLESPVRScopeExample
864 OpenGLESPVRScopeRemote
865 OpenGLESSkinning
866 )
867
Nicolas Capens51b28002020-01-30 16:41:00 -0500868 set(PVR_TARGET_OTHER
869 glslang
870 glslangValidator
871 glslang-default-resource-limits
872 OGLCompiler
873 OSDependent
874 OpenCLMatrixMultiplication
Nicolas Capens51b28002020-01-30 16:41:00 -0500875 pugixml
876 PVRAssets
877 PVRCamera
878 PVRCore
879 PVRPfx
880 PVRShell
881 PVRUtilsGles
882 PVRUtilsVk
883 PVRVk
884 SPIRV
885 spirv-remap
886 SPVRemapper
887 uninstall
888 )
889
890 set(PVR_VULKAN_TARGET
891 ${PVR_VULKAN_TARGET_GOOD}
892 ${PVR_VULKAN_TARGET_OTHER}
893 )
894
Nicolas Capens3702e012020-03-30 09:08:47 -0400895 set(PVR_GLES_TARGET
896 ${PVR_GLES_TARGET_GOOD}
897 ${PVR_GLES_TARGET_OTHER}
898 )
899
Nicolas Capens51b28002020-01-30 16:41:00 -0500900 foreach(pvr_target ${PVR_VULKAN_TARGET})
901 add_dependencies(${pvr_target} vk_swiftshader)
902 endforeach()
903
Nicolas Capens3702e012020-03-30 09:08:47 -0400904 foreach(pvr_target ${PVR_GLES_TARGET})
905 add_dependencies(${pvr_target} libGLESv2)
906 add_dependencies(${pvr_target} libEGL)
907 endforeach()
908
909 foreach(pvr_target ${PVR_VULKAN_TARGET_GOOD} ${PVR_GLES_TARGET_GOOD})
Nicolas Capens51b28002020-01-30 16:41:00 -0500910 set_target_properties(${pvr_target} PROPERTIES FOLDER Samples)
911 endforeach()
912
Nicolas Capens3702e012020-03-30 09:08:47 -0400913 foreach(pvr_target ${PVR_TARGET_OTHER} ${PVR_VULKAN_TARGET_OTHER} ${PVR_GLES_TARGET_OTHER})
Nicolas Capens51b28002020-01-30 16:41:00 -0500914 set_target_properties(${pvr_target} PROPERTIES FOLDER Samples/PowerVR-Build)
915 endforeach()
Antonio Maiorano4e397792020-07-27 15:14:52 -0400916
917 # Make angle target depend on PowerVR GL examples
918 if (TARGET angle)
919 foreach(pvr_target ${PVR_GLES_TARGET})
920 add_dependencies(angle ${pvr_target})
921 endforeach()
922 endif()
Corentin Wallezcb586622020-03-27 17:38:29 +0100923endif()
Nicolas Capensf324fe52020-06-05 16:10:07 -0400924
925if(SWIFTSHADER_BUILD_TESTS)
926 add_subdirectory(${TESTS_DIR}/ReactorUnitTests) # Add ReactorUnitTests target
927 add_subdirectory(${TESTS_DIR}/GLESUnitTests) # Add gles-unittests target
928 add_subdirectory(${TESTS_DIR}/MathUnitTests) # Add math-unittests target
929 add_subdirectory(${TESTS_DIR}/SystemUnitTests) # Add system-unittests target
930endif()
931
932if(SWIFTSHADER_BUILD_BENCHMARKS)
933 if (NOT TARGET benchmark::benchmark)
934 set(BENCHMARK_ENABLE_TESTING FALSE CACHE BOOL FALSE FORCE)
935 add_subdirectory(${THIRD_PARTY_DIR}/benchmark)
Antonio Maiorano0f14b7a2020-09-11 10:02:16 -0400936 set_target_properties(benchmark PROPERTIES FOLDER "third_party")
937 set_target_properties(benchmark_main PROPERTIES FOLDER "third_party")
Nicolas Capensf324fe52020-06-05 16:10:07 -0400938 endif()
939
Nicolas Capensaca9fb22020-06-10 12:53:31 -0400940 if (NOT TARGET glslang)
941 add_subdirectory(${THIRD_PARTY_DIR}/glslang)
942 endif()
943
Nicolas Capensf324fe52020-06-05 16:10:07 -0400944 add_subdirectory(${TESTS_DIR}/ReactorBenchmarks) # Add ReactorBenchmarks target
945 add_subdirectory(${TESTS_DIR}/SystemBenchmarks) # Add system-benchmarks target
946 add_subdirectory(${TESTS_DIR}/VulkanBenchmarks) # Add VulkanBenchmarks target
947endif()
948
949if(SWIFTSHADER_BUILD_TESTS AND SWIFTSHADER_BUILD_VULKAN)
950 add_subdirectory(${TESTS_DIR}/VulkanUnitTests) # Add VulkanUnitTests target
951endif()