1 # SPDX-FileCopyrightText: 2006 Blender Authors
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # -----------------------------------------------------------------------------
8 # NOTE: We don't allow in-source builds. This causes no end of troubles because
9 # all out-of-source builds will use the CMakeCache.txt file there and even
10 # build the libs and objects in it.
11 if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
12 if(NOT DEFINED WITH_IN_SOURCE_BUILD)
14 "CMake generation for blender is not allowed within the source directory!"
15 "\n Remove \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" and try again from another folder, e.g.:"
17 "\n rm -rf CMakeCache.txt CMakeFiles"
23 "\n Alternately define WITH_IN_SOURCE_BUILD to force this option (not recommended!)"
28 cmake_minimum_required(VERSION 3.10)
30 if(NOT EXECUTABLE_OUTPUT_PATH)
36 # this starts out unset
37 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
38 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/platform")
40 # Avoid having an empty `CMAKE_BUILD_TYPE`.
41 if(NOT DEFINED CMAKE_BUILD_TYPE_INIT)
42 set(CMAKE_BUILD_TYPE_INIT "Release")
43 # Internal logic caches this variable, avoid showing it by default
44 # since it's easy to accidentally set instead of the build type.
46 mark_as_advanced(CMAKE_BUILD_TYPE_INIT)
48 # Omit superfluous "Up-to-date" messages.
49 if(NOT DEFINED CMAKE_INSTALL_MESSAGE)
50 set(CMAKE_INSTALL_MESSAGE "LAZY")
53 # quiet output for Makefiles, 'make -s' helps too
54 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
56 # Global compile definitions since add_definitions() adds for all.
57 # _DEBUG is a Visual Studio define, enabled for all platforms.
58 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
59 $<$<CONFIG:Debug>:_DEBUG>
61 # -----------------------------------------------------------------------------
64 # see "cmake --help-policy CMP0003"
65 # So library linking is more sane
66 cmake_policy(SET CMP0003 NEW)
68 # So BUILDINFO and BLENDERPATH strings are automatically quoted
69 cmake_policy(SET CMP0005 NEW)
71 # So syntax problems are errors
72 cmake_policy(SET CMP0010 NEW)
74 # Input directories must have CMakeLists.txt
75 cmake_policy(SET CMP0014 NEW)
77 # Silence draco warning on macOS, new policy works fine.
79 cmake_policy(SET CMP0068 NEW)
82 # find_package() uses <PackageName>_ROOT variables.
84 cmake_policy(SET CMP0074 NEW)
87 # Install CODE|SCRIPT allow the use of generator expressions.
89 cmake_policy(SET CMP0087 NEW)
93 # -----------------------------------------------------------------------------
94 # Load Blender's Local Macros
96 include(build_files/cmake/macros.cmake)
98 # -----------------------------------------------------------------------------
101 blender_project_hack_pre()
105 blender_project_hack_post()
110 # -----------------------------------------------------------------------------
111 # Test Compiler Support
113 # Keep in sync with: https://developer.blender.org/docs/handbook/building_blender/
115 if(CMAKE_COMPILER_IS_GNUCC)
116 if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "11.0.0")
117 message(FATAL_ERROR "\
118 The minimum supported version of GCC is 11.0.0, found ${CMAKE_C_COMPILER_VERSION}"
121 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
122 if(CMAKE_COMPILER_IS_GNUCC AND ("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "8.0"))
123 message(FATAL_ERROR "\
124 The minimum supported version of CLANG is 8.0, found ${CMAKE_C_COMPILER_VERSION}"
127 elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
128 if(MSVC_VERSION VERSION_LESS "1928")
129 # MSVC_VERSION is an internal version number, it doesn't map to something
130 # the end user would recognize as a version. Because of this, for MSVC we do
131 # not show the found number. When using our make.bat the actual VS version
132 # will be displayed on the console before starting the build, anyway.
133 message(FATAL_ERROR "The minimum supported version of MSVC is 2019 (16.9.16)")
137 # -----------------------------------------------------------------------------
138 # Test Compiler/Library Features
140 include(build_files/cmake/have_features.cmake)
143 # -----------------------------------------------------------------------------
144 # Redirect Output Files
146 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
147 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)
149 get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
150 if(GENERATOR_IS_MULTI_CONFIG)
151 set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/$<CONFIG>/ CACHE INTERNAL "" FORCE)
153 set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/ CACHE INTERNAL "" FORCE)
157 # -----------------------------------------------------------------------------
158 # Set Default Configuration Options
160 get_blender_version()
164 # This is the app ID used for file registration, given it's used from several modules
165 # there really is no nice way to get this information consistent without a global define.
166 -DBLENDER_WIN_APPID="blender.${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}"
167 # This is the name that will be shown in the taskbar and OpenWith windows UI
168 -DBLENDER_WIN_APPID_FRIENDLY_NAME="Blender ${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}"
173 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19")
174 # This changes the default value from Off to On, but will still allow people to manually change
175 # this setting through their CMakeCache.txt if they desire to do so.
176 set(CMAKE_OPTIMIZE_DEPENDENCIES ON CACHE INTERNAL "")
179 # -----------------------------------------------------------------------------
182 # Blender internal features
183 option(WITH_BLENDER "Build blender (disable to build only Cycles stand-alone)." ON)
184 mark_as_advanced(WITH_BLENDER)
187 option(WITH_BLENDER_THUMBNAILER "\
188 Build \"BlendThumb.dll\" helper for Windows explorer integration to support extracting \
189 thumbnails from `.blend` files."
193 set(_option_default ON)
195 # In future, can be used with `quicklookthumbnailing/qlthumbnailreply`
196 # to create file thumbnails for say Finder.
197 # Turn it off for now, even though it can build on APPLE, it's not likely to be useful.
198 set(_option_default OFF)
200 option(WITH_BLENDER_THUMBNAILER "\
201 Build stand-alone \"blender-thumbnailer\" command-line thumbnail extraction utility, \
202 intended for use by file-managers to extract PNG images from `.blend` files."
205 unset(_option_default)
208 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
210 option(WITH_PYTHON "Enable Embedded Python API (only disable for development)" ON)
211 option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON)
212 # Don't want people disabling this unless they really know what they are doing.
213 mark_as_advanced(WITH_PYTHON)
214 # Some distributions see this as a security issue, rather than have them patch it,
215 # make a build option.
216 mark_as_advanced(WITH_PYTHON_SECURITY)
218 option(WITH_PYTHON_SAFETY "\
219 Enable internal API error checking to track invalid data to prevent crash on access \
220 (at the expense of some efficiency, only enable for development)."
223 mark_as_advanced(WITH_PYTHON_SAFETY)
224 option(WITH_PYTHON_MODULE "\
225 Enable building as a python module which runs without a user interface, \
226 like running regular blender in background mode (only enable for development), \
227 installs to PYTHON_SITE_PACKAGES (or CMAKE_INSTALL_PREFIX if WITH_INSTALL_PORTABLE is enabled)."
231 option(WITH_BUILDINFO "\
232 Include extra build details (only disable for development & faster builds)"
235 set(BUILDINFO_OVERRIDE_DATE "" CACHE STRING "\
236 Use instead of the current date for reproducible builds (empty string disables this option)"
238 set(BUILDINFO_OVERRIDE_TIME "" CACHE STRING "\
239 Use instead of the current time for reproducible builds (empty string disables this option)"
241 set(CPACK_OVERRIDE_PACKAGENAME "" CACHE STRING "\
242 Use instead of the standard packagename (empty string disables this option)"
244 mark_as_advanced(CPACK_OVERRIDE_PACKAGENAME)
245 mark_as_advanced(BUILDINFO_OVERRIDE_DATE)
246 mark_as_advanced(BUILDINFO_OVERRIDE_TIME)
248 # CMAKE 3.28.2 has issues with the combination of PCH and unity builds, disable for now.
249 # upstream ticket https://gitlab.kitware.com/cmake/cmake/-/issues/25650
250 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16" AND NOT ${CMAKE_VERSION} VERSION_EQUAL "3.28.2")
251 option(WITH_UNITY_BUILD "\
252 Enable unity build for modules that support it to improve compile times.\n\
253 WARNING: this option allows files to be built without all necessary headers!\n
254 This option should be disabled before manipulating or removing headers."
257 mark_as_advanced(WITH_UNITY_BUILD)
259 set(WITH_UNITY_BUILD OFF)
262 option(WITH_IK_ITASC "\
263 Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)"
266 option(WITH_IK_SOLVER "\
267 Enable Legacy IK solver (only disable for development)"
270 option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ON)
271 option(WITH_PUGIXML "Enable PugiXML support (Used for OpenImageIO, Grease Pencil SVG export)" ON)
272 option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
273 option(WITH_SYSTEM_BULLET "\
274 Use the systems bullet library (currently unsupported due to missing features in upstream!)"
277 mark_as_advanced(WITH_SYSTEM_BULLET)
278 option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ON)
280 set(_option_default ON)
282 # There's no OpenXR runtime in sight for macOS, neither is code well
283 # tested there -> disable it by default.
284 set(_option_default OFF)
286 option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" ${_option_default})
288 mark_as_advanced(WITH_XR_OPENXR)
290 unset(_option_default)
292 option(WITH_GMP "Enable features depending on GMP (Exact Boolean)" ON)
295 option(WITH_COMPOSITOR_CPU "Enable the tile based CPU nodal compositor" ON)
296 option(WITH_OPENIMAGEDENOISE "Enable the OpenImageDenoise compositing node" ON)
298 option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" ON)
300 option(WITH_POTRACE "Enable features relying on potrace" ON)
301 option(WITH_OPENVDB "Enable features relying on OpenVDB" ON)
302 option(WITH_OPENVDB_BLOSC "\
303 Enable blosc compression for OpenVDB, only enable if OpenVDB was built with blosc support"
306 option(WITH_OPENVDB_3_ABI_COMPATIBLE "\
307 Assume OpenVDB library has been compiled with version 3 ABI compatibility"
310 mark_as_advanced(WITH_OPENVDB_3_ABI_COMPATIBLE)
311 option(WITH_NANOVDB "Enable usage of NanoVDB data structure for rendering on the GPU" ON)
312 option(WITH_HARU "Enable features relying on Libharu (Grease pencil PDF export)" ON)
314 # GHOST Windowing Library Options
315 option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF)
316 mark_as_advanced(WITH_GHOST_DEBUG)
318 option(WITH_GHOST_SDL "\
319 Enable building Blender against SDL for windowing rather than the native APIs"
322 mark_as_advanced(WITH_GHOST_SDL)
324 if(UNIX AND NOT (APPLE OR HAIKU))
325 option(WITH_GHOST_X11 "Enable building Blender against X11 for windowing" ON)
326 mark_as_advanced(WITH_GHOST_X11)
328 option(WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing" ON)
329 mark_as_advanced(WITH_GHOST_WAYLAND)
331 if(WITH_GHOST_WAYLAND)
332 option(WITH_GHOST_WAYLAND_LIBDECOR "Optionally build with LibDecor window decorations" ON)
333 mark_as_advanced(WITH_GHOST_WAYLAND_LIBDECOR)
335 option(WITH_GHOST_WAYLAND_DYNLOAD "Enable runtime dynamic WAYLAND libraries loading" ON)
336 mark_as_advanced(WITH_GHOST_WAYLAND_DYNLOAD)
338 set(WITH_GHOST_WAYLAND_APP_ID "" CACHE STRING "\
339 The application ID used for Blender (use default when an empty string), \
340 this can be used to differentiate Blender instances by version or branch for example."
342 mark_as_advanced(WITH_GHOST_WAYLAND_APP_ID)
347 option(WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON)
351 option(WITH_HEADLESS "Build without graphical support (renderfarm, server mode only)" OFF)
352 mark_as_advanced(WITH_HEADLESS)
354 option(WITH_QUADRIFLOW "Build with quadriflow remesher support" ON)
356 option(WITH_AUDASPACE "\
357 Build with blenders audio library (only disable if you know what you're doing!)"
360 option(WITH_SYSTEM_AUDASPACE "\
361 Build with external audaspace library installed on the system \
362 (only enable if you know what you're doing!)"
365 mark_as_advanced(WITH_AUDASPACE)
366 mark_as_advanced(WITH_SYSTEM_AUDASPACE)
368 set_and_warn_dependency(WITH_AUDASPACE WITH_SYSTEM_AUDASPACE OFF)
370 option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON)
371 if(UNIX AND NOT APPLE)
372 option(WITH_OPENMP_STATIC "Link OpenMP statically (only used by the release environment)" OFF)
373 mark_as_advanced(WITH_OPENMP_STATIC)
377 option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
378 option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON)
379 option(WITH_X11_XFIXES "Enable X11 XWayland cursor warping workaround" ON)
382 if(UNIX AND NOT APPLE)
383 option(WITH_SYSTEM_FREETYPE "Use the freetype library provided by the operating system" OFF)
384 option(WITH_SYSTEM_EIGEN3 "Use the systems Eigen3 library" OFF)
386 set(WITH_SYSTEM_FREETYPE OFF)
387 set(WITH_SYSTEM_EIGEN3 OFF)
392 option(WITH_MOD_FLUID "Enable Mantaflow Fluid Simulation Framework" ON)
393 option(WITH_MOD_REMESH "Enable Remesh Modifier" ON)
394 option(WITH_MOD_OCEANSIM "Enable Ocean Modifier" ON)
396 # Image format support
397 option(WITH_IMAGE_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON)
398 option(WITH_IMAGE_OPENJPEG "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
399 option(WITH_IMAGE_CINEON "Enable CINEON and DPX Image Support" ON)
400 option(WITH_IMAGE_WEBP "Enable WebP Image Support" ON)
402 # Audio/Video format support
403 option(WITH_CODEC_AVI "Enable Blenders own AVI file support (raw/jpeg)" ON)
404 option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" ON)
405 option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" ON)
408 option(WITH_ALEMBIC "Enable Alembic Support" ON)
410 # Universal Scene Description support
411 option(WITH_USD "Enable Universal Scene Description (USD) Support" ON)
414 option(WITH_MATERIALX "Enable MaterialX Support" ON)
416 # Hydra render engine
417 option(WITH_HYDRA "Enable Hydra render engine" ON)
419 # RTL Languages, Complex Shaping, OpenType Features
420 option(WITH_FRIBIDI "Enable features relying on fribidi" OFF)
421 option(WITH_HARFBUZZ "Enable features relying on harfbuzz" OFF)
424 # Disable opencollada when we don't have precompiled libs
425 option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ON)
426 option(WITH_IO_WAVEFRONT_OBJ "Enable Wavefront-OBJ 3D file format support (*.obj)" ON)
427 option(WITH_IO_PLY "Enable PLY 3D file format support (*.ply)" ON)
428 option(WITH_IO_STL "Enable STL 3D file format support (*.stl)" ON)
429 option(WITH_IO_GPENCIL "Enable grease-pencil file format IO (*.svg, *.pdf)" ON)
432 option(WITH_SDL "Enable SDL for sound" ON)
433 option(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON)
435 option(WITH_COREAUDIO "Enable CoreAudio for audio support on macOS" ON)
437 set(WITH_COREAUDIO OFF)
440 set(_option_default ON)
442 set(_option_default OFF)
444 option(WITH_JACK "Enable JACK Support (http://www.jackaudio.org)" ${_option_default})
445 unset(_option_default)
446 option(WITH_JACK_DYNLOAD "Enable runtime dynamic JACK libraries loading" OFF)
450 if(UNIX AND NOT APPLE)
451 option(WITH_SDL_DYNLOAD "Enable runtime dynamic SDL libraries loading" OFF)
453 if(UNIX AND NOT APPLE)
454 option(WITH_PULSEAUDIO "Enable PulseAudio for audio support on Linux" ON)
455 option(WITH_PULSEAUDIO_DYNLOAD "Enable runtime dynamic PulseAudio libraries loading" OFF)
457 set(WITH_PULSEAUDIO OFF)
460 option(WITH_WASAPI "Enable Windows Audio Sessions API for audio support on Windows" ON)
466 option(WITH_LZO "Enable fast LZO compression (used for pointcache)" ON)
467 option(WITH_LZMA "Enable best LZMA compression, (used for pointcache)" ON)
468 if(UNIX AND NOT APPLE)
469 option(WITH_SYSTEM_LZO "Use the system LZO library" OFF)
471 option(WITH_DRACO "Enable Draco mesh compression Python module (used for glTF)" ON)
473 # Camera/motion tracking
474 option(WITH_LIBMV "Enable Libmv structure from motion library" ON)
475 option(WITH_LIBMV_SCHUR_SPECIALIZATIONS "Enable fixed-size schur specializations." ON)
476 mark_as_advanced(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
478 # Logging/unbit test libraries.
479 option(WITH_SYSTEM_GFLAGS "Use system-wide Gflags instead of a bundled one" OFF)
480 option(WITH_SYSTEM_GLOG "Use system-wide Glog instead of a bundled one" OFF)
481 mark_as_advanced(WITH_SYSTEM_GFLAGS)
482 mark_as_advanced(WITH_SYSTEM_GLOG)
485 option(WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON)
488 if(UNIX AND NOT APPLE)
489 # Optionally build without pre-compiled libraries.
490 # NOTE: this could be supported on all platforms however in practice UNIX is the only platform
491 # that has good support for detecting installed libraries.
492 option(WITH_LIBS_PRECOMPILED "\
493 Detect and link against pre-compiled libraries (typically found under \"../lib/\"). \
494 Disabling this option will use the system libraries although cached paths \
495 that point to pre-compiled libraries will be left as-is."
498 mark_as_advanced(WITH_LIBS_PRECOMPILED)
500 option(WITH_STATIC_LIBS "\
501 Try to link with static libraries, as much as possible, \
502 to make blender more portable across distributions"
506 option(WITH_BOOST_ICU "\
507 Boost uses ICU library (required for linking with static Boost built with libicu)."
510 mark_as_advanced(WITH_BOOST_ICU)
515 if(WIN32 OR APPLE OR ((UNIX AND (NOT HAIKU)) AND WITH_GHOST_WAYLAND))
516 option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
518 set(WITH_INPUT_IME OFF)
520 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ON)
521 # On Windows and for the Blender application on macOS, portable install
522 # is the only supported installation type, so there is no option.
523 if(UNIX AND (NOT APPLE OR WITH_PYTHON_MODULE))
524 option(WITH_INSTALL_PORTABLE "\
525 Install redistributable runtime, otherwise install into CMAKE_INSTALL_PREFIX"
530 option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
532 option(WITH_INSTALL_COPYRIGHT "\
533 Copy the official Blender Authors's copyright.txt into the Blender install folder"
536 mark_as_advanced(WITH_INSTALL_COPYRIGHT)
538 if((WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE) OR WITH_MOD_FLUID)
539 option(WITH_PYTHON_NUMPY "Include NumPy in Blender (used by Audaspace and Mantaflow)" ON)
543 # Windows and macOS have this bundled with Python libraries.
544 elseif(WITH_PYTHON_INSTALL OR WITH_PYTHON_NUMPY)
545 set(PYTHON_NUMPY_PATH "" CACHE PATH "\
546 Path to python site-packages or dist-packages containing 'numpy' module"
548 mark_as_advanced(PYTHON_NUMPY_PATH)
549 set(PYTHON_NUMPY_INCLUDE_DIRS "" CACHE PATH "Path to the include directory of the NumPy module")
550 mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
552 if(WITH_PYTHON_INSTALL)
553 option(WITH_PYTHON_INSTALL_NUMPY "Copy system NumPy into the blender install folder" ON)
555 if(UNIX AND NOT APPLE)
556 option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON)
557 set(PYTHON_REQUESTS_PATH "" CACHE PATH "\
558 Path to python site-packages or dist-packages containing 'requests' module"
560 mark_as_advanced(PYTHON_REQUESTS_PATH)
563 option(WITH_PYTHON_INSTALL_ZSTANDARD "Copy zstandard into the blender install folder" ON)
564 set(PYTHON_ZSTANDARD_PATH "" CACHE PATH "\
565 Path to python site-packages or dist-packages containing 'zstandard' module"
567 mark_as_advanced(PYTHON_ZSTANDARD_PATH)
570 option(WITH_CPU_SIMD "Enable SIMD instruction if they're detected on the host machine" ON)
571 mark_as_advanced(WITH_CPU_SIMD)
574 option(WITH_CYCLES "Enable Cycles Render Engine" ON)
575 option(WITH_CYCLES_OSL "Build Cycles with OpenShadingLanguage support" ON)
576 option(WITH_CYCLES_PATH_GUIDING "Build Cycles with path guiding support" ON)
577 option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON)
578 option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
579 option(WITH_CYCLES_DEBUG "Build Cycles with options useful for debugging (e.g., MIS)" OFF)
581 option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
582 option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
583 option(WITH_CYCLES_PRECOMPUTE "Build Cycles data precomputation tool" OFF)
585 option(WITH_CYCLES_HYDRA_RENDER_DELEGATE "Build Cycles Hydra render delegate" OFF)
587 option(WITH_CYCLES_DEBUG_NAN "\
588 Build Cycles with additional asserts for detecting NaNs and invalid values"
591 option(WITH_CYCLES_NATIVE_ONLY "\
592 Build Cycles with native kernel only (which fits current CPU, use for development only)"
595 option(WITH_CYCLES_KERNEL_ASAN "\
596 Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow"
599 set(CYCLES_TEST_DEVICES CPU CACHE STRING "\
600 Run regression tests on the specified device types (CPU CUDA OPTIX HIP)"
602 mark_as_advanced(WITH_CYCLES_KERNEL_ASAN)
603 mark_as_advanced(WITH_CYCLES_LOGGING)
604 mark_as_advanced(WITH_CYCLES_DEBUG_NAN)
605 mark_as_advanced(WITH_CYCLES_NATIVE_ONLY)
606 mark_as_advanced(WITH_CYCLES_PRECOMPUTE)
607 mark_as_advanced(CYCLES_TEST_DEVICES)
609 # NVIDIA CUDA & OptiX
611 option(WITH_CYCLES_DEVICE_CUDA "Enable Cycles NVIDIA CUDA compute support" ON)
612 option(WITH_CYCLES_DEVICE_OPTIX "Enable Cycles NVIDIA OptiX support" ON)
613 mark_as_advanced(WITH_CYCLES_DEVICE_CUDA)
615 option(WITH_CYCLES_CUDA_BINARIES "Build Cycles NVIDIA CUDA binaries" OFF)
616 set(CYCLES_CUDA_BINARIES_ARCH
617 sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 sm_89 compute_75
618 CACHE STRING "CUDA architectures to build binaries for"
620 option(WITH_CYCLES_CUDA_BUILD_SERIAL "\
621 Build cubins one after another (useful on machines with limited RAM)"
624 option(WITH_CUDA_DYNLOAD "\
625 Dynamically load CUDA libraries at runtime (for developers, makes cuda-gdb work)"
629 set(OPTIX_ROOT_DIR "" CACHE PATH "\
630 Path to the OptiX SDK root directory, for building Cycles OptiX kernels."
632 set(CYCLES_RUNTIME_OPTIX_ROOT_DIR "" CACHE PATH "\
633 Path to the OptiX SDK root directory. \
634 When set, this path will be used at runtime to compile OptiX kernels."
637 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
638 mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
639 mark_as_advanced(WITH_CUDA_DYNLOAD)
640 mark_as_advanced(OPTIX_ROOT_DIR)
641 mark_as_advanced(CYCLES_RUNTIME_OPTIX_ROOT_DIR)
646 option(WITH_CYCLES_DEVICE_HIP "Enable Cycles AMD HIP support" ON)
647 option(WITH_CYCLES_HIP_BINARIES "Build Cycles AMD HIP binaries" OFF)
648 # Radeon VII (gfx906) not currently working with HIP SDK, so left out of the list.
649 set(CYCLES_HIP_BINARIES_ARCH
651 gfx1010 gfx1011 gfx1012
652 gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 gfx1036
653 gfx1100 gfx1101 gfx1102 gfx1103
654 CACHE STRING "AMD HIP architectures to build binaries for"
656 mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
657 mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
659 # HIPRT is only available on Windows for now.
661 option(WITH_CYCLES_DEVICE_HIPRT "Enable Cycles AMD HIPRT support" OFF)
662 mark_as_advanced(WITH_CYCLES_DEVICE_HIPRT)
668 option(WITH_CYCLES_DEVICE_METAL "Enable Cycles Apple Metal compute support" ON)
673 option(WITH_CYCLES_DEVICE_ONEAPI "Enable Cycles oneAPI compute support" OFF)
674 option(WITH_CYCLES_ONEAPI_BINARIES "\
675 Enable Ahead-Of-Time compilation for Cycles oneAPI device"
678 option(WITH_CYCLES_ONEAPI_HOST_TASK_EXECUTION "\
679 Switch target of oneAPI implementation from SYCL devices to Host Task (single thread on CPU). \
680 This option is only for debugging purposes."
684 # 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
685 # The target architectures levels can be retrieved from `ocloc` output when running
686 # `ocloc compile -device {device_id} test.c` for given GPUs PCI device IDs.
687 # 12.55.8 is for Arc Alchemist GPUs. 12.70.0 for Meteor Lake iGPUs.
688 set(CYCLES_ONEAPI_INTEL_BINARIES_ARCH 12.55.8 12.70.0 CACHE STRING "\
689 oneAPI Intel GPU architectures to build binaries for"
691 set(CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "\
692 oneAPI targets to build AOT binaries for"
695 mark_as_advanced(WITH_CYCLES_ONEAPI_HOST_TASK_EXECUTION)
696 mark_as_advanced(CYCLES_ONEAPI_INTEL_BINARIES_ARCH)
697 mark_as_advanced(CYCLES_ONEAPI_SYCL_TARGETS)
701 option(WITH_DRAW_DEBUG "Add extra debug capabilities to Draw Manager" OFF)
702 mark_as_advanced(WITH_DRAW_DEBUG)
705 option(WITH_LLVM "Use LLVM" OFF)
706 option(LLVM_STATIC "Link with LLVM static libraries" OFF)
707 mark_as_advanced(LLVM_STATIC)
708 option(WITH_CLANG "Use Clang" OFF)
710 # disable for now, but plan to support on all platforms eventually
711 option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" ON)
712 mark_as_advanced(WITH_MEM_JEMALLOC)
714 # currently only used for BLI_mempool
715 option(WITH_MEM_VALGRIND "Enable extended valgrind support for better reporting" OFF)
716 mark_as_advanced(WITH_MEM_VALGRIND)
719 option(WITH_CXX_GUARDEDALLOC "\
720 Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)"
723 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
725 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON)
726 mark_as_advanced(WITH_ASSERT_ABORT)
728 option(WITH_ASSERT_RELEASE "Build with asserts enabled even for non-debug configurations" OFF)
729 mark_as_advanced(WITH_ASSERT_RELEASE)
731 if((UNIX AND NOT APPLE) OR (CMAKE_GENERATOR MATCHES "^Visual Studio.+"))
732 option(WITH_CLANG_TIDY "\
733 Use Clang Tidy to analyze the source code \
734 (only enable for development on Linux using Clang, or Windows using the Visual Studio IDE)"
737 mark_as_advanced(WITH_CLANG_TIDY)
740 option(WITH_BOOST "Enable features depending on boost" ON)
742 Enable multi-threading. TBB is also required for features such as Cycles, OpenVDB and USD"
746 # TBB malloc is only supported on for windows currently
748 option(WITH_TBB_MALLOC_PROXY "Enable the TBB malloc replacement" ON)
751 # This should be turned off when Blender enter beta/rc/release
752 if("${BLENDER_VERSION_CYCLE}" STREQUAL "alpha")
753 set(WITH_EXPERIMENTAL_FEATURES ON)
755 set(WITH_EXPERIMENTAL_FEATURES OFF)
759 option(WITH_GTESTS "Enable GTest unit testing" OFF)
760 option(WITH_GPU_RENDER_TESTS "Enable GPU render related unit testing (EEVEE, Workbench and Grease Pencil)" OFF)
761 option(WITH_GPU_RENDER_TESTS_SILENT "Run GPU render tests silently (finished tests will pass). Generated report will show failing tests" ON)
762 option(WITH_GPU_DRAW_TESTS "Enable GPU drawing related unit testing (GPU backends and draw manager)" OFF)
763 option(WITH_COMPOSITOR_REALTIME_TESTS "Enable regression testing for realtime compositor" OFF)
764 if(UNIX AND NOT (APPLE OR HAIKU))
765 option(WITH_UI_TESTS "\
766 Enable user-interface tests using a headless display server. \
767 Currently this depends on WITH_GHOST_WAYLAND and the weston compositor \
772 # TODO: support running GUI tests on other platforms.
773 set(WITH_UI_TESTS OFF)
776 # Enabled by default for typical use cases to speed up development cycles. However, when looking
777 # into threading or memory related issues (in dependency graph, out-of-bounds, etc) forcing single
778 # test per Blender instance could give much better clues about the root of the problem.
779 option(WITH_TESTS_BATCHED "Run multiple tests in a single Blender invocation, for faster test execution" ON)
780 mark_as_advanced(WITH_TESTS_BATCHED)
782 option(WITH_TESTS_SINGLE_BINARY "\
783 Link GTest tests into a single binary. \
784 For faster overall build and less disk space, but slower individual test build"
787 mark_as_advanced(WITH_TESTS_SINGLE_BINARY)
789 # NOTE: All callers of this must add `TEST_PYTHON_EXE_EXTRA_ARGS` before any other arguments.
790 set(TEST_PYTHON_EXE "" CACHE PATH "Python executable to run unit tests")
791 mark_as_advanced(TEST_PYTHON_EXE)
794 if(UNIX AND NOT APPLE)
795 option(WITH_DOC_MANPAGE "Create a manual page (Unix manpage)" OFF)
800 option(WITH_GPU_BUILDTIME_SHADER_BUILDER "\
801 Shader builder is a developer option enabling linting on GLSL during compilation"
804 option(WITH_RENDERDOC "Use Renderdoc API to capture frames" OFF)
807 WITH_GPU_BUILDTIME_SHADER_BUILDER
813 option(WITH_OPENGL_BACKEND "Enable OpenGL support as graphic backend" ON)
814 mark_as_advanced(WITH_OPENGL_BACKEND)
816 set(WITH_OPENGL_BACKEND OFF)
821 option(WITH_VULKAN_BACKEND "Enable Vulkan as graphics backend (experimental)" ON)
822 option(WITH_VULKAN_GUARDEDALLOC "\
823 Use guardedalloc for host allocations done inside Vulkan (development option)"
828 WITH_VULKAN_GUARDEDALLOC
830 if(NOT WITH_EXPERIMENTAL_FEATURES)
831 set(WITH_VULKAN_BACKEND OFF)
837 option(WITH_METAL_BACKEND "\
838 Use Metal for graphics instead of (or as well as) OpenGL on macOS."
841 mark_as_advanced(WITH_METAL_BACKEND)
843 set(WITH_METAL_BACKEND OFF)
847 getDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
848 set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
851 option(WITH_STRSIZE_DEBUG "\
852 Ensure string operations on fixed size buffers \
853 (works well with with \"WITH_COMPILER_ASAN\" & valgrind to detect incorrect buffer size arguments)"
855 mark_as_advanced(WITH_STRSIZE_DEBUG)
857 # Compiler tool-chain.
859 if(CMAKE_COMPILER_IS_GNUCC)
860 option(WITH_LINKER_GOLD "Use ld.gold linker which is usually faster than ld.bfd" ON)
861 mark_as_advanced(WITH_LINKER_GOLD)
863 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
864 option(WITH_LINKER_LLD "Use ld.lld linker which is usually faster than ld.gold" OFF)
865 mark_as_advanced(WITH_LINKER_LLD)
866 option(WITH_LINKER_MOLD "Use ld.mold linker which is usually faster than ld.gold & ld.lld" OFF)
867 mark_as_advanced(WITH_LINKER_MOLD)
871 option(WITH_COMPILER_ASAN "\
872 Build and link against address sanitizer (only for Debug & RelWithDebInfo targets)."
875 mark_as_advanced(WITH_COMPILER_ASAN)
876 option(WITH_COMPILER_ASAN_EXTERN "\
877 Build `extern` dependencies with address sanitizer when WITH_COMPILER_ASAN is on. \
878 Can cause linking issues due to too large binary size."
881 mark_as_advanced(WITH_COMPILER_ASAN_EXTERN)
883 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
884 if(WITH_COMPILER_ASAN)
885 set(_asan_defaults "\
890 -fsanitize=float-cast-overflow \
891 -fsanitize=float-divide-by-zero \
892 -fsanitize=nonnull-attribute \
893 -fsanitize=returns-nonnull-attribute \
894 -fsanitize=signed-integer-overflow \
895 -fsanitize=undefined \
896 -fsanitize=vla-bound \
897 -fno-sanitize=alignment \
901 # clang-cl doesn't support all sanitizers, but leak and object-size give errors/warnings.
902 set(_asan_defaults "${_asan_defaults}")
904 # AppleClang doesn't support all sanitizers, but leak gives error.
905 # Build type is not known for multi-config generator, so don't add object-size sanitizer.
906 if(CMAKE_BUILD_TYPE MATCHES "Debug" OR GENERATOR_IS_MULTI_CONFIG)
907 # Silence the warning that object-size is not effective in -O0.
908 set(_asan_defaults "${_asan_defaults}")
910 string(APPEND _asan_defaults " -fsanitize=object-size")
912 elseif(CMAKE_COMPILER_IS_GNUCC)
913 string(APPEND _asan_defaults " -fsanitize=leak -fsanitize=object-size")
915 string(APPEND _asan_defaults " -fsanitize=leak")
918 set(COMPILER_ASAN_CFLAGS "${_asan_defaults}" CACHE STRING "C flags for address sanitizer")
919 mark_as_advanced(COMPILER_ASAN_CFLAGS)
920 set(COMPILER_ASAN_CXXFLAGS "${_asan_defaults}" CACHE STRING "C++ flags for address sanitizer")
921 mark_as_advanced(COMPILER_ASAN_CXXFLAGS)
923 unset(_asan_defaults)
927 COMPILER_ASAN_LIBRARY NAMES clang_rt.asan-x86_64
929 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/7.0.0/lib/windows
930 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/6.0.0/lib/windows
932 mark_as_advanced(COMPILER_ASAN_LIBRARY)
934 execute_process(COMMAND ${CMAKE_CXX_COMPILER}
936 OUTPUT_VARIABLE CLANG_LIB_DIR
938 string(STRIP "${CLANG_LIB_DIR}" CLANG_LIB_DIR)
940 COMPILER_ASAN_LIBRARY
942 libclang_rt.asan_osx_dynamic.dylib
944 "${CLANG_LIB_DIR}/darwin/"
947 mark_as_advanced(COMPILER_ASAN_LIBRARY)
948 elseif(CMAKE_COMPILER_IS_GNUCC)
950 COMPILER_ASAN_LIBRARY asan ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}
952 mark_as_advanced(COMPILER_ASAN_LIBRARY)
958 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
959 option(WITH_COMPILER_SHORT_FILE_MACRO "\
960 Make paths in macros like __FILE__ relative to top level source and build directories."
963 mark_as_advanced(WITH_COMPILER_SHORT_FILE_MACRO)
967 # Use hardcoded paths or find_package to find externals
968 option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF)
969 mark_as_advanced(WITH_WINDOWS_FIND_MODULES)
971 option(WINDOWS_PYTHON_DEBUG "\
972 Include the files needed for debugging python scripts with visual studio 2017+."
975 mark_as_advanced(WINDOWS_PYTHON_DEBUG)
977 option(WITH_WINDOWS_BUNDLE_CRT "Bundle the C runtime for install free distribution." ON)
978 mark_as_advanced(WITH_WINDOWS_BUNDLE_CRT)
980 option(WITH_WINDOWS_SCCACHE "Use sccache to speed up builds (Ninja builder only)" OFF)
981 mark_as_advanced(WITH_WINDOWS_SCCACHE)
983 option(WITH_WINDOWS_RELEASE_PDB "\
984 Generate a pdb file for client side stacktraces for release builds"
987 mark_as_advanced(WITH_WINDOWS_RELEASE_PDB)
989 option(WITH_WINDOWS_RELEASE_STRIPPED_PDB "Use a stripped PDB file for release builds" ON)
990 mark_as_advanced(WITH_WINDOWS_RELEASE_STRIPPED_PDB)
995 option(IDE_GROUP_SOURCES_IN_FOLDERS "\
996 Organize the source files in filters matching the source folders."
999 mark_as_advanced(IDE_GROUP_SOURCES_IN_FOLDERS)
1001 option(IDE_GROUP_PROJECTS_IN_FOLDERS "\
1002 Organize the projects according to source folder structure."
1005 mark_as_advanced(IDE_GROUP_PROJECTS_IN_FOLDERS)
1007 if(IDE_GROUP_PROJECTS_IN_FOLDERS)
1008 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1013 # See WITH_WINDOWS_SCCACHE for Windows.
1014 option(WITH_COMPILER_CCACHE "\
1015 Use ccache to improve rebuild times (Works with Ninja, Makefiles and Xcode)"
1018 mark_as_advanced(WITH_COMPILER_CCACHE)
1021 # The following only works with the Ninja generator in CMake >= 3.0.
1022 if("${CMAKE_GENERATOR}" MATCHES "Ninja")
1023 option(WITH_NINJA_POOL_JOBS "\
1024 Enable Ninja pools of jobs, to try to ease building on machines with 16GB of RAM or less \
1025 (if not yet defined, will try to set best values based on detected machine specifications)."
1028 mark_as_advanced(WITH_NINJA_POOL_JOBS)
1031 # Installation process.
1032 set(POSTINSTALL_SCRIPT "" CACHE FILEPATH "Run given CMake script after installation process")
1033 mark_as_advanced(POSTINSTALL_SCRIPT)
1035 set(POSTCONFIGURE_SCRIPT "" CACHE FILEPATH "\
1036 Run given CMake script as the last step of CMake configuration"
1038 mark_as_advanced(POSTCONFIGURE_SCRIPT)
1044 # By default we want to install to the directory we are compiling our executables
1045 # unless specified otherwise, which we currently do not allow
1046 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
1048 set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE} CACHE PATH "\
1049 default install path"
1053 set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE} CACHE PATH "\
1054 default install path"
1058 if(WITH_INSTALL_PORTABLE)
1059 set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH} CACHE PATH "default install path" FORCE)
1064 # Effective install path including config folder, as a generator expression.
1065 get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
1066 if(GENERATOR_IS_MULTI_CONFIG)
1068 REPLACE "\${BUILD_TYPE}" "$<CONFIG>"
1069 CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX}
1073 REPLACE "\${BUILD_TYPE}" ""
1074 CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX}
1082 include(platform_apple_xcode)
1086 # -----------------------------------------------------------------------------
1087 # Check for Conflicting/Unsupported Configurations
1089 option(WITH_STRICT_BUILD_OPTIONS "\
1090 When requirements for a build option are not met, error instead of disabling the option."
1094 if(NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE AND NOT WITH_CYCLES_HYDRA_RENDER_DELEGATE)
1096 "At least one of WITH_BLENDER or WITH_CYCLES_STANDALONE "
1097 "or WITH_CYCLES_HYDRA_RENDER_DELEGATE "
1098 "must be enabled, nothing to do!"
1102 set_and_warn_dependency(WITH_AUDASPACE WITH_OPENAL OFF)
1103 set_and_warn_dependency(WITH_AUDASPACE WITH_COREAUDIO OFF)
1104 set_and_warn_dependency(WITH_AUDASPACE WITH_JACK OFF)
1105 set_and_warn_dependency(WITH_AUDASPACE WITH_PULSEAUDIO OFF)
1106 set_and_warn_dependency(WITH_AUDASPACE WITH_WASAPI OFF)
1108 if(NOT WITH_SDL AND WITH_GHOST_SDL)
1109 message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL")
1112 # python module, needs some different options
1113 if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
1114 message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
1117 set_and_warn_dependency(WITH_PYTHON WITH_CYCLES OFF)
1118 set_and_warn_dependency(WITH_PYTHON WITH_DRACO OFF)
1119 set_and_warn_dependency(WITH_PYTHON WITH_MOD_FLUID OFF)
1121 if(WITH_DRACO AND NOT WITH_PYTHON_INSTALL)
1122 message(STATUS "WITH_DRACO requires WITH_PYTHON_INSTALL to be ON, disabling WITH_DRACO for now")
1126 # enable boost for cycles, audaspace or i18n
1127 # otherwise if the user disabled
1129 set_and_warn_dependency(WITH_BOOST WITH_INTERNATIONAL OFF)
1130 set_and_warn_dependency(WITH_BOOST WITH_OPENVDB OFF)
1131 set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW OFF)
1132 set_and_warn_dependency(WITH_BOOST WITH_USD OFF)
1134 set_and_warn_dependency(WITH_BOOST WITH_CYCLES_OSL OFF)
1135 set_and_warn_dependency(WITH_PUGIXML WITH_CYCLES_OSL OFF)
1138 set_and_warn_dependency(WITH_TBB WITH_CYCLES OFF)
1139 set_and_warn_dependency(WITH_TBB WITH_USD OFF)
1140 set_and_warn_dependency(WITH_TBB WITH_OPENVDB OFF)
1141 set_and_warn_dependency(WITH_TBB WITH_MOD_FLUID OFF)
1143 # NanoVDB requires OpenVDB to convert the data structure
1144 set_and_warn_dependency(WITH_OPENVDB WITH_NANOVDB OFF)
1146 # OpenVDB, Alembic and OSL uses 'half' or 'imath' from OpenEXR
1147 set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENVDB OFF)
1148 set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_ALEMBIC OFF)
1149 set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_CYCLES_OSL OFF)
1151 # Hydra requires USD.
1152 set_and_warn_dependency(WITH_USD WITH_HYDRA OFF)
1155 set(WITH_CYCLES_OSL OFF)
1158 # don't store paths to libs for portable distribution
1159 if(WITH_INSTALL_PORTABLE)
1160 set(CMAKE_SKIP_BUILD_RPATH TRUE)
1163 if(UNIX AND NOT (APPLE OR HAIKU))
1164 set_and_warn_incompatible(WITH_HEADLESS WITH_GHOST_WAYLAND OFF)
1165 set_and_warn_incompatible(WITH_HEADLESS WITH_GHOST_X11 OFF)
1167 set_and_warn_incompatible(WITH_HEADLESS WITH_GHOST_SDL OFF)
1170 set_and_warn_incompatible(WITH_HEADLESS WITH_INPUT_IME OFF)
1171 set_and_warn_incompatible(WITH_GHOST_SDL WITH_INPUT_IME OFF)
1174 set_and_warn_incompatible(WITH_HEADLESS WITH_XR_OPENXR OFF)
1175 set_and_warn_incompatible(WITH_GHOST_SDL WITH_XR_OPENXR OFF)
1178 set_and_warn_dependency(WITH_GHOST_WAYLAND WITH_UI_TESTS OFF)
1183 set_and_warn_library_found("Git" GIT_FOUND WITH_BUILDINFO)
1187 if(NOT WITH_SYSTEM_AUDASPACE)
1188 set(AUDASPACE_C_INCLUDE_DIRS
1189 "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings/C"
1190 "${CMAKE_BINARY_DIR}/extern/audaspace"
1192 set(AUDASPACE_PY_INCLUDE_DIRS
1193 "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings"
1198 # Auto-enable CUDA dynload if toolkit is not found.
1199 if(WITH_CYCLES AND WITH_CYCLES_DEVICE_CUDA AND NOT WITH_CUDA_DYNLOAD)
1204 "CUDA toolkit not found, "
1205 "using dynamic runtime loading of libraries (WITH_CUDA_DYNLOAD) instead"
1207 set(WITH_CUDA_DYNLOAD ON)
1211 if(WITH_CYCLES_DEVICE_HIP)
1212 # Currently HIP must be dynamically loaded, this may change in future toolkits
1213 set(WITH_HIP_DYNLOAD ON)
1217 # -----------------------------------------------------------------------------
1218 # Check if Sub-modules are Cloned
1221 # While we have this as an '#error' in 'bpy_capi_utils.h',
1222 # upgrading Python tends to cause confusion for users who build.
1223 # Give the error message early to make this more obvious.
1225 # Do this before main 'platform_*' checks,
1226 # because UNIX will search for the old Python paths which may not exist.
1227 # giving errors about missing paths before this case is met.
1228 if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.11")
1231 "At least Python 3.11 is required to build, but found Python ${PYTHON_VERSION}"
1235 file(GLOB RESULT "${CMAKE_SOURCE_DIR}/scripts/addons")
1236 list(LENGTH RESULT DIR_LEN)
1240 "Addons path '${CMAKE_SOURCE_DIR}/scripts/addons' is missing. "
1241 "This is an external repository which needs to be checked out. Use `make update` to do so. "
1242 "* CONTINUING WITHOUT ADDONS *"
1248 # -----------------------------------------------------------------------------
1249 # InitialIze Un-cached Vars, Avoid Unused Warning
1251 # linux only, not cached
1252 set(WITH_BINRELOC OFF)
1254 # MACOSX only, set to avoid uninitialized
1258 set(PLATFORM_CFLAGS)
1260 # these are added to later on.
1264 # NOTE: These flags are intended for situations where where it's impractical to
1265 # suppress warnings by modifying the code or for code which is maintained externally.
1266 # For GCC this typically means adding `-Wno-*` arguments to negate warnings
1267 # that are useful in the general case.
1268 set(C_REMOVE_STRICT_FLAGS)
1269 set(CXX_REMOVE_STRICT_FLAGS)
1271 # Libraries to link to targets in setup_platform_linker_libs
1272 set(PLATFORM_LINKLIBS "")
1274 # Added to target linker flags in setup_platform_linker_flags
1275 # - CMAKE_EXE_LINKER_FLAGS
1276 # - CMAKE_EXE_LINKER_FLAGS_DEBUG
1277 set(PLATFORM_LINKFLAGS "")
1278 set(PLATFORM_LINKFLAGS_DEBUG "")
1279 set(PLATFORM_LINKFLAGS_RELEASE "")
1280 set(PLATFORM_LINKFLAGS_EXECUTABLE "")
1282 if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
1283 if(WITH_COMPILER_ASAN)
1285 # Avoid passing address sanitizer compiler flags to `try_compile`.
1286 # Since linker flags are not set, all compiler checks and `find_package`
1287 # calls that rely on `try_compile` will fail.
1289 string(APPEND CMAKE_C_FLAGS_DEBUG " ${COMPILER_ASAN_CFLAGS}")
1290 string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${COMPILER_ASAN_CFLAGS}")
1292 string(APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMPILER_ASAN_CXXFLAGS}")
1293 string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${COMPILER_ASAN_CXXFLAGS}")
1296 set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6")
1299 if(APPLE AND COMPILER_ASAN_LIBRARY)
1300 string(REPLACE " " ";" _list_COMPILER_ASAN_CFLAGS ${COMPILER_ASAN_CFLAGS})
1301 set(_is_CONFIG_DEBUG "$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>")
1302 add_compile_options("$<${_is_CONFIG_DEBUG}:${_list_COMPILER_ASAN_CFLAGS}>")
1304 # Skip generation of the unwind tables, as they might require a lot of space when sanitizers
1305 # are enabled and not fit into the .eh_frame section. Disabling the unwind tables might have
1306 # side effects on code which does frame walking, such as
1308 # - __attribute__((__cleanup__(f)))
1309 # - __builtin_return_address(n), for n > 0
1310 # - pthread_cleanup_push when it is implemented using __attribute__((__cleanup__(f)))
1311 # It should not have affect on debugging, since it uses -g flag which generates debugging
1312 # tables in the .debug_frame section.
1313 # At the time of adding these flags calling backtrace() from C code on Apple M2 did not
1314 # affect on the printed backtrace, and exception handling was correct as well.
1316 # Related discussion:
1317 # https://stackoverflow.com/questions/26300819/why-gcc-compiled-c-program-needs-eh-frame-section
1318 add_compile_options("$<${_is_CONFIG_DEBUG}:-fno-unwind-tables>")
1319 add_compile_options("$<${_is_CONFIG_DEBUG}:-fno-asynchronous-unwind-tables>")
1321 add_compile_options("$<${_is_CONFIG_DEBUG}:-fno-omit-frame-pointer>")
1322 add_link_options("$<${_is_CONFIG_DEBUG}:-fno-omit-frame-pointer;-fsanitize=address>")
1323 unset(_list_COMPILER_ASAN_CFLAGS)
1324 unset(_is_CONFIG_DEBUG)
1325 elseif(COMPILER_ASAN_LIBRARY)
1326 set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}")
1327 set(PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY}")
1328 set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY}")
1329 if(DEFINED COMPILER_ASAN_LINKER_FLAGS)
1330 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${COMPILER_ASAN_LINKER_FLAGS}")
1331 set(PLATFORM_LINKFLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG} ${COMPILER_ASAN_LINKER_FLAGS}")
1337 # Test SIMD support, before platform includes to determine if sse2neon is needed.
1339 set(COMPILER_SSE_FLAG)
1340 set(COMPILER_SSE2_FLAG)
1342 # Test Neon first since macOS Arm can compile and run x86-64 SSE binaries.
1344 if(NOT SUPPORT_NEON_BUILD)
1345 test_sse_support(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
1350 # ----------------------------------------------------------------------------
1351 # Main Platform Checks
1357 if(UNIX AND NOT APPLE)
1358 include(platform_unix)
1360 include(platform_win32)
1362 include(platform_apple)
1366 # -----------------------------------------------------------------------------
1367 # Common Checks for Compatible Options
1369 if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
1370 message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
1373 if(WITH_INTERNATIONAL)
1377 "Internationalization requires WITH_BOOST, the library may not have been found. "
1378 "Configure BOOST or disable WITH_INTERNATIONAL"
1383 # Enable SIMD support if detected by `test_sse_support()` or `test_neon_support()`.
1385 # This is done globally, so that all modules can use it if available, and
1386 # because these are used in headers used by many modules.
1388 if(SUPPORT_NEON_BUILD)
1391 include_directories(SYSTEM "${SSE2NEON_INCLUDE_DIRS}")
1392 add_definitions(-DWITH_SSE2NEON)
1396 if(SUPPORT_SSE_BUILD)
1397 string(PREPEND PLATFORM_CFLAGS "${COMPILER_SSE_FLAG} ")
1398 add_definitions(-D__SSE__ -D__MMX__)
1400 if(SUPPORT_SSE2_BUILD)
1401 string(APPEND PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG}")
1402 add_definitions(-D__SSE2__)
1403 if(NOT SUPPORT_SSE_BUILD) # don't double up
1404 add_definitions(-D__MMX__)
1410 # Print instructions used on first run.
1413 if(SUPPORT_NEON_BUILD)
1415 message(STATUS "Neon SIMD instructions enabled")
1417 message(STATUS "Neon SIMD instructions detected but unused, requires sse2neon")
1419 elseif(SUPPORT_SSE2_BUILD)
1420 message(STATUS "SSE2 SIMD instructions enabled")
1421 elseif(SUPPORT_SSE_BUILD)
1422 message(STATUS "SSE SIMD instructions enabled")
1424 message(STATUS "No SIMD instructions detected")
1427 message(STATUS "SIMD instructions disabled")
1431 # set the endian define
1433 # for some reason this fails on msvc
1434 add_definitions(-D__LITTLE_ENDIAN__)
1436 # OSX-Note: as we do cross-compiling with specific set architecture,
1437 # endianness-detection and auto-setting is counterproductive
1438 # so we just set endianness according CMAKE_OSX_ARCHITECTURES
1440 elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR
1441 CMAKE_OSX_ARCHITECTURES MATCHES x86_64 OR
1442 CMAKE_OSX_ARCHITECTURES MATCHES arm64)
1443 add_definitions(-D__LITTLE_ENDIAN__)
1444 elseif(CMAKE_OSX_ARCHITECTURES MATCHES ppc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc64)
1445 add_definitions(-D__BIG_ENDIAN__)
1448 include(TestBigEndian)
1449 test_big_endian(_SYSTEM_BIG_ENDIAN)
1450 if(_SYSTEM_BIG_ENDIAN)
1451 add_definitions(-D__BIG_ENDIAN__)
1453 add_definitions(-D__LITTLE_ENDIAN__)
1455 unset(_SYSTEM_BIG_ENDIAN)
1457 if(WITH_IMAGE_OPENJPEG)
1458 # Special handling of Windows platform where openjpeg is always static.
1460 set(OPENJPEG_DEFINES "-DOPJ_STATIC")
1462 set(OPENJPEG_DEFINES "")
1466 if(NOT WITH_SYSTEM_EIGEN3)
1467 set(EIGEN3_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/Eigen3)
1471 list(APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB)
1473 if(WITH_OPENVDB_3_ABI_COMPATIBLE)
1474 list(APPEND OPENVDB_DEFINITIONS -DOPENVDB_3_ABI_COMPATIBLE)
1477 # OpenVDB headers use deprecated TBB headers, silence warning.
1478 list(APPEND OPENVDB_DEFINITIONS -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1)
1480 list(APPEND OPENVDB_INCLUDE_DIRS
1481 ${BOOST_INCLUDE_DIR}
1483 ${OPENEXR_INCLUDE_DIRS}
1486 list(APPEND OPENVDB_LIBRARIES ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
1488 if(WITH_OPENVDB_BLOSC)
1489 list(APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB_BLOSC)
1490 # Even when `WITH_OPENVDB_BLOSC` is set, `FindBlosc.cmake` isn't running.
1491 # As this might be used at some point, check the libraries are defined.
1492 if(DEFINED BLOSC_LIBRARIES)
1493 list(APPEND OPENVDB_LIBRARIES ${BLOSC_LIBRARIES})
1495 list(APPEND OPENVDB_LIBRARIES ${ZLIB_LIBRARIES})
1498 list(APPEND OPENVDB_LIBRARIES ${BOOST_LIBRARIES} ${TBB_LIBRARIES})
1501 # -----------------------------------------------------------------------------
1504 if(WITH_METAL_BACKEND)
1505 add_definitions(-DWITH_METAL_BACKEND)
1507 # No need to add frameworks here, all the ones we need for Metal and
1508 # Metal-OpenGL Interop are already being added by
1509 # build_files/cmake/platform/platform_apple.cmake
1513 # -----------------------------------------------------------------------------
1517 if(NOT OPENMP_CUSTOM)
1518 find_package(OpenMP)
1521 set_and_warn_library_found("OpenMP" OPENMP_FOUND WITH_OPENMP)
1524 if(NOT WITH_OPENMP_STATIC)
1525 string(APPEND CMAKE_C_FLAGS " ${OpenMP_C_FLAGS}")
1526 string(APPEND CMAKE_CXX_FLAGS " ${OpenMP_CXX_FLAGS}")
1527 string(APPEND CMAKE_EXE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}")
1528 string(APPEND CMAKE_MODULE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}")
1530 # Typically avoid adding flags as defines but we can't
1531 # pass OpenMP flags to the linker for static builds, meaning
1532 # we can't add any OpenMP related flags to CFLAGS variables
1533 # since they're passed to the linker as well.
1534 add_definitions("${OpenMP_C_FLAGS}")
1536 find_library_static(OpenMP_LIBRARIES gomp ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES})
1550 # -----------------------------------------------------------------------------
1554 if(WITH_SYSTEM_BULLET)
1555 find_package(Bullet)
1556 set_and_warn_library_found("Bullet" BULLET_FOUND WITH_BULLET)
1558 set(BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src")
1559 set(BULLET_LIBRARIES "extern_bullet")
1564 # -----------------------------------------------------------------------------
1567 # Not currently supported due to different required Python link flags.
1568 set_and_warn_incompatible(WITH_PYTHON_MODULE WITH_GTESTS OFF)
1571 # -----------------------------------------------------------------------------
1572 # Configure `GLog/GFlags`
1574 if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
1575 if(WITH_SYSTEM_GFLAGS)
1576 find_package(Gflags)
1577 if(NOT GFLAGS_FOUND)
1578 message(FATAL_ERROR "System wide Gflags is requested but was not found")
1580 # `FindGflags` does not define this, and we are not even sure what to use here.
1584 -DGFLAGS_DLL_DEFINE_FLAG=
1585 -DGFLAGS_DLL_DECLARE_FLAG=
1588 set(GFLAGS_NAMESPACE "gflags")
1589 set(GFLAGS_LIBRARIES extern_gflags)
1590 set(GFLAGS_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/extern/gflags/src")
1593 if(WITH_SYSTEM_GLOG)
1596 message(FATAL_ERROR "System wide Glog is requested but was not found")
1598 # `FindGlog` does not define this, and we are not even sure what to use here.
1602 -DGOOGLE_GLOG_DLL_DECL=
1604 set(GLOG_LIBRARIES extern_glog)
1606 set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/glog/src/windows)
1608 set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/glog/include)
1614 # -----------------------------------------------------------------------------
1615 # Ninja Job Limiting
1617 # Extra limits to number of jobs running in parallel for some kind os tasks.
1618 # Only supported by Ninja build system currently.
1620 if("${CMAKE_GENERATOR}" MATCHES "Ninja" AND WITH_NINJA_POOL_JOBS)
1621 if(NOT NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS AND
1622 NOT NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS AND
1623 NOT NINJA_MAX_NUM_PARALLEL_LINK_JOBS)
1624 # Try to define good default values.
1625 # Max mem of heavy cpp files compilation: about 2.5GB
1626 # Max mem during linking: about 3.3GB
1627 cmake_host_system_information(RESULT _NUM_CORES QUERY NUMBER_OF_LOGICAL_CORES)
1628 # Note: this gives mem in MB.
1629 cmake_host_system_information(RESULT _TOT_MEM QUERY TOTAL_PHYSICAL_MEMORY)
1631 # Heuristics: Assume 8Gb of RAM is needed per heavy compile job.
1632 # Typical RAM peak usage of these is actually less than 3GB currently,
1633 # but this also accounts for the part of the physical RAM being used by other unrelated
1634 # processes on the system, and the part being used by the 'regular' compile and linking jobs.
1636 # Also always cap heavy jobs amount to `number of available threads - 1`, to ensure that even if
1637 # there would be enough RAM, the machine never ends up handling only heavy jobs at some point.
1638 # This can have annoying sides effects, like lack of output in the console for several minutes,
1639 # which can lead to a wrong detection of 'unresponsive' state by the buildbots e.g.
1641 # Currently, these settings applied to a 64GB/16threads linux machine will use, for a full build:
1643 # * RAM: typically less than 20%, with some peaks at 25%.
1644 # * CPU: over 90% of usage on average over the whole build time.
1645 # - debug with ASAN build:
1646 # * RAM: typically less than 40%, with some peaks at 50%.
1647 # * CPU: over 90% of usage on average over the whole build time.
1648 math(EXPR _compile_heavy_jobs "${_TOT_MEM} / 8000")
1649 math(EXPR _compile_heavy_jobs_max "${_NUM_CORES} - 1")
1650 if(${_compile_heavy_jobs} GREATER ${_compile_heavy_jobs_max})
1651 set(_compile_heavy_jobs ${_compile_heavy_jobs_max})
1652 elseif(${_compile_heavy_jobs} LESS 1)
1653 set(_compile_heavy_jobs 1)
1655 set(NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS "${_compile_heavy_jobs}" CACHE STRING "\
1656 Define the maximum number of concurrent heavy compilation jobs, for ninja build system \
1657 (used for some targets which cpp files can take several GB each during compilation)."
1660 mark_as_advanced(NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
1661 set(_compile_heavy_jobs)
1662 set(_compile_heavy_jobs_max)
1664 # Heuristics: Assume 2Gb of RAM is needed per heavy compile job.
1665 # Typical RAM peak usage of these is actually way less than 1GB usually,
1666 # but this also accounts for the part of the physical RAM being used by other unrelated
1667 # processes on the system, and the part being used by the 'heavy' compile and linking jobs.
1669 # If there are 'enough' cores available, cap the maximum number of regular jobs to
1670 # `number of cores - 1`, otherwise allow using all cores if there is enough RAM available.
1671 # This allows to ensure that the heavy jobs won't get starved by too many normal jobs,
1672 # since the former usually take a long time to process.
1673 math(EXPR _compile_jobs "${_TOT_MEM} / 2000")
1674 if(${_NUM_CORES} GREATER 3)
1675 math(EXPR _compile_jobs_max "${_NUM_CORES} - 1")
1677 set(_compile_jobs_max ${_NUM_CORES})
1679 if(${_compile_jobs} GREATER ${_compile_jobs_max})
1680 set(_compile_jobs ${_compile_jobs_max})
1681 elseif(${_compile_jobs} LESS 1)
1682 set(_compile_jobs 1)
1684 set(NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS "${_compile_jobs}" CACHE STRING
1685 "Define the maximum number of concurrent compilation jobs, for ninja build system." FORCE)
1686 mark_as_advanced(NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS)
1688 set(_compile_jobs_max)
1690 # In practice, even when there is RAM available,
1691 # this proves to be quicker than running in parallel (due to slow disks accesses).
1692 set(NINJA_MAX_NUM_PARALLEL_LINK_JOBS "1" CACHE STRING
1693 "Define the maximum number of concurrent link jobs, for ninja build system." FORCE)
1694 mark_as_advanced(NINJA_MAX_NUM_PARALLEL_LINK_JOBS)
1700 if(NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS)
1702 GLOBAL APPEND PROPERTY
1703 JOB_POOLS compile_job_pool=${NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS}
1705 set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
1708 if(NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
1710 GLOBAL APPEND PROPERTY
1711 JOB_POOLS compile_heavy_job_pool=${NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS}
1715 if(NINJA_MAX_NUM_PARALLEL_LINK_JOBS)
1717 GLOBAL APPEND PROPERTY
1718 JOB_POOLS link_job_pool=${NINJA_MAX_NUM_PARALLEL_LINK_JOBS}
1720 set(CMAKE_JOB_POOL_LINK link_job_pool)
1725 # -----------------------------------------------------------------------------
1726 # Extra Compile Flags
1728 if(CMAKE_COMPILER_IS_GNUCC)
1730 add_check_c_compiler_flags(
1734 C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration
1736 # System headers sometimes do this, disable for now, was: `-Werror=strict-prototypes`.
1737 C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes
1739 C_WARN_ERROR_RETURN_TYPE -Werror=return-type
1740 C_WARN_ERROR_VLA -Werror=vla
1741 C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes
1742 C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
1743 C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
1744 C_WARN_POINTER_ARITH -Wpointer-arith
1745 C_WARN_UNUSED_PARAMETER -Wunused-parameter
1746 C_WARN_WRITE_STRINGS -Wwrite-strings
1747 C_WARN_LOGICAL_OP -Wlogical-op
1748 C_WARN_UNDEF -Wundef
1750 # Needs: `-Wuninitialized`.
1751 C_WARN_INIT_SELF -Winit-self
1753 C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs
1754 C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero
1755 C_WARN_TYPE_LIMITS -Wtype-limits
1756 C_WARN_FORMAT_SIGN -Wformat-signedness
1757 C_WARN_RESTRICT -Wrestrict
1759 # Useful but too many false positives and inconvenient to suppress each occurrence.
1760 C_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread
1761 C_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow
1764 C_WARN_NO_NULL -Wnonnull
1765 C_WARN_ABSOLUTE_VALUE -Wabsolute-value
1767 C_WARN_UNINITIALIZED -Wuninitialized
1768 C_WARN_REDUNDANT_DECLS -Wredundant-decls
1769 C_WARN_SHADOW -Wshadow
1771 # Disable because it gives warnings for printf() & friends.
1772 # C_WARN_DOUBLE_PROMOTION "-Wdouble-promotion -Wno-error=double-promotion"
1774 # Use `ATTR_FALLTHROUGH` macro to suppress.
1775 C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5
1779 add_check_c_compiler_flags(
1781 C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable
1785 add_check_cxx_compiler_flags(
1788 CXX_WARN_UNINITIALIZED -Wuninitialized
1789 CXX_WARN_REDUNDANT_DECLS -Wredundant-decls
1792 CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
1793 CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
1794 CXX_WARN_LOGICAL_OP -Wlogical-op
1796 # Needs: `-Wuninitialized`.
1797 CXX_WARN_INIT_SELF -Winit-self
1799 CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs
1800 CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero
1801 CXX_WARN_TYPE_LIMITS -Wtype-limits
1802 CXX_WARN_ERROR_RETURN_TYPE -Werror=return-type
1803 CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
1804 CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
1805 CXX_WARN_POINTER_ARITH -Wpointer-arith
1806 CXX_WARN_UNUSED_PARAMETER -Wunused-parameter
1807 CXX_WARN_WRITE_STRINGS -Wwrite-strings
1808 CXX_WARN_UNDEF -Wundef
1809 CXX_WARN_COMMA_SUBSCRIPT -Wcomma-subscript
1810 CXX_WARN_FORMAT_SIGN -Wformat-signedness
1811 CXX_WARN_RESTRICT -Wrestrict
1812 CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override
1813 CXX_WARN_UNINITIALIZED -Wuninitialized
1815 # NOTE(@ideasman42): In GCC 13.2.1 on Linux this causes internal compiler errors.
1816 # The crashes can be resolved by disabling the flag per module (but not via pragmas).
1817 # However this also causes a type mix-up FreeStyle (Blender & FreeStyle's `Curve`)
1818 # so it seems to impact GCC's the internal state enough that it's too risky to enable.
1819 # When this is resolved the check can be enabled for fixed GCC versions.
1821 # Prevents linking errors with MSVC.
1822 # `CXX_WARN_MISMATCHED_TAGS -Wmismatched-tags`
1824 # Useful but too many false positives and inconvenient to suppress each occurrence.
1825 CXX_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread
1826 CXX_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow
1828 # Use `[[fallthrough]]` or `ATTR_FALLTHROUGH` macro to suppress.
1829 CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5
1832 # causes too many warnings
1834 add_check_cxx_compiler_flags(
1836 CXX_WARN_UNDEF -Wundef
1837 CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations
1841 # ---------------------
1842 # Suppress Strict Flags
1844 # Exclude the following warnings from this list:
1846 # This can give useful hints that point to bugs/misleading logic.
1847 # - `-Wno-strict-prototypes`:
1848 # No need to support older C-style prototypes.
1850 # If code in `./extern/` needs to suppress these flags that can be done on a case-by-case basis.
1852 # flags to undo strict flags
1853 add_check_c_compiler_flags(
1854 C_REMOVE_STRICT_FLAGS
1856 C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations
1857 C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
1858 C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function
1859 C_WARN_NO_TYPE_LIMITS -Wno-type-limits
1860 C_WARN_NO_INT_IN_BOOL_CONTEXT -Wno-int-in-bool-context
1861 C_WARN_NO_FORMAT -Wno-format
1862 C_WARN_NO_SWITCH -Wno-switch
1863 C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
1864 C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized
1865 C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough
1869 add_check_cxx_compiler_flags(
1870 CXX_REMOVE_STRICT_FLAGS
1872 CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess
1873 CXX_WARN_NO_COMMENT -Wno-comment
1874 CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs
1875 CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
1876 CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized
1881 add_check_c_compiler_flags(
1882 C_REMOVE_STRICT_FLAGS
1883 C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable
1887 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
1889 add_check_c_compiler_flags(
1892 # Strange, clang complains these are not supported, but then uses them.
1894 C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration
1895 C_WARN_ERROR_RETURN_TYPE -Werror=return-type
1896 C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare
1897 C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
1898 C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
1899 C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes
1900 C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes
1901 C_WARN_UNUSED_PARAMETER -Wunused-parameter
1902 C_WARN_UNDEF -Wundef
1903 C_WARN_UNDEF_PREFIX -Wundef-prefix
1905 C_WARN_ERROR_UNGUARDED_AVAILABILITY_NEW -Werror=unguarded-availability-new
1908 add_check_cxx_compiler_flags(
1912 # Using C++20 features while having C++17 as the project language isn't allowed by MSVC.
1913 CXX_CXX20_DESIGNATOR -Wc++20-designator
1915 CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare
1916 CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
1917 CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
1919 # We get a lot of these, if its a problem a dev needs to look into it.
1920 CXX_WARN_NO_OVERLOADED_VIRTUAL -Wno-overloaded-virtual
1922 CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
1923 CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
1925 # Apple Clang (tested on version 12) doesn't support this flag while LLVM Clang 11 does.
1926 CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override
1928 CXX_WARN_UNDEF -Wundef
1929 CXX_WARN_UNDEF_PREFIX -Wundef-prefix
1930 CXX_WARN_UNUSED_PARAMETER -Wunused-parameter
1932 # Prevents linking errors with MSVC.
1933 CXX_WARN_MISMATCHED_TAGS -Wmismatched-tags
1935 # Gives too many unfixable warnings.
1936 # `C_WARN_UNUSED_MACROS -Wunused-macros`
1937 # `CXX_WARN_UNUSED_MACROS -Wunused-macros`
1939 CXX_WARN_ERROR_UNGUARDED_AVAILABILITY_NEW -Werror=unguarded-availability-new
1945 # ---------------------
1946 # Suppress Strict Flags
1948 # flags to undo strict flags
1950 add_check_c_compiler_flags(
1951 C_REMOVE_STRICT_FLAGS
1953 C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
1954 C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
1955 C_WARN_NO_UNUSED_MACROS -Wno-unused-macros
1956 C_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation
1958 C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations
1959 C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers
1960 C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function
1961 C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast
1962 C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes
1963 C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum
1964 C_WARN_NO_UNDEF -Wno-undef
1965 C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn
1966 C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable
1967 C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations
1968 C_WARN_NO_STRICT_PROTOTYPES -Wno-strict-prototypes
1969 C_WARN_NO_BITWISE_INSTEAD_OF_LOGICAL -Wno-bitwise-instead-of-logical
1970 C_WARN_NO_IMPLICIT_CONST_INT_FLOAT_CONVERSION -Wno-implicit-const-int-float-conversion
1971 C_WARN_NO_SINGLE_BIT_BITFIELD_CONSTANT_CONVERSION -Wno-single-bit-bitfield-constant-conversion
1974 add_check_cxx_compiler_flags(
1975 CXX_REMOVE_STRICT_FLAGS
1977 CXX_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
1978 CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field
1979 CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing
1980 CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor
1981 CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros
1982 CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
1983 CXX_WARN_NO_REORDER -Wno-reorder
1984 CXX_WARN_NO_COMMENT -Wno-comment
1985 CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs
1986 CXX_WARN_NO_UNDEFINED_VAR_TEMPLATE -Wno-undefined-var-template
1987 CXX_WARN_NO_INSTANTIATION_AFTER_SPECIALIZATION -Wno-instantiation-after-specialization
1988 CXX_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation
1989 CXX_WARN_NO_BITWISE_INSTEAD_OF_LOGICAL -Wno-bitwise-instead-of-logical
1990 CXX_WARN_NO_IMPLICIT_CONST_INT_FLOAT_CONVERSION -Wno-implicit-const-int-float-conversion
1991 CXX_WARN_NO_UNDEF -Wno-undef
1992 CXX_WARN_NO_UNDEF_PREFIX -Wno-undef-prefix
1995 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
1997 add_check_c_compiler_flags(
2001 C_WARN_POINTER_ARITH -Wpointer-arith
2002 C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
2005 add_check_cxx_compiler_flags(
2009 CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
2010 CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
2013 # Disable numbered, false positives.
2014 string(APPEND C_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
2015 string(APPEND CXX_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
2016 elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
2017 # most msvc warnings are C & C++
2021 "/w34062" # switch statement contains 'default' but no 'case' labels
2022 "/w34100" # 'identifier' : unreferenced formal parameter
2023 "/w34115" # 'type' : named type definition in parentheses
2024 "/w34189" # local variable is initialized but not referenced
2025 # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017
2026 "/w35038" # order of initialization in c++ constructors
2028 "/wd4018" # signed/unsigned mismatch
2029 "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
2030 "/wd4065" # switch statement contains 'default' but no 'case' labels
2031 "/wd4127" # conditional expression is constant
2032 "/wd4181" # qualifier applied to reference type; ignored
2033 "/wd4200" # zero-sized array in struct/union
2034 "/wd4244" # conversion from 'type1' to 'type2', possible loss of data
2035 "/wd4267" # conversion from 'size_t' to 'type', possible loss of data
2036 "/wd4305" # truncation from 'type1' to 'type2'
2037 "/wd4800" # forcing value to bool 'true' or 'false'
2038 "/wd4828" # The file contains a character that is illegal
2039 "/wd4996" # identifier was declared deprecated
2040 "/wd4661" # no suitable definition provided for explicit template instantiation request
2041 "/wd4848" # 'no_unique_address' is a vendor extension in C++17
2043 "/we4013" # 'function' undefined; assuming extern returning int
2044 "/we4133" # incompatible pointer types
2045 "/we4431" # missing type specifier - int assumed
2046 "/we4033" # 'function' must return a value
2049 string(REPLACE ";" " " _WARNINGS "${_WARNINGS}")
2050 set(C_WARNINGS "${_WARNINGS}")
2051 set(CXX_WARNINGS "${_WARNINGS}")
2055 # Xcode enables additional warning flags by default. Disable some to match
2056 # command line build and other platforms more closely.
2058 set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO)
2061 # ensure python header is found since detection can fail, this could happen
2062 # with _any_ library but since we used a fixed python version this tends to
2063 # be most problematic.
2065 if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
2068 "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
2069 "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
2070 "to a valid python include path. Containing "
2071 "Python.h for python version \"${PYTHON_VERSION}\""
2076 # Always use numpy bundled in precompiled libs.
2077 elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR WITH_PYTHON_NUMPY)
2078 if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
2079 find_python_package(numpy "core/include")
2084 # Always copy from precompiled libs.
2085 elseif(WITH_PYTHON_INSTALL_REQUESTS)
2086 find_python_package(requests "")
2090 # Always copy from precompiled libs.
2091 elseif(WITH_PYTHON_INSTALL_ZSTANDARD)
2092 find_python_package(zstandard "")
2096 # Select C++17 as the standard for C++ projects.
2097 set(CMAKE_CXX_STANDARD 17)
2098 # If C++17 is not available, downgrading to an earlier standard is NOT OK.
2099 set(CMAKE_CXX_STANDARD_REQUIRED ON)
2100 # Do not enable compiler specific language extensions.
2101 set(CMAKE_CXX_EXTENSIONS OFF)
2103 # Make MSVC properly report the value of the __cplusplus preprocessor macro
2104 # Available MSVC 15.7 (1914) and up, without this it reports 199711L regardless
2105 # of the C++ standard chosen above.
2107 string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus")
2110 # Visual Studio has all standards it supports available by default
2111 # Clang on windows copies this behavior and does not support these switches
2113 CMAKE_COMPILER_IS_GNUCC OR
2114 (CMAKE_C_COMPILER_ID MATCHES "Clang" AND (NOT MSVC)) OR
2115 (CMAKE_C_COMPILER_ID MATCHES "Intel")
2117 # Use C11 + GNU extensions, works with GCC, Clang, ICC
2118 string(APPEND CMAKE_C_FLAGS " -std=gnu11")
2121 if(WITH_COMPILER_SHORT_FILE_MACRO)
2122 # Use '-fmacro-prefix-map' for Clang and GCC (MSVC doesn't support this).
2123 set(C_PREFIX_MAP_FLAGS "")
2124 set(CXX_PREFIX_MAP_FLAGS "")
2125 add_check_c_compiler_flags(
2127 C_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar
2129 add_check_cxx_compiler_flags(
2130 CXX_PREFIX_MAP_FLAGS
2131 CXX_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar
2133 if(C_MACRO_PREFIX_MAP AND CXX_MACRO_PREFIX_MAP)
2135 if(XCODE AND ${XCODE_VERSION} VERSION_LESS 12.0)
2136 # Developers may have say LLVM Clang-10.0.1 toolchain (which supports the flag)
2137 # with Xcode-11 (the Clang of which doesn't support the flag).
2140 "-fmacro-prefix-map flag is NOT supported by Clang shipped with Xcode-${XCODE_VERSION}."
2141 " Some Xcode functionality in Product menu may not work. "
2142 "Disabling WITH_COMPILER_SHORT_FILE_MACRO."
2144 set(WITH_COMPILER_SHORT_FILE_MACRO OFF)
2147 if(WITH_COMPILER_SHORT_FILE_MACRO)
2148 path_ensure_trailing_slash(_src_dir "${CMAKE_SOURCE_DIR}")
2149 path_ensure_trailing_slash(_bin_dir "${CMAKE_BINARY_DIR}")
2150 # Keep this variable so it can be stripped from build-info.
2151 set(PLATFORM_CFLAGS_FMACRO_PREFIX_MAP
2152 "-fmacro-prefix-map=\"${_src_dir}\"=\"\" -fmacro-prefix-map=\"${_bin_dir}\"=\"\"")
2153 string(APPEND PLATFORM_CFLAGS " ${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}")
2160 "-fmacro-prefix-map flag is NOT supported by C/C++ compiler."
2161 " Disabling WITH_COMPILER_SHORT_FILE_MACRO."
2163 set(WITH_COMPILER_SHORT_FILE_MACRO OFF)
2165 unset(C_PREFIX_MAP_FLAGS)
2166 unset(CXX_PREFIX_MAP_FLAGS)
2169 # Include warnings first, so its possible to disable them with user defined flags
2170 # eg: -Wno-uninitialized
2171 set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
2172 set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}")
2174 # defined above, platform specific but shared names
2192 # -------------------------------------------------------------------------------
2195 # better not set includes here but this debugging option is off by default.
2196 if(WITH_CXX_GUARDEDALLOC)
2197 include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
2198 add_definitions(-DWITH_CXX_GUARDEDALLOC)
2201 if(WITH_ASSERT_ABORT)
2202 add_definitions(-DWITH_ASSERT_ABORT)
2205 # NDEBUG is the standard C define to disable asserts.
2206 if(WITH_ASSERT_RELEASE)
2207 # CMake seemingly be setting the NDEBUG flag on its own already on some configurations
2208 # therefore we need to remove the flags if they happen to be set.
2209 remove_cc_flag("-DNDEBUG") # GCC/CLang
2210 remove_cc_flag("/DNDEBUG") # MSVC
2212 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
2213 $<$<CONFIG:Release>:NDEBUG>
2214 $<$<CONFIG:MinSizeRel>:NDEBUG>
2215 $<$<CONFIG:RelWithDebInfo>:NDEBUG>
2219 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
2220 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
2222 # -----------------------------------------------------------------------------
2225 include(build_files/cmake/testing.cmake)
2227 # -----------------------------------------------------------------------------
2228 # Add Sub-Directories
2231 add_subdirectory(intern)
2232 add_subdirectory(extern)
2234 # source after intern and extern to gather all
2235 # internal and external library information first, for test linking
2236 add_subdirectory(source)
2237 elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
2238 add_subdirectory(intern/guardedalloc)
2239 add_subdirectory(intern/libc_compat)
2240 add_subdirectory(intern/sky)
2242 add_subdirectory(intern/cycles)
2243 if(WITH_CYCLES_LOGGING)
2244 if(NOT WITH_SYSTEM_GFLAGS)
2245 add_subdirectory(extern/gflags)
2247 add_subdirectory(extern/glog)
2249 if(WITH_CUDA_DYNLOAD)
2250 add_subdirectory(extern/cuew)
2252 if(WITH_HIP_DYNLOAD)
2253 add_subdirectory(extern/hipew)
2258 # -----------------------------------------------------------------------------
2259 # Add Testing Directory
2261 add_subdirectory(tests)
2264 # -----------------------------------------------------------------------------
2265 # Add Blender Application
2268 add_subdirectory(source/creator)
2272 # -----------------------------------------------------------------------------
2273 # Define 'heavy' sub-modules (for Ninja builder when using pools)
2274 setup_heavy_lib_pool()
2277 # -----------------------------------------------------------------------------
2278 # CPack for generating packages
2280 include(build_files/cmake/packaging.cmake)
2283 # -----------------------------------------------------------------------------
2284 # Use Dynamic Loading for OpenMP
2287 openmp_delayload(blender)
2291 # -----------------------------------------------------------------------------
2292 # Print Final Configuration
2296 set(_config_msg "\nBlender Configuration\n=====================")
2298 function(info_cfg_option
2302 set(_msg " - ${_setting}")
2303 string(LENGTH "${_msg}" _len)
2304 while("36" GREATER "${_len}")
2305 string(APPEND _msg " ")
2306 math(EXPR _len "${_len} + 1")
2309 set(_config_msg "${_config_msg}\n${_msg}${${_setting}}" PARENT_SCOPE)
2312 function(info_cfg_text
2316 set(_config_msg "${_config_msg}\n\n ${_text}" PARENT_SCOPE)
2319 message(STATUS "C Compiler: \"${CMAKE_C_COMPILER_ID}\"")
2320 message(STATUS "C++ Compiler: \"${CMAKE_CXX_COMPILER_ID}\"")
2322 info_cfg_text("Build Options:")
2323 info_cfg_option(WITH_ALEMBIC)
2324 info_cfg_option(WITH_BULLET)
2325 info_cfg_option(WITH_CLANG)
2326 info_cfg_option(WITH_CYCLES)
2327 info_cfg_option(WITH_FFTW3)
2328 info_cfg_option(WITH_FREESTYLE)
2329 info_cfg_option(WITH_GMP)
2330 info_cfg_option(WITH_HARU)
2331 info_cfg_option(WITH_IK_ITASC)
2332 info_cfg_option(WITH_IK_SOLVER)
2333 info_cfg_option(WITH_INPUT_NDOF)
2334 info_cfg_option(WITH_INPUT_IME)
2335 info_cfg_option(WITH_INTERNATIONAL)
2336 info_cfg_option(WITH_OPENCOLLADA)
2337 info_cfg_option(WITH_OPENCOLORIO)
2338 info_cfg_option(WITH_OPENIMAGEDENOISE)
2339 info_cfg_option(WITH_OPENVDB)
2340 info_cfg_option(WITH_POTRACE)
2341 info_cfg_option(WITH_PUGIXML)
2342 info_cfg_option(WITH_QUADRIFLOW)
2343 info_cfg_option(WITH_TBB)
2344 info_cfg_option(WITH_USD)
2345 info_cfg_option(WITH_MATERIALX)
2346 info_cfg_option(WITH_XR_OPENXR)
2348 info_cfg_text("Compiler Options:")
2349 info_cfg_option(WITH_BUILDINFO)
2350 info_cfg_option(WITH_OPENMP)
2352 info_cfg_text("System Options:")
2353 info_cfg_option(WITH_INSTALL_PORTABLE)
2354 info_cfg_option(WITH_MEM_JEMALLOC)
2355 info_cfg_option(WITH_MEM_VALGRIND)
2357 info_cfg_text("GHOST Options:")
2358 info_cfg_option(WITH_GHOST_DEBUG)
2359 info_cfg_option(WITH_GHOST_SDL)
2360 if(UNIX AND NOT APPLE)
2361 info_cfg_option(WITH_GHOST_X11)
2362 info_cfg_option(WITH_GHOST_WAYLAND)
2364 info_cfg_option(WITH_GHOST_XDND)
2365 info_cfg_option(WITH_X11_XF86VMODE)
2366 info_cfg_option(WITH_X11_XFIXES)
2367 info_cfg_option(WITH_X11_XINPUT)
2369 if(WITH_GHOST_WAYLAND)
2370 info_cfg_option(WITH_GHOST_WAYLAND_DYNLOAD)
2371 info_cfg_option(WITH_GHOST_WAYLAND_LIBDECOR)
2375 info_cfg_text("Image Formats:")
2376 info_cfg_option(WITH_IMAGE_CINEON)
2377 info_cfg_option(WITH_IMAGE_OPENEXR)
2378 info_cfg_option(WITH_IMAGE_OPENJPEG)
2380 info_cfg_text("Audio:")
2381 info_cfg_option(WITH_CODEC_AVI)
2382 info_cfg_option(WITH_CODEC_FFMPEG)
2383 info_cfg_option(WITH_CODEC_SNDFILE)
2384 info_cfg_option(WITH_COREAUDIO)
2385 info_cfg_option(WITH_JACK)
2386 info_cfg_option(WITH_JACK_DYNLOAD)
2387 info_cfg_option(WITH_OPENAL)
2388 info_cfg_option(WITH_PULSEAUDIO)
2389 info_cfg_option(WITH_PULSEAUDIO_DYNLOAD)
2390 info_cfg_option(WITH_SDL)
2391 info_cfg_option(WITH_SDL_DYNLOAD)
2392 info_cfg_option(WITH_WASAPI)
2394 info_cfg_text("Compression:")
2395 info_cfg_option(WITH_LZMA)
2396 info_cfg_option(WITH_LZO)
2399 info_cfg_text("Python:")
2400 info_cfg_option(WITH_PYTHON_INSTALL)
2401 info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
2402 info_cfg_option(WITH_PYTHON_INSTALL_ZSTANDARD)
2403 info_cfg_option(WITH_PYTHON_MODULE)
2404 info_cfg_option(WITH_PYTHON_SAFETY)
2407 info_cfg_text("Modifiers:")
2408 info_cfg_option(WITH_MOD_FLUID)
2409 info_cfg_option(WITH_MOD_OCEANSIM)
2410 info_cfg_option(WITH_MOD_REMESH)
2412 info_cfg_text("Rendering:")
2413 info_cfg_option(WITH_HYDRA)
2416 info_cfg_text("Rendering (Cycles):")
2417 info_cfg_option(WITH_CYCLES_OSL)
2418 info_cfg_option(WITH_CYCLES_EMBREE)
2419 info_cfg_option(WITH_CYCLES_PATH_GUIDING)
2421 info_cfg_option(WITH_CYCLES_DEVICE_OPTIX)
2422 info_cfg_option(WITH_CYCLES_DEVICE_CUDA)
2423 info_cfg_option(WITH_CYCLES_CUDA_BINARIES)
2424 info_cfg_option(WITH_CYCLES_DEVICE_ONEAPI)
2425 info_cfg_option(WITH_CYCLES_ONEAPI_BINARIES)
2426 info_cfg_option(WITH_CYCLES_DEVICE_HIP)
2427 info_cfg_option(WITH_CYCLES_HIP_BINARIES)
2430 info_cfg_option(WITH_CYCLES_DEVICE_HIPRT)
2436 message("${_config_msg}")
2443 # Should be the last step of configuration.
2444 if(POSTCONFIGURE_SCRIPT)
2445 include(${POSTCONFIGURE_SCRIPT})