Ben Clayton | 3c69034 | 2020-03-24 22:38:59 +0000 | [diff] [blame] | 1 | # 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 Maiorano | bccfe71 | 2020-04-20 17:48:53 -0400 | [diff] [blame] | 15 | cmake_minimum_required(VERSION 3.13) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 16 | |
Ben Clayton | 30b6b59 | 2019-08-07 15:04:11 +0100 | [diff] [blame] | 17 | project(SwiftShader C CXX ASM) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 18 | |
Nicolas Capens | b3e5c44 | 2021-01-20 06:16:24 +0000 | [diff] [blame] | 19 | set(CMAKE_CXX_STANDARD 17) |
Antonio Maiorano | 10ff433 | 2020-12-04 11:33:34 -0500 | [diff] [blame] | 20 | set(CXX_STANDARD_REQUIRED ON) |
| 21 | # MSVC doesn't define __cplusplus by default |
| 22 | if(MSVC) |
| 23 | string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus") |
| 24 | endif() |
| 25 | |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 26 | ########################################################### |
| 27 | # Detect system |
| 28 | ########################################################### |
| 29 | |
Nicolas Capens | 6f42209 | 2015-12-23 15:12:45 -0500 | [diff] [blame] | 30 | if(CMAKE_SYSTEM_NAME MATCHES "Linux") |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 31 | set(LINUX TRUE) |
Stephen White | e6ab01f | 2019-04-04 14:31:25 -0400 | [diff] [blame] | 32 | elseif(CMAKE_SYSTEM_NAME MATCHES "Android") |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 33 | set(ANDROID TRUE) |
Stephen White | e6ab01f | 2019-04-04 14:31:25 -0400 | [diff] [blame] | 34 | set(CMAKE_CXX_FLAGS "-DANDROID_NDK_BUILD") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 35 | elseif(WIN32) |
| 36 | elseif(APPLE) |
David 'Digit' Turner | d371793 | 2019-11-19 17:54:00 +0100 | [diff] [blame] | 37 | elseif(FUCHSIA) |
| 38 | # NOTE: Building for Fuchsia requires a Fuchsia CMake-based SDK. |
| 39 | # See https://fuchsia-review.googlesource.com/c/fuchsia/+/379673 |
David 'Digit' Turner | 0809046 | 2020-04-17 15:53:21 +0200 | [diff] [blame] | 40 | find_package(FuchsiaLibraries) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 41 | else() |
| 42 | message(FATAL_ERROR "Platform is not supported") |
| 43 | endif() |
| 44 | |
Nicolas Capens | 30cd7d4 | 2017-04-25 15:17:25 -0400 | [diff] [blame] | 45 | if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch") |
| 46 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 47 | set(ARCH "aarch64") |
| 48 | else() |
| 49 | set(ARCH "arm") |
| 50 | endif() |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 51 | elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "mips*") |
| 52 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 53 | set(ARCH "mips64el") |
| 54 | else() |
| 55 | set(ARCH "mipsel") |
| 56 | endif() |
Colin Samples | f63a3ab | 2019-06-13 12:53:09 -0400 | [diff] [blame] | 57 | elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc*") |
| 58 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 59 | set(ARCH "ppc64le") |
| 60 | else() |
| 61 | message(FATAL_ERROR "Architecture is not supported") |
| 62 | endif() |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 63 | else() |
Nicolas Capens | 30cd7d4 | 2017-04-25 15:17:25 -0400 | [diff] [blame] | 64 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 65 | set(ARCH "x86_64") |
| 66 | else() |
| 67 | set(ARCH "x86") |
| 68 | endif() |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 69 | endif() |
| 70 | |
Yilong Li | 14dcbed | 2021-01-19 16:31:21 -0800 | [diff] [blame] | 71 | # Cross compiling on macOS. The cross compiling architecture should override |
| 72 | # auto-detected system architecture settings. |
| 73 | if(CMAKE_OSX_ARCHITECTURES) |
| 74 | if(CMAKE_OSX_ARCHITECTURES MATCHES "arm64") |
| 75 | set(ARCH "aarch64") |
| 76 | elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") |
| 77 | set(ARCH "x86_64") |
| 78 | elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386") |
| 79 | set(ARCH "x86") |
| 80 | else() |
| 81 | message(FATAL_ERROR "Architecture ${CMAKE_OSX_ARCHITECTURES} is not " |
| 82 | "supported. Only one architecture (arm64, x86_64 " |
| 83 | "or i386) could be specified at build time.") |
| 84 | endif() |
| 85 | endif() |
| 86 | |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 87 | set(CMAKE_MACOSX_RPATH TRUE) |
Nicolas Capens | 007c6c5 | 2017-06-09 11:21:48 -0400 | [diff] [blame] | 88 | |
Nicolas Capens | d7a21cc | 2018-09-11 13:09:28 -0400 | [diff] [blame] | 89 | if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (CMAKE_GENERATOR_TOOLSET STREQUAL "")) |
| 90 | message(WARNING "Visual Studio generators use the x86 host compiler by " |
| 91 | "default, even for 64-bit targets. This can result in linker " |
| 92 | "instability and out of memory errors. To use the 64-bit " |
| 93 | "host compiler, pass -Thost=x64 on the CMake command line.") |
| 94 | endif() |
| 95 | |
Ben Clayton | 4901ffd | 2019-06-27 10:39:07 +0100 | [diff] [blame] | 96 | # Use CCache if available |
| 97 | find_program(CCACHE_FOUND ccache) |
| 98 | if(CCACHE_FOUND) |
| 99 | message(STATUS "Using ccache") |
| 100 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) |
| 101 | set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) |
Ben Clayton | 1e8486b | 2020-01-22 17:01:52 +0000 | [diff] [blame] | 102 | endif() |
Ben Clayton | 4901ffd | 2019-06-27 10:39:07 +0100 | [diff] [blame] | 103 | |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 104 | ########################################################### |
Ben Clayton | a9af883 | 2019-08-14 13:09:43 +0100 | [diff] [blame] | 105 | # Host libraries |
| 106 | ########################################################### |
| 107 | |
| 108 | find_library(X11 X11) |
| 109 | find_library(XCB xcb) |
Nicolas Caramelli | a681d12 | 2020-07-20 23:47:56 +0200 | [diff] [blame] | 110 | if(SWIFTSHADER_BUILD_WSI_WAYLAND) |
| 111 | find_library(WAYLAND wayland-client) |
| 112 | endif(SWIFTSHADER_BUILD_WSI_WAYLAND) |
Nicolas Caramelli | 08596c4 | 2020-08-01 07:55:00 +0200 | [diff] [blame] | 113 | if(SWIFTSHADER_BUILD_WSI_DIRECTFB) |
| 114 | find_library(DIRECTFB directfb) |
| 115 | find_path(DIRECTFB_INCLUDE_DIR directfb/directfb.h) |
| 116 | endif(SWIFTSHADER_BUILD_WSI_DIRECTFB) |
Nicolas Caramelli | 937395c | 2021-01-06 21:00:18 +0100 | [diff] [blame] | 117 | if(SWIFTSHADER_BUILD_WSI_D2D) |
| 118 | find_library(D2D drm) |
| 119 | find_path(D2D_INCLUDE_DIR libdrm/drm.h) |
| 120 | endif(SWIFTSHADER_BUILD_WSI_D2D) |
Ben Clayton | a9af883 | 2019-08-14 13:09:43 +0100 | [diff] [blame] | 121 | |
| 122 | ########################################################### |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 123 | # Options |
| 124 | ########################################################### |
| 125 | |
| 126 | if(NOT CMAKE_BUILD_TYPE) |
| 127 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The type of build: Debug Release MinSizeRel RelWithDebInfo." FORCE) |
Antonio Maiorano | 31038ea | 2020-04-15 16:47:00 -0400 | [diff] [blame] | 128 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo) |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 129 | endif() |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 130 | |
Ben Clayton | 5837d87 | 2020-01-20 16:23:36 +0000 | [diff] [blame] | 131 | function (option_if_not_defined name description default) |
| 132 | if(NOT DEFINED ${name}) |
| 133 | option(${name} ${description} ${default}) |
| 134 | endif() |
| 135 | endfunction() |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 136 | |
Ben Clayton | 9cc163c | 2020-01-20 16:26:36 +0000 | [diff] [blame] | 137 | function (set_if_not_defined name value) |
| 138 | if(NOT DEFINED ${name}) |
| 139 | set(${name} ${value} PARENT_SCOPE) |
| 140 | endif() |
| 141 | endfunction() |
| 142 | |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 143 | option_if_not_defined(SWIFTSHADER_BUILD_EGL "Build the EGL library" TRUE) |
| 144 | option_if_not_defined(SWIFTSHADER_BUILD_GLESv2 "Build the OpenGL ES 2 library" TRUE) |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 145 | option_if_not_defined(SWIFTSHADER_BUILD_VULKAN "Build the Vulkan library" TRUE) |
Nicolas Caramelli | a681d12 | 2020-07-20 23:47:56 +0200 | [diff] [blame] | 146 | option_if_not_defined(SWIFTSHADER_BUILD_WSI_WAYLAND "Build the Wayland WSI support" FALSE) |
Nicolas Caramelli | 08596c4 | 2020-08-01 07:55:00 +0200 | [diff] [blame] | 147 | option_if_not_defined(SWIFTSHADER_BUILD_WSI_DIRECTFB "Build the DirectFB WSI support" FALSE) |
Nicolas Caramelli | 937395c | 2021-01-06 21:00:18 +0100 | [diff] [blame] | 148 | option_if_not_defined(SWIFTSHADER_BUILD_WSI_D2D "Build the Direct-to-Display WSI support" FALSE) |
Nicolas Capens | 13943ba | 2020-03-17 22:36:24 -0400 | [diff] [blame] | 149 | option_if_not_defined(SWIFTSHADER_BUILD_PVR "Build the PowerVR examples" TRUE) |
| 150 | option_if_not_defined(SWIFTSHADER_GET_PVR "Check out the PowerVR submodule" FALSE) |
Antonio Maiorano | 4e39779 | 2020-07-27 15:14:52 -0400 | [diff] [blame] | 151 | option_if_not_defined(SWIFTSHADER_BUILD_ANGLE "Build angle" FALSE) |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 152 | |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 153 | option_if_not_defined(SWIFTSHADER_USE_GROUP_SOURCES "Group the source files in a folder tree for Visual Studio" TRUE) |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 154 | |
Nicolas Capens | 45755df | 2020-03-30 12:42:40 -0400 | [diff] [blame] | 155 | option_if_not_defined(SWIFTSHADER_BUILD_TESTS "Build unit tests" TRUE) |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 156 | option_if_not_defined(SWIFTSHADER_BUILD_BENCHMARKS "Build benchmarks" FALSE) |
Ben Clayton | 5837d87 | 2020-01-20 16:23:36 +0000 | [diff] [blame] | 157 | |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 158 | option_if_not_defined(SWIFTSHADER_MSAN "Build with memory sanitizer" FALSE) |
| 159 | option_if_not_defined(SWIFTSHADER_ASAN "Build with address sanitizer" FALSE) |
| 160 | option_if_not_defined(SWIFTSHADER_TSAN "Build with thread sanitizer" FALSE) |
| 161 | option_if_not_defined(SWIFTSHADER_UBSAN "Build with undefined behavior sanitizer" FALSE) |
Ben Clayton | 063fc02 | 2020-03-23 13:18:09 +0000 | [diff] [blame] | 162 | option_if_not_defined(SWIFTSHADER_EMIT_COVERAGE "Emit code coverage information" FALSE) |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 163 | option_if_not_defined(SWIFTSHADER_WARNINGS_AS_ERRORS "Treat all warnings as errors" TRUE) |
| 164 | option_if_not_defined(SWIFTSHADER_DCHECK_ALWAYS_ON "Check validation macros even in release builds" FALSE) |
| 165 | option_if_not_defined(REACTOR_EMIT_DEBUG_INFO "Emit debug info for JIT functions" FALSE) |
| 166 | option_if_not_defined(REACTOR_EMIT_PRINT_LOCATION "Emit printing of location info for JIT functions" FALSE) |
Antonio Maiorano | 6f6ca29 | 2020-11-27 15:40:15 -0500 | [diff] [blame] | 167 | option_if_not_defined(REACTOR_EMIT_ASM_FILE "Emit asm files for JIT functions" FALSE) |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 168 | option_if_not_defined(REACTOR_ENABLE_PRINT "Enable RR_PRINT macros" FALSE) |
| 169 | option_if_not_defined(REACTOR_VERIFY_LLVM_IR "Check reactor-generated LLVM IR is valid even in release builds" FALSE) |
Adlai Holler | 0320eab | 2021-02-17 12:29:00 -0500 | [diff] [blame] | 170 | # TODO(b/155148722): Remove when unconditionally instrumenting for all build systems. |
| 171 | option_if_not_defined(REACTOR_ENABLE_MEMORY_SANITIZER_INSTRUMENTATION "Include JIT in MSAN instrumentation (LLVM backend)" TRUE) |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 172 | option_if_not_defined(SWIFTSHADER_LESS_DEBUG_INFO "Generate less debug info to reduce file size" FALSE) |
| 173 | option_if_not_defined(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER "Enable Vulkan debugger support" FALSE) |
| 174 | option_if_not_defined(SWIFTSHADER_ENABLE_ASTC "Enable ASTC compressed textures support" TRUE) # TODO(b/150130101) |
Nicolas Capens | bf8fd5b | 2018-06-21 00:42:00 -0400 | [diff] [blame] | 175 | |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 176 | set(BUILD_MARL ${SWIFTSHADER_BUILD_VULKAN}) |
Ben Clayton | 5e4d55f | 2019-12-10 19:40:58 +0000 | [diff] [blame] | 177 | |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 178 | if(${SWIFTSHADER_BUILD_VULKAN} AND ${SWIFTSHADER_ENABLE_VULKAN_DEBUGGER}) |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 179 | set_if_not_defined(SWIFTSHADER_BUILD_CPPDAP TRUE) |
Ben Clayton | 5e4d55f | 2019-12-10 19:40:58 +0000 | [diff] [blame] | 180 | else() |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 181 | set_if_not_defined(SWIFTSHADER_BUILD_CPPDAP FALSE) |
Ben Clayton | 5e4d55f | 2019-12-10 19:40:58 +0000 | [diff] [blame] | 182 | endif() |
Ben Clayton | e693b62 | 2019-09-05 12:48:37 +0100 | [diff] [blame] | 183 | |
Nicolas Capens | 5f8a16a | 2019-08-15 10:36:13 -0400 | [diff] [blame] | 184 | set(DEFAULT_REACTOR_BACKEND "LLVM") |
Nicolas Capens | 3957b7f | 2018-10-15 12:54:41 -0400 | [diff] [blame] | 185 | set(REACTOR_BACKEND ${DEFAULT_REACTOR_BACKEND} CACHE STRING "JIT compiler back-end used by Reactor") |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 186 | set_property(CACHE REACTOR_BACKEND PROPERTY STRINGS LLVM Subzero) |
| 187 | |
Antonio Maiorano | 6a6ae44 | 2020-07-20 14:11:48 -0400 | [diff] [blame] | 188 | set(DEFAULT_SWIFTSHADER_LLVM_VERSION "10.0") |
Ben Clayton | cafff78 | 2020-03-26 11:18:05 +0000 | [diff] [blame] | 189 | set(SWIFTSHADER_LLVM_VERSION ${DEFAULT_SWIFTSHADER_LLVM_VERSION} CACHE STRING "LLVM version to use") |
Antonio Maiorano | 6a6ae44 | 2020-07-20 14:11:48 -0400 | [diff] [blame] | 190 | set_property(CACHE SWIFTSHADER_LLVM_VERSION PROPERTY STRINGS "10.0") |
Ben Clayton | cafff78 | 2020-03-26 11:18:05 +0000 | [diff] [blame] | 191 | |
Antonio Maiorano | 062dc18 | 2019-12-09 11:52:31 -0500 | [diff] [blame] | 192 | # If defined, overrides the default optimization level of the current reactor backend. |
| 193 | # Set to one of the rr::Optimization::Level enum values. |
Antonio Maiorano | b17161a | 2020-11-23 11:17:22 -0500 | [diff] [blame] | 194 | set(REACTOR_DEFAULT_OPT_LEVEL "" CACHE STRING "Reactor default optimization level") |
Antonio Maiorano | 062dc18 | 2019-12-09 11:52:31 -0500 | [diff] [blame] | 195 | set_property(CACHE REACTOR_DEFAULT_OPT_LEVEL PROPERTY STRINGS "None" "Less" "Default" "Aggressive") |
| 196 | |
Ben Clayton | cbb5a10 | 2020-10-03 11:15:47 +0100 | [diff] [blame] | 197 | if(NOT DEFINED SWIFTSHADER_LOGGING_LEVEL) |
| 198 | set(SWIFTSHADER_LOGGING_LEVEL "Info" CACHE STRING "SwiftShader logging level") |
| 199 | set_property(CACHE SWIFTSHADER_LOGGING_LEVEL PROPERTY STRINGS "Verbose" "Debug" "Info" "Warn" "Error" "Fatal" "Disabled") |
| 200 | endif() |
| 201 | |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 202 | # LLVM disallows calling cmake . from the main LLVM dir, the reason is that |
| 203 | # it builds header files that could overwrite the orignal ones. Here we |
| 204 | # want to include LLVM as a subdirectory and even though it wouldn't cause |
| 205 | # the problem, if cmake . is called from the main dir, the condition that |
Erwin Jansen | d46faeb | 2018-11-19 16:01:37 -0800 | [diff] [blame] | 206 | # LLVM checkes, "CMAKE_CURRENT_SOURCE_DIR == CMAKE_CURRENT_BINARY_DIR" will be true. So we |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 207 | # disallow it ourselves too to. In addition if there are remining CMakeFiles |
| 208 | # and CMakeCache in the directory, cmake .. from a subdirectory will still |
| 209 | # try to build from the main directory so we instruct users to delete these |
| 210 | # files when they get the error. |
Erwin Jansen | d46faeb | 2018-11-19 16:01:37 -0800 | [diff] [blame] | 211 | if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 212 | 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.") |
| 213 | endif() |
| 214 | |
Nicolas Capens | 1dfcdb0 | 2020-03-12 21:12:52 +0000 | [diff] [blame] | 215 | set_property(GLOBAL PROPERTY USE_FOLDERS TRUE) |
Nicolas Capens | 18b8d68 | 2017-07-25 15:31:45 -0400 | [diff] [blame] | 216 | |
| 217 | ########################################################### |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 218 | # Directories |
| 219 | ########################################################### |
| 220 | |
Antonio Maiorano | 8772b42 | 2020-04-15 15:00:36 -0400 | [diff] [blame] | 221 | set(SWIFTSHADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 222 | set(SOURCE_DIR ${SWIFTSHADER_DIR}/src) |
| 223 | set(THIRD_PARTY_DIR ${SWIFTSHADER_DIR}/third_party) |
| 224 | set(TESTS_DIR ${SWIFTSHADER_DIR}/tests) |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 225 | |
| 226 | ########################################################### |
Nicolas Capens | fe5861b | 2018-08-03 16:01:48 -0400 | [diff] [blame] | 227 | # Initialize submodules |
| 228 | ########################################################### |
| 229 | |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 230 | function(InitSubmodule target submodule_dir) |
| 231 | if (NOT TARGET ${target}) |
| 232 | if(NOT EXISTS ${submodule_dir}/.git) |
Ben Clayton | 55890e1 | 2020-01-31 14:07:21 +0000 | [diff] [blame] | 233 | message(WARNING " |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 234 | Target ${target} from submodule ${submodule_dir} missing. |
Ben Clayton | 55890e1 | 2020-01-31 14:07:21 +0000 | [diff] [blame] | 235 | Running 'git submodule update --init' to download it: |
| 236 | ") |
Nicolas Capens | fe5861b | 2018-08-03 16:01:48 -0400 | [diff] [blame] | 237 | |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 238 | execute_process(COMMAND git -C ${SWIFTSHADER_DIR} submodule update --init ${submodule_dir}) |
Ben Clayton | 55890e1 | 2020-01-31 14:07:21 +0000 | [diff] [blame] | 239 | endif() |
Dan Sinclair | 6480d4e | 2019-03-11 10:48:19 -0400 | [diff] [blame] | 240 | endif() |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 241 | endfunction() |
| 242 | |
Antonio Maiorano | 9d35d54 | 2021-02-01 16:35:07 -0500 | [diff] [blame] | 243 | if (SWIFTSHADER_BUILD_TESTS OR SWIFTSHADER_BUILD_BENCHMARKS) |
| 244 | set(BUILD_VULKAN_WRAPPER TRUE) |
| 245 | endif() |
| 246 | |
| 247 | if (BUILD_VULKAN_WRAPPER) |
| 248 | InitSubmodule(glslang ${THIRD_PARTY_DIR}/glslang) |
| 249 | endif() |
| 250 | |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 251 | if (SWIFTSHADER_BUILD_TESTS) |
| 252 | InitSubmodule(gtest ${THIRD_PARTY_DIR}/googletest) |
Nicolas Capens | fe5861b | 2018-08-03 16:01:48 -0400 | [diff] [blame] | 253 | endif() |
| 254 | |
Ben Clayton | 55890e1 | 2020-01-31 14:07:21 +0000 | [diff] [blame] | 255 | if(SWIFTSHADER_BUILD_BENCHMARKS) |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 256 | InitSubmodule(benchmark::benchmark ${THIRD_PARTY_DIR}/benchmark) |
| 257 | endif() |
Ben Clayton | 55890e1 | 2020-01-31 14:07:21 +0000 | [diff] [blame] | 258 | |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 259 | if(REACTOR_EMIT_DEBUG_INFO) |
| 260 | InitSubmodule(libbacktrace ${THIRD_PARTY_DIR}/libbacktrace/src) |
Ben Clayton | 755467c | 2019-03-23 11:57:02 +0000 | [diff] [blame] | 261 | endif() |
| 262 | |
Nicolas Capens | 13943ba | 2020-03-17 22:36:24 -0400 | [diff] [blame] | 263 | if(SWIFTSHADER_GET_PVR) |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 264 | InitSubmodule(PVRCore ${THIRD_PARTY_DIR}/PowerVR_Examples) |
Nicolas Capens | 13943ba | 2020-03-17 22:36:24 -0400 | [diff] [blame] | 265 | set(SWIFTSHADER_GET_PVR FALSE CACHE BOOL "Check out the PowerVR submodule" FORCE) |
| 266 | endif() |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 267 | if(EXISTS ${THIRD_PARTY_DIR}/PowerVR_Examples/.git) |
Nicolas Capens | 13943ba | 2020-03-17 22:36:24 -0400 | [diff] [blame] | 268 | set(HAVE_PVR_SUBMODULE TRUE) |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 269 | endif() |
| 270 | |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 271 | if(SWIFTSHADER_BUILD_CPPDAP) |
| 272 | InitSubmodule(json ${THIRD_PARTY_DIR}/json) |
| 273 | InitSubmodule(cppdap ${THIRD_PARTY_DIR}/cppdap) |
| 274 | endif() |
| 275 | |
Antonio Maiorano | 4e39779 | 2020-07-27 15:14:52 -0400 | [diff] [blame] | 276 | if(SWIFTSHADER_BUILD_ANGLE) |
| 277 | InitSubmodule(angle ${THIRD_PARTY_DIR}/angle/angle) |
| 278 | endif() |
Antonio Maiorano | 1e2fba3 | 2020-04-15 16:02:58 -0400 | [diff] [blame] | 279 | |
Nicolas Capens | fe5861b | 2018-08-03 16:01:48 -0400 | [diff] [blame] | 280 | ########################################################### |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 281 | # Convenience macros |
| 282 | ########################################################### |
| 283 | |
| 284 | # Recursively calls source_group on the files of the directory |
| 285 | # so that Visual Studio has the files in a folder tree |
| 286 | macro(group_all_sources directory) |
Antonio Maiorano | 8772b42 | 2020-04-15 15:00:36 -0400 | [diff] [blame] | 287 | file(GLOB files RELATIVE ${SWIFTSHADER_DIR}/${directory} ${SWIFTSHADER_DIR}/${directory}/*) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 288 | foreach(file ${files}) |
Antonio Maiorano | 8772b42 | 2020-04-15 15:00:36 -0400 | [diff] [blame] | 289 | if(IS_DIRECTORY ${SWIFTSHADER_DIR}/${directory}/${file}) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 290 | group_all_sources(${directory}/${file}) |
| 291 | else() |
| 292 | string(REPLACE "/" "\\" groupname ${directory}) |
Antonio Maiorano | 8772b42 | 2020-04-15 15:00:36 -0400 | [diff] [blame] | 293 | source_group(${groupname} FILES ${SWIFTSHADER_DIR}/${directory}/${file}) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 294 | endif() |
| 295 | endforeach() |
| 296 | endmacro() |
| 297 | |
| 298 | # Takes target library and a directory where the export map is |
| 299 | # and add the linker options so that only the API symbols are |
| 300 | # exported. |
Nicolas Capens | 499bb76 | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 301 | macro(set_shared_library_export_map TARGET DIR) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 302 | if(MSVC) |
Nicolas Capens | 499bb76 | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 303 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " /DEF:\"${DIR}/${TARGET}.def\"") |
Ben Clayton | 8565e77 | 2019-06-10 11:58:37 +0100 | [diff] [blame] | 304 | elseif(APPLE) |
| 305 | # The exported symbols list only exports the API functions and |
| 306 | # hides all the others. |
| 307 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS "-exported_symbols_list ${DIR}/${TARGET}.exports") |
| 308 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_DEPENDS "${DIR}/${TARGET}.exports;") |
| 309 | # Don't allow undefined symbols, unless it's a Sanitizer build. |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 310 | if(NOT SWIFTSHADER_MSAN AND NOT SWIFTSHADER_ASAN AND NOT SWIFTSHADER_TSAN AND NOT SWIFTSHADER_UBSAN) |
Ben Clayton | 8565e77 | 2019-06-10 11:58:37 +0100 | [diff] [blame] | 311 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-undefined,error") |
| 312 | endif() |
David 'Digit' Turner | d371793 | 2019-11-19 17:54:00 +0100 | [diff] [blame] | 313 | elseif(LINUX OR FUCHSIA) |
David 'Digit' Turner | 6e44504 | 2020-04-17 16:27:56 +0200 | [diff] [blame] | 314 | # NOTE: The Fuchsia linker script is needed to export the vk_icdInitializeConnectToServiceCallback |
| 315 | # entry point (a private implementation detail betwen the Fuchsia Vulkan loader and the ICD). |
| 316 | if ((FUCHSIA) AND ("${TARGET}" STREQUAL "vk_swiftshader")) |
| 317 | set(LINKER_VERSION_SCRIPT "fuchsia_vk_swiftshader.lds") |
| 318 | else() |
| 319 | set(LINKER_VERSION_SCRIPT "${TARGET}.lds") |
| 320 | endif() |
| 321 | |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 322 | # The version script only exports the API functions and |
Nicolas Capens | 499bb76 | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 323 | # hides all the others. |
David 'Digit' Turner | 6e44504 | 2020-04-17 16:27:56 +0200 | [diff] [blame] | 324 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--version-script=${DIR}/${LINKER_VERSION_SCRIPT}") |
| 325 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_DEPENDS "${DIR}/${LINKER_VERSION_SCRIPT};") |
Nicolas Capens | bf8fd5b | 2018-06-21 00:42:00 -0400 | [diff] [blame] | 326 | |
Nicolas Capens | e3621dc | 2020-02-25 22:45:42 -0500 | [diff] [blame] | 327 | # -Bsymbolic binds symbol references to their global definitions within |
| 328 | # a shared object, thereby preventing symbol preemption. |
James Price | 126720b | 2020-03-03 10:20:00 -0500 | [diff] [blame] | 329 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-Bsymbolic") |
Nicolas Capens | 517a57f | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 330 | |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 331 | if(ARCH STREQUAL "mipsel" OR ARCH STREQUAL "mips64el") |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 332 | # MIPS supports sysv hash-style only. |
| 333 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--hash-style=sysv") |
David 'Digit' Turner | d371793 | 2019-11-19 17:54:00 +0100 | [diff] [blame] | 334 | elseif(LINUX) |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 335 | # Both hash-style are needed, because we want both gold and |
| 336 | # GNU ld to be able to read our libraries. |
| 337 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--hash-style=both") |
| 338 | endif() |
Nicolas Capens | 499bb76 | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 339 | |
Ben Clayton | 063fc02 | 2020-03-23 13:18:09 +0000 | [diff] [blame] | 340 | if(NOT ${SWIFTSHADER_EMIT_COVERAGE}) |
| 341 | # Gc sections is used in combination with each functions being |
| 342 | # in its own section, to reduce the binary size. |
| 343 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--gc-sections") |
| 344 | endif() |
Nicolas Capens | 499bb76 | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 345 | |
| 346 | # Don't allow undefined symbols, unless it's a Sanitizer build. |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 347 | if(NOT SWIFTSHADER_MSAN AND NOT SWIFTSHADER_ASAN AND NOT SWIFTSHADER_TSAN AND NOT SWIFTSHADER_UBSAN) |
Nicolas Capens | bf8fd5b | 2018-06-21 00:42:00 -0400 | [diff] [blame] | 348 | set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined") |
| 349 | endif() |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 350 | endif() |
| 351 | endmacro() |
| 352 | |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 353 | if(SWIFTSHADER_USE_GROUP_SOURCES) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 354 | group_all_sources(src) |
| 355 | endif() |
| 356 | |
| 357 | ########################################################### |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 358 | # Compile flags |
| 359 | ########################################################### |
| 360 | |
Ben Clayton | 4ceb77d | 2019-04-24 12:09:59 +0100 | [diff] [blame] | 361 | # Flags for project code (non 3rd party) |
| 362 | set(SWIFTSHADER_COMPILE_OPTIONS "") |
Ben Clayton | 063fc02 | 2020-03-23 13:18:09 +0000 | [diff] [blame] | 363 | set(SWIFTSHADER_LINK_FLAGS "") |
| 364 | set(SWIFTSHADER_LIBS "") |
Ben Clayton | 4ceb77d | 2019-04-24 12:09:59 +0100 | [diff] [blame] | 365 | |
Nicolas Capens | 6f42209 | 2015-12-23 15:12:45 -0500 | [diff] [blame] | 366 | macro(set_cpp_flag FLAG) |
| 367 | if(${ARGC} GREATER 1) |
| 368 | set(CMAKE_CXX_FLAGS_${ARGV1} "${CMAKE_CXX_FLAGS_${ARGV1}} ${FLAG}") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 369 | else() |
Nicolas Capens | 6f42209 | 2015-12-23 15:12:45 -0500 | [diff] [blame] | 370 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 371 | endif() |
| 372 | endmacro() |
| 373 | |
Ben Clayton | 48c8a18 | 2019-05-21 20:00:20 +0100 | [diff] [blame] | 374 | macro(set_linker_flag FLAG) |
| 375 | if(${ARGC} GREATER 1) |
Nicolas Capens | 5d4c981 | 2020-07-02 10:06:25 -0400 | [diff] [blame] | 376 | set(CMAKE_EXE_LINKER_FLAGS_${ARGV1} "${CMAKE_EXE_LINKER_FLAGS_${ARGV1}} ${FLAG}") |
Nicolas Capens | 268fd73 | 2020-10-08 16:46:48 -0400 | [diff] [blame] | 377 | set(CMAKE_SHARED_LINKER_FLAGS_${ARGV1} "${CMAKE_EXE_LINKER_FLAGS_${ARGV1}} ${FLAG}") |
Ben Clayton | 48c8a18 | 2019-05-21 20:00:20 +0100 | [diff] [blame] | 378 | else() |
| 379 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}") |
Nicolas Capens | 268fd73 | 2020-10-08 16:46:48 -0400 | [diff] [blame] | 380 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}") |
Ben Clayton | 48c8a18 | 2019-05-21 20:00:20 +0100 | [diff] [blame] | 381 | endif() |
| 382 | endmacro() |
| 383 | |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 384 | if(MSVC) |
| 385 | set_cpp_flag("/MP") |
| 386 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) |
Antonio Maiorano | 5bce1f4 | 2019-05-10 16:03:49 -0400 | [diff] [blame] | 387 | add_definitions(-D_SCL_SECURE_NO_WARNINGS) |
Nicolas Capens | 4c9f04b | 2019-01-31 22:09:03 -0500 | [diff] [blame] | 388 | add_definitions(-D_SBCS) # Single Byte Character Set (ASCII) |
Ben Clayton | 30b6b59 | 2019-08-07 15:04:11 +0100 | [diff] [blame] | 389 | add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) # Disable MSVC warnings about std::aligned_storage being broken before VS 2017 15.8 |
Antonio Maiorano | 5bce1f4 | 2019-05-10 16:03:49 -0400 | [diff] [blame] | 390 | |
Nicolas Capens | 5d4c981 | 2020-07-02 10:06:25 -0400 | [diff] [blame] | 391 | set_linker_flag("/DEBUG:FASTLINK" DEBUG) |
| 392 | set_linker_flag("/DEBUG:FASTLINK" RELWITHDEBINFO) |
Nicolas Capens | f554c54 | 2020-01-09 17:19:35 +0000 | [diff] [blame] | 393 | |
Antonio Maiorano | 5bce1f4 | 2019-05-10 16:03:49 -0400 | [diff] [blame] | 394 | # Disable specific warnings |
| 395 | # TODO: Not all of these should be disabled, but for now, we want a warning-free msvc build. Remove these one by one |
| 396 | # and fix the actual warnings in code. |
| 397 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
| 398 | "/wd4005" # 'identifier' : macro redefinition |
| 399 | "/wd4018" # 'expression' : signed/unsigned mismatch |
Ben Clayton | 4d4a190 | 2019-05-15 11:15:42 +0100 | [diff] [blame] | 400 | "/wd4065" # switch statement contains 'default' but no 'case' labels |
Antonio Maiorano | 5bce1f4 | 2019-05-10 16:03:49 -0400 | [diff] [blame] | 401 | "/wd4141" # 'modifier' : used more than once |
Antonio Maiorano | 5bce1f4 | 2019-05-10 16:03:49 -0400 | [diff] [blame] | 402 | "/wd4244" # 'conversion' conversion from 'type1' to 'type2', possible loss of data |
| 403 | "/wd4267" # 'var' : conversion from 'size_t' to 'type', possible loss of data |
| 404 | "/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 |
| 405 | "/wd4309" # 'conversion' : truncation of constant value |
| 406 | "/wd4624" # 'derived class' : destructor was implicitly defined as deleted because a base class destructor is inaccessible or deleted |
| 407 | "/wd4800" # 'type' : forcing value to bool 'true' or 'false' (performance warning) |
| 408 | "/wd4838" # conversion from 'type_1' to 'type_2' requires a narrowing conversion |
| 409 | "/wd5030" # attribute 'attribute' is not recognized |
| 410 | "/wd5038" # data member 'member1' will be initialized after data member 'member2' data member 'member' will be initialized after base class 'base_class' |
| 411 | ) |
| 412 | |
| 413 | # Treat specific warnings as errors |
| 414 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
| 415 | "/we4018" # 'expression' : signed/unsigned mismatch |
Antonio Maiorano | 23da073 | 2019-05-14 22:32:16 -0400 | [diff] [blame] | 416 | "/we4471" # 'enumeration': a forward declaration of an unscoped enumeration must have an underlying type (int assumed) |
Antonio Maiorano | 5bce1f4 | 2019-05-10 16:03:49 -0400 | [diff] [blame] | 417 | "/we4838" # conversion from 'type_1' to 'type_2' requires a narrowing conversion |
| 418 | "/we5038" # data member 'member1' will be initialized after data member 'member2' data member 'member' will be initialized after base class 'base_class' |
| 419 | ) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 420 | else() |
Ben Clayton | a5f0763 | 2020-02-04 11:43:25 +0000 | [diff] [blame] | 421 | # Explicitly enable these warnings. |
Ben Clayton | 4ceb77d | 2019-04-24 12:09:59 +0100 | [diff] [blame] | 422 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
Ben Clayton | 4ceb77d | 2019-04-24 12:09:59 +0100 | [diff] [blame] | 423 | "-Wall" |
Ben Clayton | 8a983f7 | 2019-06-18 17:56:36 +0100 | [diff] [blame] | 424 | "-Wreorder" |
| 425 | "-Wsign-compare" |
| 426 | "-Wmissing-braces" |
Ben Clayton | 4ceb77d | 2019-04-24 12:09:59 +0100 | [diff] [blame] | 427 | ) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 428 | |
James Rumble | 69deca6 | 2021-07-01 11:39:34 +0100 | [diff] [blame^] | 429 | if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 430 | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9) |
| 431 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
| 432 | "-Wdeprecated-copy" # implicit copy constructor for 'X' is deprecated because of user-declared copy assignment operator. |
| 433 | ) |
| 434 | endif() |
| 435 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
Ben Clayton | 4ceb77d | 2019-04-24 12:09:59 +0100 | [diff] [blame] | 436 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
Ben Clayton | 5470988 | 2020-04-16 10:40:08 +0100 | [diff] [blame] | 437 | "-Wextra" |
| 438 | "-Wunreachable-code-loop-increment" |
Ben Clayton | 8a983f7 | 2019-06-18 17:56:36 +0100 | [diff] [blame] | 439 | "-Wunused-lambda-capture" |
| 440 | "-Wstring-conversion" |
| 441 | "-Wextra-semi" |
| 442 | "-Wignored-qualifiers" |
James Rumble | 69deca6 | 2021-07-01 11:39:34 +0100 | [diff] [blame^] | 443 | "-Wdeprecated-copy" # implicit copy constructor for 'X' is deprecated because of user-declared copy assignment operator. |
Ben Clayton | a5f0763 | 2020-02-04 11:43:25 +0000 | [diff] [blame] | 444 | ) |
| 445 | endif() |
| 446 | |
Ben Clayton | 063fc02 | 2020-03-23 13:18:09 +0000 | [diff] [blame] | 447 | if (SWIFTSHADER_EMIT_COVERAGE) |
| 448 | if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 449 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "--coverage") |
| 450 | list(APPEND SWIFTSHADER_LIBS "gcov") |
| 451 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 452 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fprofile-instr-generate" "-fcoverage-mapping") |
| 453 | list(APPEND SWIFTSHADER_LINK_FLAGS "-fprofile-instr-generate" "-fcoverage-mapping") |
| 454 | else() |
| 455 | message(FATAL_ERROR "Coverage generation not supported for the ${CMAKE_CXX_COMPILER_ID} toolchain") |
| 456 | endif() |
| 457 | endif() |
| 458 | |
Nicolas Capens | d2bdde2 | 2021-06-17 22:14:37 -0400 | [diff] [blame] | 459 | # Disable pedantic warnings |
Ben Clayton | a5f0763 | 2020-02-04 11:43:25 +0000 | [diff] [blame] | 460 | if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 461 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
| 462 | "-Wno-ignored-attributes" # ignoring attributes on template argument 'X' |
| 463 | "-Wno-attributes" # 'X' attribute ignored |
| 464 | "-Wno-strict-aliasing" # dereferencing type-punned pointer will break strict-aliasing rules |
| 465 | "-Wno-comment" # multi-line comment |
| 466 | ) |
| 467 | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9) |
| 468 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
| 469 | "-Wno-init-list-lifetime" # assignment from temporary initializer_list does not extend the lifetime of the underlying array |
| 470 | ) |
| 471 | endif() |
| 472 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 473 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
| 474 | "-Wno-unneeded-internal-declaration" # function 'X' is not needed and will not be emitted |
| 475 | "-Wno-unused-private-field" # private field 'offset' is not used - TODO: Consider enabling this once Vulkan is further implemented. |
| 476 | "-Wno-comment" # multi-line comment |
| 477 | "-Wno-undefined-var-template" # instantiation of variable 'X' required here, but no definition is available |
Ben Clayton | a7bc2b9 | 2020-03-26 11:24:49 +0000 | [diff] [blame] | 478 | "-Wno-extra-semi" # extra ';' after member function definition |
Ben Clayton | 5470988 | 2020-04-16 10:40:08 +0100 | [diff] [blame] | 479 | "-Wno-unused-parameter" # unused parameter 'X' |
Ben Clayton | a5f0763 | 2020-02-04 11:43:25 +0000 | [diff] [blame] | 480 | |
Nicolas Capens | 67180a0 | 2019-06-17 15:27:03 -0400 | [diff] [blame] | 481 | # Silence errors caused by unknown warnings when building with older |
| 482 | # versions of Clang. This demands checking that warnings added above |
| 483 | # are spelled correctly and work as intended! |
| 484 | "-Wno-unknown-warning-option" |
Ben Clayton | 4ceb77d | 2019-04-24 12:09:59 +0100 | [diff] [blame] | 485 | ) |
Nicolas Capens | 825d344 | 2018-11-06 23:50:05 -0500 | [diff] [blame] | 486 | endif() |
| 487 | |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 488 | # Remove xor, and, or and friends from the list of keywords, they are used |
| 489 | # by Reactor |
Ben Clayton | 4ceb77d | 2019-04-24 12:09:59 +0100 | [diff] [blame] | 490 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS |
| 491 | "-fno-operator-names" |
| 492 | ) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 493 | |
Nicolas Capens | 499bb76 | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 494 | if(ARCH STREQUAL "x86") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 495 | set_cpp_flag("-m32") |
| 496 | set_cpp_flag("-msse2") |
Nicolas Capens | 0424edc | 2018-01-03 14:06:30 -0500 | [diff] [blame] | 497 | set_cpp_flag("-mfpmath=sse") |
| 498 | set_cpp_flag("-march=pentium4") |
| 499 | set_cpp_flag("-mtune=generic") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 500 | endif() |
Nicolas Capens | 499bb76 | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 501 | if(ARCH STREQUAL "x86_64") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 502 | set_cpp_flag("-m64") |
| 503 | set_cpp_flag("-fPIC") |
Nicolas Capens | 0424edc | 2018-01-03 14:06:30 -0500 | [diff] [blame] | 504 | set_cpp_flag("-march=x86-64") |
| 505 | set_cpp_flag("-mtune=generic") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 506 | endif() |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 507 | if(ARCH STREQUAL "mipsel") |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 508 | set_cpp_flag("-EL") |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 509 | set_cpp_flag("-march=mips32r2") |
| 510 | set_cpp_flag("-fPIC") |
| 511 | set_cpp_flag("-mhard-float") |
| 512 | set_cpp_flag("-mfp32") |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 513 | set_cpp_flag("-mxgot") |
Gordana Cmiljanovic | 082dfec | 2018-10-19 11:36:15 +0200 | [diff] [blame] | 514 | endif() |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 515 | if(ARCH STREQUAL "mips64el") |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 516 | set_cpp_flag("-EL") |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 517 | set_cpp_flag("-march=mips64r2") |
| 518 | set_cpp_flag("-mabi=64") |
| 519 | set_cpp_flag("-fPIC") |
Jiaxun Yang | 55275c3 | 2020-02-09 14:52:42 +0800 | [diff] [blame] | 520 | set_cpp_flag("-mxgot") |
Gordana Cmiljanovic | 20622c0 | 2018-11-05 15:00:11 +0100 | [diff] [blame] | 521 | endif() |
Nicolas Capens | 499bb76 | 2018-06-29 13:30:57 -0400 | [diff] [blame] | 522 | |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 523 | if(SWIFTSHADER_LESS_DEBUG_INFO) |
Paul Thomson | 09b5079 | 2019-10-17 12:55:56 +0100 | [diff] [blame] | 524 | # Use -g1 to be able to get stack traces |
| 525 | set_cpp_flag("-g -g1" DEBUG) |
| 526 | set_cpp_flag("-g -g1" RELWITHDEBINFO) |
| 527 | else() |
| 528 | # Use -g3 to have even more debug info |
| 529 | set_cpp_flag("-g -g3" DEBUG) |
| 530 | set_cpp_flag("-g -g3" RELWITHDEBINFO) |
| 531 | endif() |
| 532 | |
Ben Clayton | 09a91e4 | 2019-02-05 17:58:38 +0000 | [diff] [blame] | 533 | if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 534 | # Treated as an unused argument with clang |
| 535 | set_cpp_flag("-s" RELEASE) |
| 536 | endif() |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 537 | |
| 538 | # For distribution it is more important to be slim than super optimized |
Alexis Hetu | 2c0546d | 2017-05-24 11:16:26 -0400 | [diff] [blame] | 539 | set_cpp_flag("-Os" RELEASE) |
| 540 | set_cpp_flag("-Os" RELWITHDEBINFO) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 541 | |
| 542 | set_cpp_flag("-DNDEBUG" RELEASE) |
| 543 | set_cpp_flag("-DNDEBUG" RELWITHDEBINFO) |
| 544 | set_cpp_flag("-DANGLE_DISABLE_TRACE" RELEASE) |
| 545 | set_cpp_flag("-DANGLE_DISABLE_TRACE" RELWITHDEBINFO) |
| 546 | |
| 547 | # Put each variable and function in its own section so that when linking |
| 548 | # with -gc-sections unused functions and variables are removed. |
| 549 | set_cpp_flag("-ffunction-sections" RELEASE) |
| 550 | set_cpp_flag("-fdata-sections" RELEASE) |
| 551 | set_cpp_flag("-fomit-frame-pointer" RELEASE) |
Nicolas Capens | bf8fd5b | 2018-06-21 00:42:00 -0400 | [diff] [blame] | 552 | |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 553 | if(SWIFTSHADER_MSAN) |
Nicolas Capens | 7a0ca4e | 2020-11-30 10:08:59 -0500 | [diff] [blame] | 554 | if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 555 | message(FATAL_ERROR " \n" |
| 556 | " MemorySanitizer usage requires compiling with Clang.") |
| 557 | endif() |
| 558 | |
Nicolas Capens | 268fd73 | 2020-10-08 16:46:48 -0400 | [diff] [blame] | 559 | if(NOT DEFINED ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}) |
Nicolas Capens | 268fd73 | 2020-10-08 16:46:48 -0400 | [diff] [blame] | 560 | message(FATAL_ERROR " \n" |
| 561 | " MemorySanitizer usage requires an instrumented build of libc++.\n" |
| 562 | " Set the SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH environment variable to the\n" |
| 563 | " build output path. See\n" |
| 564 | " https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo#instrumented-libc\n" |
| 565 | " for details on how to build an MSan instrumented libc++.") |
| 566 | endif() |
| 567 | |
Ben Clayton | dae9792 | 2019-05-17 12:09:31 +0100 | [diff] [blame] | 568 | set_cpp_flag("-fsanitize=memory") |
Ben Clayton | 48c8a18 | 2019-05-21 20:00:20 +0100 | [diff] [blame] | 569 | set_linker_flag("-fsanitize=memory") |
Nicolas Capens | 268fd73 | 2020-10-08 16:46:48 -0400 | [diff] [blame] | 570 | set_cpp_flag("-stdlib=libc++") |
| 571 | set_linker_flag("-L$ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}/lib") |
| 572 | set_cpp_flag("-I$ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}/include") |
| 573 | set_cpp_flag("-I$ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}/include/c++/v1") |
| 574 | set_linker_flag("-Wl,-rpath,$ENV{SWIFTSHADER_MSAN_INSTRUMENTED_LIBCXX_PATH}/lib") |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 575 | elseif(SWIFTSHADER_ASAN) |
Ben Clayton | dae9792 | 2019-05-17 12:09:31 +0100 | [diff] [blame] | 576 | set_cpp_flag("-fsanitize=address") |
Ben Clayton | 48c8a18 | 2019-05-21 20:00:20 +0100 | [diff] [blame] | 577 | set_linker_flag("-fsanitize=address") |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 578 | elseif(SWIFTSHADER_TSAN) |
Ben Clayton | dae9792 | 2019-05-17 12:09:31 +0100 | [diff] [blame] | 579 | set_cpp_flag("-fsanitize=thread") |
Ben Clayton | 48c8a18 | 2019-05-21 20:00:20 +0100 | [diff] [blame] | 580 | set_linker_flag("-fsanitize=thread") |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 581 | elseif(SWIFTSHADER_UBSAN) |
Ben Clayton | dae9792 | 2019-05-17 12:09:31 +0100 | [diff] [blame] | 582 | set_cpp_flag("-fsanitize=undefined") |
Ben Clayton | 48c8a18 | 2019-05-21 20:00:20 +0100 | [diff] [blame] | 583 | set_linker_flag("-fsanitize=undefined") |
Nicolas Capens | bf8fd5b | 2018-06-21 00:42:00 -0400 | [diff] [blame] | 584 | endif() |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 585 | endif() |
| 586 | |
Antonio Maiorano | 4b8b078 | 2020-03-23 14:11:01 -0400 | [diff] [blame] | 587 | if(SWIFTSHADER_DCHECK_ALWAYS_ON) |
| 588 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DDCHECK_ALWAYS_ON") |
| 589 | endif() |
| 590 | |
Nicolas Capens | 8c13b2f | 2020-03-06 01:12:01 -0500 | [diff] [blame] | 591 | if(SWIFTSHADER_WARNINGS_AS_ERRORS) |
| 592 | if(MSVC) |
| 593 | set(WARNINGS_AS_ERRORS "/WX") # Treat all warnings as errors |
| 594 | else() |
| 595 | set(WARNINGS_AS_ERRORS "-Werror") # Treat all warnings as errors |
| 596 | endif() |
| 597 | endif() |
| 598 | |
Nicolas Capens | 8dceadd | 2020-11-06 14:36:13 -0500 | [diff] [blame] | 599 | # Enable Reactor Print() functionality in Debug/RelWithDebInfo builds or when explicitly enabled. |
| 600 | if(CMAKE_BUILD_TYPE MATCHES "Deb") |
| 601 | set(REACTOR_ENABLE_PRINT TRUE) |
| 602 | endif() |
| 603 | |
Antonio Maiorano | f448d8e | 2019-04-26 16:19:16 -0400 | [diff] [blame] | 604 | if(REACTOR_EMIT_PRINT_LOCATION) |
Antonio Maiorano | 415d181 | 2020-02-11 16:22:55 -0500 | [diff] [blame] | 605 | # This feature depends on REACTOR_EMIT_DEBUG_INFO and REACTOR_ENABLE_PRINT |
Nicolas Capens | 8dceadd | 2020-11-06 14:36:13 -0500 | [diff] [blame] | 606 | set(REACTOR_EMIT_DEBUG_INFO TRUE) |
| 607 | set(REACTOR_ENABLE_PRINT TRUE) |
Antonio Maiorano | f448d8e | 2019-04-26 16:19:16 -0400 | [diff] [blame] | 608 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_EMIT_PRINT_LOCATION") |
| 609 | endif() |
| 610 | |
Antonio Maiorano | 6f6ca29 | 2020-11-27 15:40:15 -0500 | [diff] [blame] | 611 | if(REACTOR_EMIT_ASM_FILE) |
| 612 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_EMIT_ASM_FILE") |
| 613 | endif() |
| 614 | |
Antonio Maiorano | f448d8e | 2019-04-26 16:19:16 -0400 | [diff] [blame] | 615 | if(REACTOR_EMIT_DEBUG_INFO) |
| 616 | message(WARNING "REACTOR_EMIT_DEBUG_INFO is enabled. This will likely affect performance.") |
| 617 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_DEBUG_INFO") |
| 618 | endif() |
| 619 | |
Antonio Maiorano | 415d181 | 2020-02-11 16:22:55 -0500 | [diff] [blame] | 620 | if(REACTOR_ENABLE_PRINT) |
| 621 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_PRINT") |
| 622 | endif() |
| 623 | |
Ben Clayton | 5375f47 | 2019-06-24 13:33:11 +0100 | [diff] [blame] | 624 | if(REACTOR_VERIFY_LLVM_IR) |
| 625 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_RR_LLVM_IR_VERIFICATION") |
| 626 | endif() |
| 627 | |
Antonio Maiorano | 062dc18 | 2019-12-09 11:52:31 -0500 | [diff] [blame] | 628 | if(REACTOR_DEFAULT_OPT_LEVEL) |
| 629 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DREACTOR_DEFAULT_OPT_LEVEL=${REACTOR_DEFAULT_OPT_LEVEL}") |
| 630 | endif() |
| 631 | |
Ben Clayton | cbb5a10 | 2020-10-03 11:15:47 +0100 | [diff] [blame] | 632 | if(DEFINED SWIFTSHADER_LOGGING_LEVEL) |
| 633 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DSWIFTSHADER_LOGGING_LEVEL=${SWIFTSHADER_LOGGING_LEVEL}") |
| 634 | endif() |
| 635 | |
Nicolas Capens | bf8fd5b | 2018-06-21 00:42:00 -0400 | [diff] [blame] | 636 | if(WIN32) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 637 | add_definitions(-DWINVER=0x501 -DNOMINMAX -DSTRICT) |
Nicolas Capens | 6f42209 | 2015-12-23 15:12:45 -0500 | [diff] [blame] | 638 | set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "" "lib") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 639 | endif() |
| 640 | |
Antonio Maiorano | 6102276 | 2020-03-30 11:11:16 -0400 | [diff] [blame] | 641 | set(USE_EXCEPTIONS |
| 642 | ${REACTOR_EMIT_DEBUG_INFO} # boost::stacktrace uses exceptions |
| 643 | ) |
| 644 | if(NOT MSVC) |
| 645 | if (${USE_EXCEPTIONS}) |
| 646 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fexceptions") |
| 647 | else() |
| 648 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fno-exceptions") |
| 649 | endif() |
| 650 | endif() |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 651 | unset(USE_EXCEPTIONS) |
Antonio Maiorano | 6102276 | 2020-03-30 11:11:16 -0400 | [diff] [blame] | 652 | |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 653 | ########################################################### |
Antonio Maiorano | fa8f48d | 2020-03-30 16:41:48 -0400 | [diff] [blame] | 654 | # libbacktrace and boost |
| 655 | ########################################################### |
| 656 | if(REACTOR_EMIT_DEBUG_INFO) |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 657 | add_subdirectory(${THIRD_PARTY_DIR}/libbacktrace EXCLUDE_FROM_ALL) |
| 658 | add_subdirectory(${THIRD_PARTY_DIR}/boost EXCLUDE_FROM_ALL) |
Antonio Maiorano | fa8f48d | 2020-03-30 16:41:48 -0400 | [diff] [blame] | 659 | endif() |
| 660 | |
| 661 | ########################################################### |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 662 | # LLVM |
| 663 | ########################################################### |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 664 | add_subdirectory(${THIRD_PARTY_DIR}/llvm-${SWIFTSHADER_LLVM_VERSION} EXCLUDE_FROM_ALL) |
Antonio Maiorano | 0f14b7a | 2020-09-11 10:02:16 -0400 | [diff] [blame] | 665 | set_target_properties(llvm PROPERTIES FOLDER "third_party") |
Ben Clayton | 8f71f73 | 2019-02-01 09:38:45 +0000 | [diff] [blame] | 666 | |
Antonio Maiorano | 4bde1c3 | 2020-03-27 15:01:53 -0400 | [diff] [blame] | 667 | ########################################################### |
| 668 | # Subzero |
| 669 | ########################################################### |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 670 | add_subdirectory(${THIRD_PARTY_DIR}/llvm-subzero EXCLUDE_FROM_ALL) |
| 671 | add_subdirectory(${THIRD_PARTY_DIR}/subzero EXCLUDE_FROM_ALL) |
Antonio Maiorano | 0f14b7a | 2020-09-11 10:02:16 -0400 | [diff] [blame] | 672 | set_target_properties(llvm-subzero PROPERTIES FOLDER "third_party") |
| 673 | set_target_properties(subzero PROPERTIES FOLDER "third_party") |
Antonio Maiorano | 8bce067 | 2020-02-28 13:13:45 -0500 | [diff] [blame] | 674 | |
| 675 | ########################################################### |
| 676 | # marl |
| 677 | ########################################################### |
| 678 | if(BUILD_MARL) |
| 679 | set(MARL_THIRD_PARTY_DIR ${THIRD_PARTY_DIR}) |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 680 | add_subdirectory(${THIRD_PARTY_DIR}/marl) |
Antonio Maiorano | 0f14b7a | 2020-09-11 10:02:16 -0400 | [diff] [blame] | 681 | set_target_properties(marl PROPERTIES FOLDER "third_party") |
Antonio Maiorano | 8bce067 | 2020-02-28 13:13:45 -0500 | [diff] [blame] | 682 | endif() |
| 683 | |
Ben Clayton | 377573c | 2020-04-03 20:36:40 +0100 | [diff] [blame] | 684 | if(MARL_THREAD_SAFETY_ANALYSIS_SUPPORTED) |
| 685 | list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-Wthread-safety") |
| 686 | endif() |
| 687 | |
Antonio Maiorano | 8bce067 | 2020-02-28 13:13:45 -0500 | [diff] [blame] | 688 | ########################################################### |
| 689 | # cppdap |
| 690 | ########################################################### |
| 691 | if(SWIFTSHADER_BUILD_CPPDAP) |
| 692 | set(CPPDAP_THIRD_PARTY_DIR ${THIRD_PARTY_DIR}) |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 693 | add_subdirectory(${THIRD_PARTY_DIR}/cppdap) |
Antonio Maiorano | 8bce067 | 2020-02-28 13:13:45 -0500 | [diff] [blame] | 694 | endif() |
| 695 | |
Antonio Maiorano | b02a708 | 2020-03-30 21:55:20 -0400 | [diff] [blame] | 696 | ########################################################### |
| 697 | # astc-encoder |
| 698 | ########################################################### |
| 699 | if(SWIFTSHADER_ENABLE_ASTC) |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 700 | add_subdirectory(${THIRD_PARTY_DIR}/astc-encoder) |
Antonio Maiorano | 0f14b7a | 2020-09-11 10:02:16 -0400 | [diff] [blame] | 701 | set_target_properties(astc-encoder PROPERTIES FOLDER "third_party") |
Antonio Maiorano | b02a708 | 2020-03-30 21:55:20 -0400 | [diff] [blame] | 702 | endif() |
Nicolas Capens | 19291ef | 2017-01-09 13:35:14 -0500 | [diff] [blame] | 703 | |
Nicolas Capens | f53adbd | 2017-01-06 12:47:46 -0500 | [diff] [blame] | 704 | ########################################################### |
Antonio Maiorano | 8f02f58 | 2020-03-31 11:01:43 -0400 | [diff] [blame] | 705 | # gtest and gmock |
| 706 | ########################################################### |
| 707 | if(SWIFTSHADER_BUILD_TESTS) |
| 708 | # For Win32, force gtest to match our CRT (shared) |
| 709 | set(gtest_force_shared_crt TRUE CACHE BOOL "" FORCE) |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 710 | add_subdirectory(${THIRD_PARTY_DIR}/googletest EXCLUDE_FROM_ALL) |
Antonio Maiorano | 8f02f58 | 2020-03-31 11:01:43 -0400 | [diff] [blame] | 711 | # gtest finds python, which picks python 2 first, if present. |
| 712 | # We need to undo this so that SPIR-V can later find python3. |
| 713 | unset(PYTHON_EXECUTABLE CACHE) |
Antonio Maiorano | 0f14b7a | 2020-09-11 10:02:16 -0400 | [diff] [blame] | 714 | set_target_properties(gmock PROPERTIES FOLDER "third_party") |
| 715 | set_target_properties(gmock_main PROPERTIES FOLDER "third_party") |
| 716 | set_target_properties(gtest PROPERTIES FOLDER "third_party") |
| 717 | set_target_properties(gtest_main PROPERTIES FOLDER "third_party") |
Antonio Maiorano | 8f02f58 | 2020-03-31 11:01:43 -0400 | [diff] [blame] | 718 | endif() |
| 719 | |
| 720 | ########################################################### |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 721 | # File Lists |
| 722 | ########################################################### |
| 723 | |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 724 | ########################################################### |
| 725 | # Append OS specific files to lists |
| 726 | ########################################################### |
| 727 | |
| 728 | if(WIN32) |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 729 | set(OS_LIBS odbc32 odbccp32 WS2_32 dxguid) |
| 730 | elseif(LINUX) |
Nicolas Capens | 681d97b | 2016-05-17 16:02:32 -0400 | [diff] [blame] | 731 | set(OS_LIBS dl pthread) |
Nicolas Caramelli | a681d12 | 2020-07-20 23:47:56 +0200 | [diff] [blame] | 732 | if(SWIFTSHADER_BUILD_WSI_WAYLAND) |
| 733 | list(APPEND OS_LIBS "${WAYLAND}") |
| 734 | endif(SWIFTSHADER_BUILD_WSI_WAYLAND) |
Nicolas Caramelli | 08596c4 | 2020-08-01 07:55:00 +0200 | [diff] [blame] | 735 | if(SWIFTSHADER_BUILD_WSI_DIRECTFB) |
| 736 | list(APPEND OS_LIBS "${DIRECTFB}") |
| 737 | include_directories(${DIRECTFB_INCLUDE_DIR}/directfb) |
| 738 | endif(SWIFTSHADER_BUILD_WSI_DIRECTFB) |
Nicolas Caramelli | 937395c | 2021-01-06 21:00:18 +0100 | [diff] [blame] | 739 | if(SWIFTSHADER_BUILD_WSI_D2D) |
| 740 | list(APPEND OS_LIBS "${D2D}") |
| 741 | include_directories(${D2D_INCLUDE_DIR}/libdrm) |
| 742 | endif(SWIFTSHADER_BUILD_WSI_D2D) |
David 'Digit' Turner | d371793 | 2019-11-19 17:54:00 +0100 | [diff] [blame] | 743 | elseif(FUCHSIA) |
| 744 | set(OS_LIBS zircon) |
Corentin Wallez | cd0a457 | 2015-12-10 15:59:28 -0500 | [diff] [blame] | 745 | elseif(APPLE) |
| 746 | find_library(COCOA_FRAMEWORK Cocoa) |
| 747 | find_library(QUARTZ_FRAMEWORK Quartz) |
Alexis Hetu | d23cf63 | 2018-04-10 10:48:42 -0400 | [diff] [blame] | 748 | find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation) |
| 749 | find_library(IOSURFACE_FRAMEWORK IOSurface) |
Corentin Wallez | cb58662 | 2020-03-27 17:38:29 +0100 | [diff] [blame] | 750 | find_library(METAL_FRAMEWORK Metal) |
| 751 | set(OS_LIBS "${COCOA_FRAMEWORK}" "${QUARTZ_FRAMEWORK}" "${CORE_FOUNDATION_FRAMEWORK}" "${IOSURFACE_FRAMEWORK}" "${METAL_FRAMEWORK}") |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 752 | endif() |
| 753 | |
| 754 | ########################################################### |
Nicolas Capens | 5a105bc | 2015-12-22 22:04:28 -0500 | [diff] [blame] | 755 | # SwiftShader Targets |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 756 | ########################################################### |
| 757 | |
Antonio Maiorano | fa8f48d | 2020-03-30 16:41:48 -0400 | [diff] [blame] | 758 | add_subdirectory(src/Reactor) # Add ReactorSubzero and ReactorLLVM targets |
Nicolas Capens | e329f01 | 2020-03-13 14:54:21 +0000 | [diff] [blame] | 759 | |
Ben Clayton | b99bc1f | 2019-04-15 13:56:08 -0400 | [diff] [blame] | 760 | if(${REACTOR_BACKEND} STREQUAL "LLVM") |
Nicolas Capens | f53adbd | 2017-01-06 12:47:46 -0500 | [diff] [blame] | 761 | set(Reactor ReactorLLVM) |
| 762 | elseif(${REACTOR_BACKEND} STREQUAL "Subzero") |
| 763 | set(Reactor ReactorSubzero) |
| 764 | else() |
| 765 | message(FATAL_ERROR "REACTOR_BACKEND must be 'LLVM' or 'Subzero'") |
| 766 | endif() |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 767 | |
Antonio Maiorano | 4ce6a88 | 2020-04-06 16:16:21 -0400 | [diff] [blame] | 768 | add_subdirectory(src/Common) # Add gl_common target |
| 769 | add_subdirectory(src/Main) # Add gl_main target |
| 770 | add_subdirectory(src/Shader) # Add gl_shader target |
| 771 | add_subdirectory(src/Renderer) # Add gl_renderer target |
| 772 | |
| 773 | # Combine all gl_* targets into an interface target |
| 774 | # along with other dependencies |
| 775 | add_library(gl_swiftshader_core INTERFACE) |
| 776 | target_link_libraries(gl_swiftshader_core INTERFACE |
| 777 | # Transitively depends on shader, main, core, Reactor, |
| 778 | # OS_LIBS and SWIFTSHADER_LIBS |
| 779 | gl_renderer |
| 780 | ) |
| 781 | |
Antonio Maiorano | a71aff2 | 2020-04-07 10:09:41 -0400 | [diff] [blame] | 782 | add_subdirectory(src/OpenGL/common EXCLUDE_FROM_ALL) # Add libGLESCommon target |
| 783 | add_subdirectory(src/OpenGL/compiler EXCLUDE_FROM_ALL) # Add GLCompiler target |
Nicolas Capens | 6f42209 | 2015-12-23 15:12:45 -0500 | [diff] [blame] | 784 | |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 785 | if(SWIFTSHADER_BUILD_EGL) |
Antonio Maiorano | a71aff2 | 2020-04-07 10:09:41 -0400 | [diff] [blame] | 786 | add_subdirectory(src/OpenGL/libEGL) # Add libEGL target |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 787 | endif() |
| 788 | |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 789 | if(SWIFTSHADER_BUILD_GLESv2) |
Antonio Maiorano | a71aff2 | 2020-04-07 10:09:41 -0400 | [diff] [blame] | 790 | add_subdirectory(src/OpenGL/libGLESv2) # Add libGLESv2 target |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 791 | endif() |
| 792 | |
Sean Risser | f6d3cbb | 2020-01-08 14:44:53 -0500 | [diff] [blame] | 793 | if(SWIFTSHADER_BUILD_VULKAN) |
Dan Sinclair | 6480d4e | 2019-03-11 10:48:19 -0400 | [diff] [blame] | 794 | if (NOT TARGET SPIRV-Tools) |
| 795 | # This variable is also used by SPIRV-Tools to locate SPIRV-Headers |
Ben Clayton | afb4ebd | 2019-12-02 19:33:17 +0000 | [diff] [blame] | 796 | set(SPIRV-Headers_SOURCE_DIR "${THIRD_PARTY_DIR}/SPIRV-Headers") |
Antonio Maiorano | 8f02f58 | 2020-03-31 11:01:43 -0400 | [diff] [blame] | 797 | set(SPIRV_SKIP_TESTS TRUE CACHE BOOL "" FORCE) |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 798 | add_subdirectory(${THIRD_PARTY_DIR}/SPIRV-Tools) # Add SPIRV-Tools target |
Ben Clayton | 1e8486b | 2020-01-22 17:01:52 +0000 | [diff] [blame] | 799 | endif() |
Nicolas Capens | 4c9f04b | 2019-01-31 22:09:03 -0500 | [diff] [blame] | 800 | |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 801 | # Add a vk_base interface library for shared vulkan build options. |
| 802 | # TODO: Create src/Base and make this a lib target, and move stuff from |
| 803 | # src/Vulkan into it that is needed by vk_pipeline, vk_device, and vk_wsi. |
| 804 | add_library(vk_base INTERFACE) |
Ben Clayton | 4cdbb54 | 2020-04-14 22:51:50 +0100 | [diff] [blame] | 805 | |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 806 | if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER) |
| 807 | target_compile_definitions(vk_base INTERFACE "ENABLE_VK_DEBUGGER") |
David 'Digit' Turner | d371793 | 2019-11-19 17:54:00 +0100 | [diff] [blame] | 808 | endif() |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 809 | |
Nicolas Capens | d354537 | 2019-08-09 13:59:18 -0400 | [diff] [blame] | 810 | if(WIN32) |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 811 | target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_WIN32_KHR") |
Nicolas Capens | d354537 | 2019-08-09 13:59:18 -0400 | [diff] [blame] | 812 | elseif(LINUX) |
Ben Clayton | a9af883 | 2019-08-14 13:09:43 +0100 | [diff] [blame] | 813 | if(X11) |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 814 | target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_XLIB_KHR") |
Ben Clayton | 1e8486b | 2020-01-22 17:01:52 +0000 | [diff] [blame] | 815 | endif() |
Ben Clayton | a9af883 | 2019-08-14 13:09:43 +0100 | [diff] [blame] | 816 | if(XCB) |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 817 | target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_XCB_KHR") |
Ben Clayton | 1e8486b | 2020-01-22 17:01:52 +0000 | [diff] [blame] | 818 | endif() |
Nicolas Caramelli | a681d12 | 2020-07-20 23:47:56 +0200 | [diff] [blame] | 819 | if(SWIFTSHADER_BUILD_WSI_WAYLAND) |
| 820 | if(WAYLAND) |
| 821 | target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_WAYLAND_KHR") |
| 822 | endif() |
| 823 | endif(SWIFTSHADER_BUILD_WSI_WAYLAND) |
Nicolas Caramelli | 08596c4 | 2020-08-01 07:55:00 +0200 | [diff] [blame] | 824 | if(SWIFTSHADER_BUILD_WSI_DIRECTFB) |
| 825 | if(DIRECTFB AND DIRECTFB_INCLUDE_DIR) |
| 826 | target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_DIRECTFB_EXT") |
| 827 | endif() |
| 828 | endif(SWIFTSHADER_BUILD_WSI_DIRECTFB) |
Nicolas Caramelli | 937395c | 2021-01-06 21:00:18 +0100 | [diff] [blame] | 829 | if(SWIFTSHADER_BUILD_WSI_D2D) |
| 830 | if(D2D) |
| 831 | target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_DISPLAY_KHR") |
| 832 | endif() |
| 833 | endif(SWIFTSHADER_BUILD_WSI_D2D) |
Nicolas Capens | d354537 | 2019-08-09 13:59:18 -0400 | [diff] [blame] | 834 | elseif(APPLE) |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 835 | target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_MACOS_MVK") |
David 'Digit' Turner | d371793 | 2019-11-19 17:54:00 +0100 | [diff] [blame] | 836 | elseif(FUCHSIA) |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 837 | target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_FUCHSIA") |
Nicolas Capens | 29a9809 | 2019-04-03 14:35:10 -0400 | [diff] [blame] | 838 | else() |
| 839 | message(FATAL_ERROR "Platform does not support Vulkan yet") |
Nicolas Capens | d354537 | 2019-08-09 13:59:18 -0400 | [diff] [blame] | 840 | endif() |
| 841 | |
Antonio Maiorano | 9418b51 | 2020-04-08 23:18:13 -0400 | [diff] [blame] | 842 | add_subdirectory(src/System) # Add vk_system target |
| 843 | add_subdirectory(src/Pipeline) # Add vk_pipeline target |
| 844 | add_subdirectory(src/WSI) # Add vk_wsi target |
| 845 | add_subdirectory(src/Device) # Add vk_device target |
| 846 | add_subdirectory(src/Vulkan) # Add vk_swiftshader target |
Ben Clayton | ac73612 | 2020-03-24 17:48:31 +0000 | [diff] [blame] | 847 | |
Ben Clayton | 6ce626b | 2020-05-05 12:39:23 +0100 | [diff] [blame] | 848 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND # turbo-cov is only useful for clang coverage info |
Ben Clayton | 6ce626b | 2020-05-05 12:39:23 +0100 | [diff] [blame] | 849 | SWIFTSHADER_EMIT_COVERAGE) |
Antonio Maiorano | 2430d66 | 2020-04-14 17:04:36 -0400 | [diff] [blame] | 850 | add_subdirectory(${TESTS_DIR}/regres/cov/turbo-cov) |
Ben Clayton | ac73612 | 2020-03-24 17:48:31 +0000 | [diff] [blame] | 851 | endif() |
| 852 | |
Nicolas Capens | 29a9809 | 2019-04-03 14:35:10 -0400 | [diff] [blame] | 853 | endif() |
Chris Forbes | 3d27f2e | 2018-09-26 09:24:39 -0700 | [diff] [blame] | 854 | |
Antonio Maiorano | 4e39779 | 2020-07-27 15:14:52 -0400 | [diff] [blame] | 855 | if(SWIFTSHADER_BUILD_ANGLE) |
| 856 | add_subdirectory(${THIRD_PARTY_DIR}/angle) |
| 857 | |
| 858 | # Make angle depend on vk_swiftshader so we can test SWANGLE |
| 859 | if (TARGET vk_swiftshader) |
| 860 | add_dependencies(angle vk_swiftshader) |
| 861 | endif() |
| 862 | endif() |
| 863 | |
| 864 | |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 865 | ########################################################### |
Nicolas Capens | 29a9809 | 2019-04-03 14:35:10 -0400 | [diff] [blame] | 866 | # Sample programs and tests |
Corentin Wallez | 0866b29 | 2015-12-09 13:49:40 -0500 | [diff] [blame] | 867 | ########################################################### |
| 868 | |
Antonio Maiorano | 79248ab | 2020-07-23 11:24:33 -0400 | [diff] [blame] | 869 | # TODO(b/161976310): Add support for building PowerVR on MacOS |
| 870 | if(APPLE AND HAVE_PVR_SUBMODULE AND SWIFTSHADER_BUILD_PVR) |
| 871 | message(WARNING "Building PowerVR examples for SwiftShader is not yet supported on Apple platforms.") |
| 872 | set(SWIFTSHADER_BUILD_PVR FALSE) |
| 873 | endif() |
| 874 | |
Nicolas Capens | 13943ba | 2020-03-17 22:36:24 -0400 | [diff] [blame] | 875 | if(HAVE_PVR_SUBMODULE AND SWIFTSHADER_BUILD_PVR) |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 876 | if(UNIX AND NOT APPLE) |
| 877 | set(PVR_WINDOW_SYSTEM XCB) |
Nicolas Capens | 7e85709 | 2020-03-06 13:21:10 -0500 | [diff] [blame] | 878 | |
| 879 | # Set the RPATH of the next defined build targets to $ORIGIN, |
| 880 | # allowing them to load shared libraries from the execution directory. |
| 881 | set(CMAKE_BUILD_RPATH "$ORIGIN") |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 882 | endif() |
| 883 | |
Nicolas Capens | 13943ba | 2020-03-17 22:36:24 -0400 | [diff] [blame] | 884 | set(PVR_BUILD_EXAMPLES TRUE CACHE BOOL "Build the PowerVR SDK Examples" FORCE) |
Antonio Maiorano | da4315d | 2020-04-15 13:49:56 -0400 | [diff] [blame] | 885 | add_subdirectory(${THIRD_PARTY_DIR}/PowerVR_Examples) |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 886 | |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 887 | # Samples known to work well |
| 888 | set(PVR_VULKAN_TARGET_GOOD |
| 889 | VulkanBumpmap |
Nicolas Capens | 3702e01 | 2020-03-30 09:08:47 -0400 | [diff] [blame] | 890 | VulkanExampleUI |
| 891 | VulkanGaussianBlur |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 892 | VulkanGlass |
| 893 | VulkanGnomeHorde |
| 894 | VulkanHelloAPI |
| 895 | VulkanImageBasedLighting |
Nicolas Capens | 3702e01 | 2020-03-30 09:08:47 -0400 | [diff] [blame] | 896 | VulkanIntroducingPVRUtils |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 897 | VulkanMultiSampling |
Nicolas Capens | 3702e01 | 2020-03-30 09:08:47 -0400 | [diff] [blame] | 898 | VulkanNavigation2D |
| 899 | VulkanParticleSystem |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 900 | VulkanSkinning |
| 901 | ) |
| 902 | |
Nicolas Capens | 3702e01 | 2020-03-30 09:08:47 -0400 | [diff] [blame] | 903 | set(PVR_GLES_TARGET_GOOD |
| 904 | OpenGLESHelloAPI |
| 905 | OpenGLESIntroducingPVRUtils |
| 906 | OpenGLESNavigation2D |
| 907 | ) |
| 908 | |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 909 | set(PVR_VULKAN_TARGET_OTHER |
| 910 | VulkanDeferredShading |
| 911 | VulkanDeferredShadingPFX |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 912 | VulkanGameOfLife |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 913 | VulkanIBLMapsGenerator |
| 914 | VulkanIMGTextureFilterCubic |
| 915 | VulkanIntroducingPVRShell |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 916 | VulkanIntroducingPVRVk |
| 917 | VulkanIntroducingUIRenderer |
| 918 | VulkanMultithreading |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 919 | VulkanNavigation3D |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 920 | VulkanPostProcessing |
| 921 | VulkanPVRScopeExample |
| 922 | VulkanPVRScopeRemote |
| 923 | ) |
| 924 | |
Nicolas Capens | 3702e01 | 2020-03-30 09:08:47 -0400 | [diff] [blame] | 925 | set(PVR_GLES_TARGET_OTHER |
| 926 | OpenGLESDeferredShading |
| 927 | OpenGLESGaussianBlur |
| 928 | OpenGLESImageBasedLighting |
| 929 | OpenGLESIMGFramebufferDownsample |
| 930 | OpenGLESIMGTextureFilterCubic |
| 931 | OpenGLESIntroducingPVRCamera |
| 932 | OpenGLESIntroducingPVRShell |
| 933 | OpenGLESIntroducingUIRenderer |
| 934 | OpenGLESMultiviewVR |
| 935 | OpenGLESNavigation3D |
| 936 | OpenGLESOpenCLExample |
| 937 | OpenGLESParticleSystem |
| 938 | OpenGLESPostProcessing |
| 939 | OpenGLESPVRScopeExample |
| 940 | OpenGLESPVRScopeRemote |
| 941 | OpenGLESSkinning |
| 942 | ) |
| 943 | |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 944 | set(PVR_TARGET_OTHER |
| 945 | glslang |
| 946 | glslangValidator |
| 947 | glslang-default-resource-limits |
| 948 | OGLCompiler |
| 949 | OSDependent |
| 950 | OpenCLMatrixMultiplication |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 951 | pugixml |
| 952 | PVRAssets |
| 953 | PVRCamera |
| 954 | PVRCore |
| 955 | PVRPfx |
| 956 | PVRShell |
| 957 | PVRUtilsGles |
| 958 | PVRUtilsVk |
| 959 | PVRVk |
| 960 | SPIRV |
| 961 | spirv-remap |
| 962 | SPVRemapper |
| 963 | uninstall |
| 964 | ) |
| 965 | |
| 966 | set(PVR_VULKAN_TARGET |
| 967 | ${PVR_VULKAN_TARGET_GOOD} |
| 968 | ${PVR_VULKAN_TARGET_OTHER} |
| 969 | ) |
| 970 | |
Nicolas Capens | 3702e01 | 2020-03-30 09:08:47 -0400 | [diff] [blame] | 971 | set(PVR_GLES_TARGET |
| 972 | ${PVR_GLES_TARGET_GOOD} |
| 973 | ${PVR_GLES_TARGET_OTHER} |
| 974 | ) |
| 975 | |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 976 | foreach(pvr_target ${PVR_VULKAN_TARGET}) |
| 977 | add_dependencies(${pvr_target} vk_swiftshader) |
| 978 | endforeach() |
| 979 | |
Nicolas Capens | 3702e01 | 2020-03-30 09:08:47 -0400 | [diff] [blame] | 980 | foreach(pvr_target ${PVR_GLES_TARGET}) |
| 981 | add_dependencies(${pvr_target} libGLESv2) |
| 982 | add_dependencies(${pvr_target} libEGL) |
| 983 | endforeach() |
| 984 | |
| 985 | foreach(pvr_target ${PVR_VULKAN_TARGET_GOOD} ${PVR_GLES_TARGET_GOOD}) |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 986 | set_target_properties(${pvr_target} PROPERTIES FOLDER Samples) |
| 987 | endforeach() |
| 988 | |
Nicolas Capens | 3702e01 | 2020-03-30 09:08:47 -0400 | [diff] [blame] | 989 | foreach(pvr_target ${PVR_TARGET_OTHER} ${PVR_VULKAN_TARGET_OTHER} ${PVR_GLES_TARGET_OTHER}) |
Nicolas Capens | 51b2800 | 2020-01-30 16:41:00 -0500 | [diff] [blame] | 990 | set_target_properties(${pvr_target} PROPERTIES FOLDER Samples/PowerVR-Build) |
| 991 | endforeach() |
Antonio Maiorano | 4e39779 | 2020-07-27 15:14:52 -0400 | [diff] [blame] | 992 | |
| 993 | # Make angle target depend on PowerVR GL examples |
| 994 | if (TARGET angle) |
| 995 | foreach(pvr_target ${PVR_GLES_TARGET}) |
| 996 | add_dependencies(angle ${pvr_target}) |
| 997 | endforeach() |
| 998 | endif() |
Corentin Wallez | cb58662 | 2020-03-27 17:38:29 +0100 | [diff] [blame] | 999 | endif() |
Nicolas Capens | f324fe5 | 2020-06-05 16:10:07 -0400 | [diff] [blame] | 1000 | |
Antonio Maiorano | 9d35d54 | 2021-02-01 16:35:07 -0500 | [diff] [blame] | 1001 | if(BUILD_VULKAN_WRAPPER) |
| 1002 | if (NOT TARGET glslang) |
| 1003 | add_subdirectory(${THIRD_PARTY_DIR}/glslang) |
| 1004 | endif() |
| 1005 | add_subdirectory(${TESTS_DIR}/VulkanWrapper) # Add VulkanWrapper target |
| 1006 | endif() |
| 1007 | |
Nicolas Capens | f324fe5 | 2020-06-05 16:10:07 -0400 | [diff] [blame] | 1008 | if(SWIFTSHADER_BUILD_TESTS) |
| 1009 | add_subdirectory(${TESTS_DIR}/ReactorUnitTests) # Add ReactorUnitTests target |
| 1010 | add_subdirectory(${TESTS_DIR}/GLESUnitTests) # Add gles-unittests target |
| 1011 | add_subdirectory(${TESTS_DIR}/MathUnitTests) # Add math-unittests target |
| 1012 | add_subdirectory(${TESTS_DIR}/SystemUnitTests) # Add system-unittests target |
| 1013 | endif() |
| 1014 | |
| 1015 | if(SWIFTSHADER_BUILD_BENCHMARKS) |
| 1016 | if (NOT TARGET benchmark::benchmark) |
| 1017 | set(BENCHMARK_ENABLE_TESTING FALSE CACHE BOOL FALSE FORCE) |
| 1018 | add_subdirectory(${THIRD_PARTY_DIR}/benchmark) |
Antonio Maiorano | 0f14b7a | 2020-09-11 10:02:16 -0400 | [diff] [blame] | 1019 | set_target_properties(benchmark PROPERTIES FOLDER "third_party") |
| 1020 | set_target_properties(benchmark_main PROPERTIES FOLDER "third_party") |
Nicolas Capens | f324fe5 | 2020-06-05 16:10:07 -0400 | [diff] [blame] | 1021 | endif() |
| 1022 | |
| 1023 | add_subdirectory(${TESTS_DIR}/ReactorBenchmarks) # Add ReactorBenchmarks target |
| 1024 | add_subdirectory(${TESTS_DIR}/SystemBenchmarks) # Add system-benchmarks target |
| 1025 | add_subdirectory(${TESTS_DIR}/VulkanBenchmarks) # Add VulkanBenchmarks target |
| 1026 | endif() |
| 1027 | |
| 1028 | if(SWIFTSHADER_BUILD_TESTS AND SWIFTSHADER_BUILD_VULKAN) |
| 1029 | add_subdirectory(${TESTS_DIR}/VulkanUnitTests) # Add VulkanUnitTests target |
| 1030 | endif() |