mirrored from https://projects.blender.org/blender/cycles.git
-
Notifications
You must be signed in to change notification settings - Fork 75
/
CMakeLists.txt
250 lines (204 loc) · 8.52 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
###########################################################################
# Disable insource build
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
"CMake generation for Cycles is not allowed within the source directory!"
"\n Remove the CMakeCache.txt file and try again from another folder, e.g.:"
"\n "
"\n rm CMakeCache.txt"
"\n cd .."
"\n mkdir cmake-make"
"\n cd cmake-make"
"\n cmake ../cycles"
)
endif()
###########################################################################
# Policies
cmake_minimum_required(VERSION 3.10)
# So library linking is more sane.
if(POLICY CMP0003)
cmake_policy(SET CMP0003 NEW)
endif()
# So syntax problems are errors.
if(POLICY CMP0010)
cmake_policy(SET CMP0010 NEW)
endif()
# So BUILDINFO and BLENDERPATH strings are automatically quoted.
if(POLICY CMP0005)
cmake_policy(SET CMP0005 NEW)
endif()
# Input directories must have CMakeLists.txt
if(POLICY CMP0014)
cmake_policy(SET CMP0014 NEW)
endif()
# Compile definitions.
if(POLICY CMP0043)
cmake_policy(SET CMP0043 NEW)
endif()
# Use ROOT variables in find_package.
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
if(POLICY CMP0144)
cmake_policy(SET CMP0144 NEW)
endif()
# Avoid having empty buildtype.
set(CMAKE_BUILD_TYPE_INIT "Release")
###########################################################################
# Initialize project.
project(Cycles)
###########################################################################
# Macros and utilities.
list(APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/src/cmake"
"${PROJECT_SOURCE_DIR}/src/cmake/Modules"
)
include(compiler_utils)
include(macros)
###########################################################################
# Global settings.
set(CMAKE_INSTALL_MESSAGE LAZY)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE PATH "Installation path" FORCE)
endif()
# Effective install path including config folder, as a generator expression.
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(GENERATOR_IS_MULTI_CONFIG)
string(REPLACE "\${BUILD_TYPE}" "$<CONFIG>" CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX})
else()
string(REPLACE "\${BUILD_TYPE}" "" CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX})
endif()
# Some stuff is different when building stabdalone Cycles from inside
# Blender source code and when building it from it's own repository.
set(CYCLES_STANDALONE_REPOSITORY TRUE)
# Force standalone build.
set(WITH_CYCLES_STANDALONE TRUE)
# Global compile definitions since add_definitions() adds for all.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:Debug>:DEBUG;_DEBUG>
$<$<CONFIG:Release>:NDEBUG>
$<$<CONFIG:MinSizeRel>:NDEBUG>
$<$<CONFIG:RelWithDebInfo>:NDEBUG>
)
###########################################################################
# Options.
# Use precompiled library dependencies
option(WITH_LIBS_PRECOMPILED "Use precompiled library dependencies" ON)
# Library dependencies
option(WITH_CYCLES_ALEMBIC "Build with Alembic procedural support" ON)
option(WITH_CYCLES_EMBREE "Build with Embree support" ON)
option(WITH_CYCLES_LOGGING "Build with logging support (using glog)" OFF)
option(WITH_CYCLES_OPENCOLORIO "Build with OpenColorIO support" ON)
option(WITH_CYCLES_OPENIMAGEDENOISE "Build with OpenImageDenoise support" ON)
option(WITH_CYCLES_OPENSUBDIV "Build with OpenSubdiv support" ON)
option(WITH_CYCLES_OPENVDB "Build with OpenVDB support" ON)
option(WITH_CYCLES_NANOVDB "Build with NanoVDB support" ON)
option(WITH_CYCLES_OSL "Build with OSL support" ON)
option(WITH_CYCLES_USD "Build with USD support" ON)
if(UNIX AND NOT APPLE)
option(WITH_CXX11_ABI "Build with glibc C++11 ABI. Turn off for compatibility with VFX platform 2022 and earlier." ON)
endif()
# Development Features
option(WITH_CYCLES_DEBUG "Build Cycles with options useful for debugging (e.g., MIS)" OFF)
option(WITH_CYCLES_DEBUG_NAN "Build Cycles with additional asserts for detecting NaNs and invalid values" OFF)
option(WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF)
option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
# NVIDIA CUDA & OptiX
if(NOT APPLE AND NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64"))
option(WITH_CYCLES_DEVICE_CUDA "Enable Cycles NVIDIA CUDA compute support" ON)
option(WITH_CYCLES_DEVICE_OPTIX "Enable Cycles NVIDIA OptiX support" ON)
mark_as_advanced(WITH_CYCLES_DEVICE_CUDA)
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles NVIDIA CUDA binaries" OFF)
set(CYCLES_CUDA_BINARIES_ARCH
sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 sm_89 compute_75
CACHE STRING "CUDA architectures to build binaries for"
)
option(WITH_CYCLES_CUDA_BUILD_SERIAL "\
Build cubins one after another (useful on machines with limited RAM)"
OFF
)
option(WITH_CUDA_DYNLOAD "\
Dynamically load CUDA libraries at runtime (for developers, makes cuda-gdb work)"
ON
)
set(OPTIX_ROOT_DIR "" CACHE PATH "\
Path to the OptiX SDK root directory, for building Cycles OptiX kernels."
)
set(CYCLES_RUNTIME_OPTIX_ROOT_DIR "" CACHE PATH "\
Path to the OptiX SDK root directory. \
When set, this path will be used at runtime to compile OptiX kernels."
)
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
mark_as_advanced(WITH_CUDA_DYNLOAD)
mark_as_advanced(OPTIX_ROOT_DIR)
mark_as_advanced(CYCLES_RUNTIME_OPTIX_ROOT_DIR)
endif()
# AMD HIP
if(NOT APPLE AND NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64"))
option(WITH_CYCLES_DEVICE_HIP "Enable Cycles AMD HIP support" ON)
option(WITH_CYCLES_HIP_BINARIES "Build Cycles AMD HIP binaries" OFF)
# Radeon VII (gfx906) not currently working with HIP SDK, so left out of the list.
set(CYCLES_HIP_BINARIES_ARCH
gfx900 gfx90c gfx902
gfx1010 gfx1011 gfx1012
gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 gfx1036
gfx1100 gfx1101 gfx1102 gfx1103 gfx1150 gfx1151
CACHE STRING "AMD HIP architectures to build binaries for"
)
mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
option(WITH_CYCLES_DEVICE_HIPRT "Enable Cycles AMD HIPRT support" OFF)
mark_as_advanced(WITH_CYCLES_DEVICE_HIPRT)
endif()
# Apple Metal
if(APPLE)
option(WITH_CYCLES_DEVICE_METAL "Enable Cycles Apple Metal compute support" ON)
endif()
# oneAPI
if(NOT APPLE AND NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64"))
option(WITH_CYCLES_DEVICE_ONEAPI "Enable Cycles oneAPI compute support" OFF)
option(WITH_CYCLES_ONEAPI_BINARIES "\
Enable Ahead-Of-Time compilation for Cycles oneAPI device"
OFF
)
option(WITH_CYCLES_ONEAPI_HOST_TASK_EXECUTION "\
Switch target of oneAPI implementation from SYCL devices to Host Task (single thread on CPU). \
This option is only for debugging purposes."
OFF
)
# https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compilation/ahead-of-time-compilation.html
# The target architectures levels can be retrieved from `ocloc` output when running
# `ocloc compile -device {device_id} test.c` for given GPUs PCI device IDs.
# 12.55.8 is for Arc Alchemist GPUs. 12.70.4 for Meteor Lake iGPUs.
set(CYCLES_ONEAPI_INTEL_BINARIES_ARCH 12.55.8 12.70.4 CACHE STRING "\
oneAPI Intel GPU architectures to build binaries for"
)
set(CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "\
oneAPI targets to build AOT binaries for"
)
mark_as_advanced(WITH_CYCLES_ONEAPI_HOST_TASK_EXECUTION)
mark_as_advanced(CYCLES_ONEAPI_INTEL_BINARIES_ARCH)
mark_as_advanced(CYCLES_ONEAPI_SYCL_TARGETS)
endif()
# Hydra Render Delegate
option(WITH_CYCLES_HYDRA_RENDER_DELEGATE "Build Cycles Hydra render delegate" ON)
# Error Checking
option(WITH_STRICT_BUILD_OPTIONS "When requirements for a build option are not met, error instead of disabling the option" OFF)
###########################################################################
# Configuration.
include(CheckCXXCompilerFlag)
include(detect_platform)
include(external_libs)
include(configure_build)
include(CTest)
###########################################################################
# Include directories.
include_directories(
third_party/cuew/include
third_party/hipew/include
)
###########################################################################
# Sources.
add_subdirectory(src)
add_subdirectory(third_party)