Fix: EEVEE-Next: Principled BSDF transmission color applied twice
[blender.git] / CMakeLists.txt
blob7dd796123f24bad579cd80680c2f11142c524e65
1 # SPDX-FileCopyrightText: 2006 Blender Authors
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # -----------------------------------------------------------------------------
6 # Early Initialization
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)
13     message(FATAL_ERROR
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.:"
16       "\n "
17       "\n rm -rf CMakeCache.txt CMakeFiles"
18       "\n cd .."
19       "\n mkdir cmake-make"
20       "\n cd cmake-make"
21       "\n cmake ../blender"
22       "\n "
23       "\n Alternately define WITH_IN_SOURCE_BUILD to force this option (not recommended!)"
24     )
25   endif()
26 endif()
28 cmake_minimum_required(VERSION 3.10)
30 if(NOT EXECUTABLE_OUTPUT_PATH)
31   set(FIRST_RUN TRUE)
32 else()
33   set(FIRST_RUN FALSE)
34 endif()
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.
45 endif()
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")
51 endif()
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 # -----------------------------------------------------------------------------
62 # Set policy
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.
78 if(POLICY CMP0068)
79   cmake_policy(SET CMP0068 NEW)
80 endif()
82 # find_package() uses <PackageName>_ROOT variables.
83 if(POLICY CMP0074)
84   cmake_policy(SET CMP0074 NEW)
85 endif()
87 # find_package() uses uppercase <PackageName>_ROOT variables.
88 if(POLICY CMP0144)
89   cmake_policy(SET CMP0144 NEW)
90 endif()
92 # Install CODE|SCRIPT allow the use of generator expressions.
93 if(POLICY CMP0087)
94   cmake_policy(SET CMP0087 NEW)
95 endif()
98 # -----------------------------------------------------------------------------
99 # Load Blender's Local Macros
101 include(build_files/cmake/macros.cmake)
103 # -----------------------------------------------------------------------------
104 # Initialize Project
106 blender_project_hack_pre()
108 project(Blender)
110 blender_project_hack_post()
112 enable_testing()
115 # -----------------------------------------------------------------------------
116 # Test Compiler Support
118 # Keep in sync with: https://developer.blender.org/docs/handbook/building_blender/
120 if(CMAKE_COMPILER_IS_GNUCC)
121   if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "11.0.0")
122     message(FATAL_ERROR "\
123 The minimum supported version of GCC is 11.0.0, found C compiler: ${CMAKE_C_COMPILER_VERSION}"
124     )
125   endif()
126   if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "11.0.0")
127     message(FATAL_ERROR "\
128 The minimum supported version of GCC is 11.0.0, found C++ compiler${CMAKE_CXX_COMPILER_VERSION}"
129     )
130   endif()
131 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
132   if(CMAKE_COMPILER_IS_GNUCC)
133     if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "8.0")
134       message(FATAL_ERROR "\
135 The minimum supported version of CLANG is 8.0, found C compiler ${CMAKE_C_COMPILER_VERSION}"
136       )
137     endif()
138     if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "8.0")
139       message(FATAL_ERROR "\
140 The minimum supported version of CLANG is 8.0, found C++ compiler ${CMAKE_CXX_COMPILER_VERSION}"
141       )
142     endif()
143   endif()
144 elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
145   if(MSVC_VERSION VERSION_LESS "1928")
146     # MSVC_VERSION is an internal version number, it doesn't map to something
147     # the end user would recognize as a version. Because of this, for MSVC we do
148     # not show the found number. When using our make.bat the actual VS version
149     # will be displayed on the console before starting the build, anyway.
150     message(FATAL_ERROR "The minimum supported version of MSVC is 2019 (16.9.16)")
151   endif()
152 endif()
154 # -----------------------------------------------------------------------------
155 # Test Compiler/Library Features
157 include(build_files/cmake/have_features.cmake)
160 # -----------------------------------------------------------------------------
161 # Redirect Output Files
163 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
164 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)
166 get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
167 if(GENERATOR_IS_MULTI_CONFIG)
168   set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/$<CONFIG>/ CACHE INTERNAL "" FORCE)
169 else()
170   set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/ CACHE INTERNAL "" FORCE)
171 endif()
174 # -----------------------------------------------------------------------------
175 # Set Default Configuration Options
177 get_blender_version()
179 if(WIN32)
180   add_definitions(
181     # This is the app ID used for file registration, given it's used from several modules
182     # there really is no nice way to get this information consistent without a global define.
183     -DBLENDER_WIN_APPID="blender.${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}"
184     # This is the name that will be shown in the taskbar and OpenWith windows UI
185     -DBLENDER_WIN_APPID_FRIENDLY_NAME="Blender ${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}"
186   )
187 endif()
190 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19")
191   # This changes the default value from Off to On, but will still allow people to manually change
192   # this setting through their CMakeCache.txt if they desire to do so.
193   set(CMAKE_OPTIMIZE_DEPENDENCIES ON CACHE INTERNAL "")
194 endif()
196 # -----------------------------------------------------------------------------
197 # Declare Options
199 # Blender internal features
200 option(WITH_BLENDER "Build blender (disable to build only Cycles stand-alone)." ON)
201 mark_as_advanced(WITH_BLENDER)
203 if(WIN32)
204   option(WITH_BLENDER_THUMBNAILER "\
205 Build \"BlendThumb.dll\" helper for Windows explorer integration to support extracting \
206 thumbnails from `.blend` files."
207     ON
208   )
209 else()
210   set(_option_default ON)
211   if(APPLE)
212     # In future, can be used with `quicklookthumbnailing/qlthumbnailreply`
213     # to create file thumbnails for say Finder.
214     # Turn it off for now, even though it can build on APPLE, it's not likely to be useful.
215     set(_option_default OFF)
216   endif()
217   option(WITH_BLENDER_THUMBNAILER "\
218 Build stand-alone \"blender-thumbnailer\" command-line thumbnail extraction utility, \
219 intended for use by file-managers to extract PNG images from `.blend` files."
220     ${_option_default}
221   )
222   unset(_option_default)
223 endif()
225 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
227 option(WITH_PYTHON "Enable Embedded Python API (only disable for development)" ON)
228 option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON)
229 # Don't want people disabling this unless they really know what they are doing.
230 mark_as_advanced(WITH_PYTHON)
231 # Some distributions see this as a security issue, rather than have them patch it,
232 # make a build option.
233 mark_as_advanced(WITH_PYTHON_SECURITY)
235 option(WITH_PYTHON_SAFETY "\
236 Enable internal API error checking to track invalid data to prevent crash on access \
237 (at the expense of some efficiency, only enable for development)."
238   OFF
240 mark_as_advanced(WITH_PYTHON_SAFETY)
241 option(WITH_PYTHON_MODULE "\
242 Enable building as a python module which runs without a user interface, \
243 like running regular blender in background mode (only enable for development), \
244 installs to PYTHON_SITE_PACKAGES (or CMAKE_INSTALL_PREFIX if WITH_INSTALL_PORTABLE is enabled)."
245   OFF
248 option(WITH_BUILDINFO "\
249 Include extra build details (only disable for development & faster builds)"
250   ON
252 set(BUILDINFO_OVERRIDE_DATE "" CACHE STRING "\
253 Use instead of the current date for reproducible builds (empty string disables this option)"
255 set(BUILDINFO_OVERRIDE_TIME "" CACHE STRING "\
256 Use instead of the current time for reproducible builds (empty string disables this option)"
258 set(CPACK_OVERRIDE_PACKAGENAME "" CACHE STRING "\
259 Use instead of the standard packagename (empty string disables this option)"
261 mark_as_advanced(CPACK_OVERRIDE_PACKAGENAME)
262 mark_as_advanced(BUILDINFO_OVERRIDE_DATE)
263 mark_as_advanced(BUILDINFO_OVERRIDE_TIME)
265 # CMAKE 3.28.2 has issues with the combination of PCH and unity builds, disable for now.
266 # upstream ticket https://gitlab.kitware.com/cmake/cmake/-/issues/25650
267 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16" AND NOT ${CMAKE_VERSION} VERSION_EQUAL "3.28.2")
268   option(WITH_UNITY_BUILD "\
269 Enable unity build for modules that support it to improve compile times.\n\
270 WARNING: this option allows files to be built without all necessary headers!\n
271 This option should be disabled before manipulating or removing headers."
272     ON
273   )
274   mark_as_advanced(WITH_UNITY_BUILD)
275 else()
276   set(WITH_UNITY_BUILD OFF)
277 endif()
279 if(COMMAND target_precompile_headers)
280   # Disabling is needed for `./tools/utils_maintenance/code_clean.py` to function.
281   option(WITH_COMPILER_PRECOMPILED_HEADERS "\
282 Use pre-compiled headers to speed up compilation."
283     ON
284   )
285   mark_as_advanced(WITH_COMPILER_PRECOMPILED_HEADERS)
287   if(WITH_CLANG_TIDY AND CMAKE_COMPILER_IS_GNUCC)
288     if(WITH_COMPILER_PRECOMPILED_HEADERS)
289       message(STATUS
290         "Clang-Tidy and GCC precompiled headers are incompatible, disabling precompiled headers"
291       )
292       set(WITH_COMPILER_PRECOMPILED_HEADERS OFF)
293     endif()
294   endif()
296   if(NOT WITH_COMPILER_PRECOMPILED_HEADERS)
297     set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON)
298   endif()
299 endif()
301 option(WITH_IK_ITASC "\
302 Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)"
303   ON
305 option(WITH_IK_SOLVER "\
306 Enable Legacy IK solver (only disable for development)"
307   ON
309 option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ON)
310 option(WITH_PUGIXML "Enable PugiXML support (Used for OpenImageIO, Grease Pencil SVG export)" ON)
311 option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
312 option(WITH_SYSTEM_BULLET "\
313 Use the systems bullet library (currently unsupported due to missing features in upstream!)"
314   OFF
316 mark_as_advanced(WITH_SYSTEM_BULLET)
317 option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ON)
319 set(_option_default ON)
320 if(APPLE)
321   # There's no OpenXR runtime in sight for macOS, neither is code well
322   # tested there -> disable it by default.
323   set(_option_default OFF)
324 endif()
325 option(WITH_XR_OPENXR "Enable VR features through the OpenXR specification" ${_option_default})
326 if(APPLE)
327   mark_as_advanced(WITH_XR_OPENXR)
328 endif()
329 unset(_option_default)
331 option(WITH_GMP "Enable features depending on GMP (Exact Boolean)" ON)
333 # Compositor
334 option(WITH_COMPOSITOR_CPU "Enable the tile based CPU nodal compositor" ON)
335 option(WITH_OPENIMAGEDENOISE "Enable the OpenImageDenoise compositing node" ON)
337 option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" ON)
339 option(WITH_POTRACE "Enable features relying on potrace" ON)
340 option(WITH_OPENVDB "Enable features relying on OpenVDB" ON)
341 option(WITH_OPENVDB_BLOSC "\
342 Enable blosc compression for OpenVDB, only enable if OpenVDB was built with blosc support"
343   ON
345 option(WITH_OPENVDB_3_ABI_COMPATIBLE "\
346 Assume OpenVDB library has been compiled with version 3 ABI compatibility"
347   OFF
349 mark_as_advanced(WITH_OPENVDB_3_ABI_COMPATIBLE)
350 option(WITH_NANOVDB "Enable usage of NanoVDB data structure for rendering on the GPU" ON)
351 option(WITH_HARU "Enable features relying on Libharu (Grease pencil PDF export)" ON)
353 # GHOST Windowing Library Options
354 option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF)
355 mark_as_advanced(WITH_GHOST_DEBUG)
357 option(WITH_GHOST_SDL "\
358 Enable building Blender against SDL for windowing rather than the native APIs"
359   OFF
361 mark_as_advanced(WITH_GHOST_SDL)
363 if(UNIX AND NOT (APPLE OR HAIKU))
364   option(WITH_GHOST_X11 "Enable building Blender against X11 for windowing" ON)
365   mark_as_advanced(WITH_GHOST_X11)
367   option(WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing" ON)
368   mark_as_advanced(WITH_GHOST_WAYLAND)
370   if(WITH_GHOST_WAYLAND)
371     option(WITH_GHOST_WAYLAND_LIBDECOR "Optionally build with LibDecor window decorations" ON)
372     mark_as_advanced(WITH_GHOST_WAYLAND_LIBDECOR)
374     option(WITH_GHOST_WAYLAND_DYNLOAD "Enable runtime dynamic WAYLAND libraries loading" ON)
375     mark_as_advanced(WITH_GHOST_WAYLAND_DYNLOAD)
377     set(WITH_GHOST_WAYLAND_APP_ID "" CACHE STRING "\
378 The application ID used for Blender (use default when an empty string), \
379 this can be used to differentiate Blender instances by version or branch for example."
380     )
381     mark_as_advanced(WITH_GHOST_WAYLAND_APP_ID)
382   endif()
383 endif()
385 if(WITH_GHOST_X11)
386   option(WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON)
387 endif()
389 # Misc...
390 option(WITH_HEADLESS "Build without graphical support (renderfarm, server mode only)" OFF)
391 mark_as_advanced(WITH_HEADLESS)
393 option(WITH_QUADRIFLOW "Build with quadriflow remesher support" ON)
395 option(WITH_AUDASPACE "\
396 Build with blenders audio library (only disable if you know what you're doing!)"
397   ON
399 option(WITH_SYSTEM_AUDASPACE "\
400 Build with external audaspace library installed on the system \
401 (only enable if you know what you're doing!)"
402   OFF
404 mark_as_advanced(WITH_AUDASPACE)
405 mark_as_advanced(WITH_SYSTEM_AUDASPACE)
407 set_and_warn_dependency(WITH_AUDASPACE WITH_SYSTEM_AUDASPACE OFF)
409 option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON)
410 if(UNIX AND NOT APPLE)
411   option(WITH_OPENMP_STATIC "Link OpenMP statically (only used by the release environment)" OFF)
412   mark_as_advanced(WITH_OPENMP_STATIC)
413 endif()
415 if(WITH_GHOST_X11)
416   option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
417   option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON)
418   option(WITH_X11_XFIXES "Enable X11 XWayland cursor warping workaround" ON)
419 endif()
421 if(UNIX AND NOT APPLE)
422   option(WITH_SYSTEM_FREETYPE "Use the freetype library provided by the operating system" OFF)
423   option(WITH_SYSTEM_EIGEN3 "Use the systems Eigen3 library" OFF)
424 else()
425   set(WITH_SYSTEM_FREETYPE OFF)
426   set(WITH_SYSTEM_EIGEN3 OFF)
427 endif()
429 if((NOT WITH_PYTHON_MODULE) AND (
430       (WIN32 AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")) OR
431       ((UNIX AND NOT APPLE) AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"))))
432   option(WITH_CPU_CHECK "\
433 Report when a CPU is not compatible on startup \
434 instead of failing to start with an inscrutable error."
435     ON
436   )
437   mark_as_advanced(WITH_CPU_CHECK)
438 else()
439   set(WITH_CPU_CHECK OFF)
440 endif()
442 # Modifiers
443 option(WITH_MOD_FLUID "Enable Mantaflow Fluid Simulation Framework" ON)
444 option(WITH_MOD_REMESH "Enable Remesh Modifier" ON)
445 option(WITH_MOD_OCEANSIM "Enable Ocean Modifier" ON)
447 # Image format support
448 option(WITH_IMAGE_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON)
449 option(WITH_IMAGE_OPENJPEG "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
450 option(WITH_IMAGE_CINEON "Enable CINEON and DPX Image Support" ON)
451 option(WITH_IMAGE_WEBP "Enable WebP Image Support" ON)
453 # Audio/Video format support
454 option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" ON)
455 option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" ON)
457 # Alembic support
458 option(WITH_ALEMBIC "Enable Alembic Support" ON)
460 # Universal Scene Description support
461 option(WITH_USD "Enable Universal Scene Description (USD) Support" ON)
463 # MaterialX
464 option(WITH_MATERIALX "Enable MaterialX Support" ON)
466 # Hydra render engine
467 option(WITH_HYDRA "Enable Hydra render engine" ON)
469 # RTL Languages, Complex Shaping, OpenType Features
470 option(WITH_FRIBIDI "Enable features relying on fribidi" OFF)
471 option(WITH_HARFBUZZ "Enable features relying on harfbuzz" OFF)
473 # 3D format support
474 # Disable opencollada when we don't have precompiled libs
475 option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ON)
476 option(WITH_IO_WAVEFRONT_OBJ "Enable Wavefront-OBJ 3D file format support (*.obj)" ON)
477 option(WITH_IO_PLY "Enable PLY 3D file format support (*.ply)" ON)
478 option(WITH_IO_STL "Enable STL 3D file format support (*.stl)" ON)
479 option(WITH_IO_GPENCIL "Enable grease-pencil file format IO (*.svg, *.pdf)" ON)
481 # Sound output
482 option(WITH_SDL "Enable SDL for sound" ON)
483 option(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON)
484 if(APPLE)
485   option(WITH_COREAUDIO "Enable CoreAudio for audio support on macOS" ON)
486 else()
487   set(WITH_COREAUDIO OFF)
488 endif()
489 if(NOT WIN32)
490   set(_option_default ON)
491   if(APPLE)
492     set(_option_default OFF)
493   endif()
494   option(WITH_JACK "Enable JACK Support (http://www.jackaudio.org)" ${_option_default})
495   unset(_option_default)
496   option(WITH_JACK_DYNLOAD "Enable runtime dynamic JACK libraries loading" OFF)
497 else()
498   set(WITH_JACK OFF)
499 endif()
500 if(UNIX AND NOT APPLE)
501   option(WITH_SDL_DYNLOAD "Enable runtime dynamic SDL libraries loading" OFF)
502 endif()
503 if(UNIX AND NOT APPLE)
504   option(WITH_PULSEAUDIO "Enable PulseAudio for audio support on Linux" ON)
505   option(WITH_PULSEAUDIO_DYNLOAD "Enable runtime dynamic PulseAudio libraries loading" OFF)
506 else()
507   set(WITH_PULSEAUDIO OFF)
508 endif()
509 if(WIN32)
510   option(WITH_WASAPI "Enable Windows Audio Sessions API for audio support on Windows" ON)
511 else()
512   set(WITH_WASAPI OFF)
513 endif()
515 # Compression
516 option(WITH_LZO "Enable fast LZO compression (used for pointcache)" ON)
517 option(WITH_LZMA "Enable best LZMA compression, (used for pointcache)" ON)
518 if(UNIX AND NOT APPLE)
519   option(WITH_SYSTEM_LZO "Use the system LZO library" OFF)
520 endif()
521 option(WITH_DRACO "Enable Draco mesh compression Python module (used for glTF)" ON)
523 # Camera/motion tracking
524 option(WITH_LIBMV "Enable Libmv structure from motion library" ON)
525 option(WITH_LIBMV_SCHUR_SPECIALIZATIONS "Enable fixed-size schur specializations." ON)
526 mark_as_advanced(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
528 # Logging/unbit test libraries.
529 option(WITH_SYSTEM_GFLAGS "Use system-wide Gflags instead of a bundled one" OFF)
530 option(WITH_SYSTEM_GLOG "Use system-wide Glog instead of a bundled one" OFF)
531 mark_as_advanced(WITH_SYSTEM_GFLAGS)
532 mark_as_advanced(WITH_SYSTEM_GLOG)
534 # Freestyle
535 option(WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON)
537 # Libraries.
538 if(UNIX AND NOT APPLE)
539   # Optionally build without pre-compiled libraries.
540   # NOTE: this could be supported on all platforms however in practice UNIX is the only platform
541   # that has good support for detecting installed libraries.
542   option(WITH_LIBS_PRECOMPILED "\
543 Detect and link against pre-compiled libraries (typically found under \"../lib/\"). \
544 Disabling this option will use the system libraries although cached paths \
545 that point to pre-compiled libraries will be left as-is."
546     ON
547   )
548   mark_as_advanced(WITH_LIBS_PRECOMPILED)
550   option(WITH_STATIC_LIBS "\
551 Try to link with static libraries, as much as possible, \
552 to make blender more portable across distributions"
553     OFF
554   )
555   if(WITH_STATIC_LIBS)
556     option(WITH_BOOST_ICU "\
557 Boost uses ICU library (required for linking with static Boost built with libicu)."
558       OFF
559     )
560     mark_as_advanced(WITH_BOOST_ICU)
561   endif()
562 endif()
564 # Misc
565 if(WIN32 OR APPLE OR ((UNIX AND (NOT HAIKU)) AND WITH_GHOST_WAYLAND))
566   option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
567 else()
568   set(WITH_INPUT_IME OFF)
569 endif()
570 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ON)
571 # On Windows and for the Blender application on macOS, portable install
572 # is the only supported installation type, so there is no option.
573 if(UNIX AND (NOT APPLE OR WITH_PYTHON_MODULE))
574   option(WITH_INSTALL_PORTABLE "\
575 Install redistributable runtime, otherwise install into CMAKE_INSTALL_PREFIX"
576     ON
577   )
578 endif()
580 option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON)
582 option(WITH_INSTALL_COPYRIGHT "\
583 Copy the official Blender Authors's copyright.txt into the Blender install folder"
584   OFF
586 mark_as_advanced(WITH_INSTALL_COPYRIGHT)
588 if((WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE) OR WITH_MOD_FLUID)
589   option(WITH_PYTHON_NUMPY "Include NumPy in Blender (used by Audaspace and Mantaflow)" ON)
590 endif()
592 if(WIN32 OR APPLE)
593   # Windows and macOS have this bundled with Python libraries.
594 elseif(WITH_PYTHON_INSTALL OR WITH_PYTHON_NUMPY)
595   set(PYTHON_NUMPY_PATH "" CACHE PATH "\
596 Path to python site-packages or dist-packages containing 'numpy' module"
597   )
598   mark_as_advanced(PYTHON_NUMPY_PATH)
599   set(PYTHON_NUMPY_INCLUDE_DIRS "" CACHE PATH "Path to the include directory of the NumPy module")
600   mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS)
601 endif()
602 if(WITH_PYTHON_INSTALL)
603   option(WITH_PYTHON_INSTALL_NUMPY "Copy system NumPy into the blender install folder" ON)
605   if(UNIX AND NOT APPLE)
606     option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON)
607     set(PYTHON_REQUESTS_PATH "" CACHE PATH "\
608 Path to python site-packages or dist-packages containing 'requests' module"
609     )
610     mark_as_advanced(PYTHON_REQUESTS_PATH)
611   endif()
613   option(WITH_PYTHON_INSTALL_ZSTANDARD "Copy zstandard into the blender install folder" ON)
614   set(PYTHON_ZSTANDARD_PATH "" CACHE PATH "\
615 Path to python site-packages or dist-packages containing 'zstandard' module"
616   )
617   mark_as_advanced(PYTHON_ZSTANDARD_PATH)
618 endif()
620 option(WITH_CPU_SIMD "Enable SIMD instruction if they're detected on the host machine" ON)
621 mark_as_advanced(WITH_CPU_SIMD)
623 # Cycles
624 option(WITH_CYCLES "Enable Cycles Render Engine" ON)
625 option(WITH_CYCLES_OSL "Build Cycles with OpenShadingLanguage support" ON)
626 option(WITH_CYCLES_PATH_GUIDING "Build Cycles with path guiding support" ON)
627 option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON)
628 option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
629 option(WITH_CYCLES_DEBUG "Build Cycles with options useful for debugging (e.g., MIS)" OFF)
631 option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
632 option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
633 option(WITH_CYCLES_PRECOMPUTE "Build Cycles data precomputation tool" OFF)
635 option(WITH_CYCLES_HYDRA_RENDER_DELEGATE "Build Cycles Hydra render delegate" OFF)
637 option(WITH_CYCLES_DEBUG_NAN "\
638 Build Cycles with additional asserts for detecting NaNs and invalid values"
639   OFF
641 option(WITH_CYCLES_NATIVE_ONLY "\
642 Build Cycles with native kernel only (which fits current CPU, use for development only)"
643   OFF
645 option(WITH_CYCLES_KERNEL_ASAN "\
646 Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow"
647   OFF
649 set(CYCLES_TEST_DEVICES CPU CACHE STRING "\
650 Run regression tests on the specified device types (CPU CUDA OPTIX HIP)"
652 mark_as_advanced(WITH_CYCLES_KERNEL_ASAN)
653 mark_as_advanced(WITH_CYCLES_LOGGING)
654 mark_as_advanced(WITH_CYCLES_DEBUG_NAN)
655 mark_as_advanced(WITH_CYCLES_NATIVE_ONLY)
656 mark_as_advanced(WITH_CYCLES_PRECOMPUTE)
657 mark_as_advanced(CYCLES_TEST_DEVICES)
659 # NVIDIA CUDA & OptiX
660 if(NOT APPLE AND NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64"))
661   option(WITH_CYCLES_DEVICE_CUDA "Enable Cycles NVIDIA CUDA compute support" ON)
662   option(WITH_CYCLES_DEVICE_OPTIX "Enable Cycles NVIDIA OptiX support" ON)
663   mark_as_advanced(WITH_CYCLES_DEVICE_CUDA)
665   option(WITH_CYCLES_CUDA_BINARIES "Build Cycles NVIDIA CUDA binaries" OFF)
666   set(CYCLES_CUDA_BINARIES_ARCH
667     sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 sm_89 compute_75
668     CACHE STRING "CUDA architectures to build binaries for"
669   )
670   option(WITH_CYCLES_CUDA_BUILD_SERIAL "\
671 Build cubins one after another (useful on machines with limited RAM)"
672     OFF
673   )
674   option(WITH_CUDA_DYNLOAD "\
675 Dynamically load CUDA libraries at runtime (for developers, makes cuda-gdb work)"
676     ON
677   )
679   set(OPTIX_ROOT_DIR "" CACHE PATH "\
680 Path to the OptiX SDK root directory, for building Cycles OptiX kernels."
681   )
682   set(CYCLES_RUNTIME_OPTIX_ROOT_DIR "" CACHE PATH "\
683 Path to the OptiX SDK root directory. \
684 When set, this path will be used at runtime to compile OptiX kernels."
685   )
687   mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
688   mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
689   mark_as_advanced(WITH_CUDA_DYNLOAD)
690   mark_as_advanced(OPTIX_ROOT_DIR)
691   mark_as_advanced(CYCLES_RUNTIME_OPTIX_ROOT_DIR)
692 endif()
694 # AMD HIP
695 if(NOT APPLE AND NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64"))
696   option(WITH_CYCLES_DEVICE_HIP "Enable Cycles AMD HIP support" ON)
697   option(WITH_CYCLES_HIP_BINARIES "Build Cycles AMD HIP binaries" OFF)
698   # Radeon VII (gfx906) not currently working with HIP SDK, so left out of the list.
699   set(CYCLES_HIP_BINARIES_ARCH
700     gfx900 gfx90c gfx902
701     gfx1010 gfx1011 gfx1012
702     gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 gfx1036
703     gfx1100 gfx1101 gfx1102 gfx1103
704     CACHE STRING "AMD HIP architectures to build binaries for"
705   )
706   mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
707   mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
709   # HIPRT is only available on Windows for now.
710   if(WIN32)
711     option(WITH_CYCLES_DEVICE_HIPRT "Enable Cycles AMD HIPRT support" OFF)
712     mark_as_advanced(WITH_CYCLES_DEVICE_HIPRT)
713   endif()
714 endif()
716 # Apple Metal
717 if(APPLE)
718   option(WITH_CYCLES_DEVICE_METAL "Enable Cycles Apple Metal compute support" ON)
719 endif()
721 # oneAPI
722 if(NOT APPLE AND NOT (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64"))
723   option(WITH_CYCLES_DEVICE_ONEAPI "Enable Cycles oneAPI compute support" OFF)
724   option(WITH_CYCLES_ONEAPI_BINARIES "\
725 Enable Ahead-Of-Time compilation for Cycles oneAPI device"
726     OFF
727   )
728   option(WITH_CYCLES_ONEAPI_HOST_TASK_EXECUTION "\
729 Switch target of oneAPI implementation from SYCL devices to Host Task (single thread on CPU). \
730 This option is only for debugging purposes."
731     OFF
732   )
734   # 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
735   # The target architectures levels can be retrieved from `ocloc` output when running
736   # `ocloc compile -device {device_id} test.c` for given GPUs PCI device IDs.
737   # 12.55.8 is for Arc Alchemist GPUs. 12.70.4 for Meteor Lake iGPUs.
738   set(CYCLES_ONEAPI_INTEL_BINARIES_ARCH 12.55.8 12.70.4 CACHE STRING "\
739 oneAPI Intel GPU architectures to build binaries for"
740   )
741   set(CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "\
742 oneAPI targets to build AOT binaries for"
743   )
745   mark_as_advanced(WITH_CYCLES_ONEAPI_HOST_TASK_EXECUTION)
746   mark_as_advanced(CYCLES_ONEAPI_INTEL_BINARIES_ARCH)
747   mark_as_advanced(CYCLES_ONEAPI_SYCL_TARGETS)
748 endif()
750 # Draw Manager
751 option(WITH_DRAW_DEBUG "Add extra debug capabilities to Draw Manager" OFF)
752 mark_as_advanced(WITH_DRAW_DEBUG)
754 # LLVM
755 option(WITH_LLVM "Use LLVM" OFF)
756 option(LLVM_STATIC "Link with LLVM static libraries" OFF)
757 mark_as_advanced(LLVM_STATIC)
758 option(WITH_CLANG "Use Clang" OFF)
760 # disable for now, but plan to support on all platforms eventually
761 option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" ON)
762 mark_as_advanced(WITH_MEM_JEMALLOC)
764 # currently only used for BLI_mempool
765 option(WITH_MEM_VALGRIND "Enable extended valgrind support for better reporting" OFF)
766 mark_as_advanced(WITH_MEM_VALGRIND)
768 # Debug
769 option(WITH_CXX_GUARDEDALLOC "\
770 Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)"
771   OFF
773 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
775 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON)
776 mark_as_advanced(WITH_ASSERT_ABORT)
778 option(WITH_ASSERT_RELEASE "Build with asserts enabled even for non-debug configurations" OFF)
779 mark_as_advanced(WITH_ASSERT_RELEASE)
781 if((UNIX AND NOT APPLE) OR (CMAKE_GENERATOR MATCHES "^Visual Studio.+"))
782   option(WITH_CLANG_TIDY "\
783 Use Clang Tidy to analyze the source code \
784 (only enable for development on Linux using Clang, or Windows using the Visual Studio IDE)"
785     OFF
786   )
787   mark_as_advanced(WITH_CLANG_TIDY)
788 endif()
790 option(WITH_BOOST "Enable features depending on boost" ON)
791 option(WITH_TBB "\
792 Enable multi-threading. TBB is also required for features such as Cycles, OpenVDB and USD"
793   ON
796 # TBB malloc is only supported on for windows currently
797 if(WIN32)
798   option(WITH_TBB_MALLOC_PROXY "Enable the TBB malloc replacement" ON)
799 endif()
801 option(WITH_EXPERIMENTAL_FEATURES "Enable experimental features" ON)
803 # This should be turned off when Blender enter beta/rc/release
804 if("${BLENDER_VERSION_CYCLE}" STREQUAL "alpha" AND WITH_EXPERIMENTAL_FEATURES)
805   set(WITH_EXPERIMENTAL_FEATURES ON)
806 else()
807   set(WITH_EXPERIMENTAL_FEATURES OFF)
808 endif()
810 # Unit testing
811 option(WITH_GTESTS "Enable GTest unit testing" OFF)
812 option(WITH_GPU_RENDER_TESTS "\
813 Enable GPU render related unit testing (EEVEE, Workbench and Grease Pencil)"
814   OFF
816 option(WITH_GPU_RENDER_TESTS_SILENT "\
817 Run GPU render tests silently (finished tests will pass). \
818 Generated report will show failing tests"
819   ON
821 option(WITH_GPU_DRAW_TESTS "\
822 Enable GPU drawing related unit testing (GPU backends and draw manager)"
823   OFF
825 option(WITH_COMPOSITOR_REALTIME_TESTS "Enable regression testing for realtime compositor" OFF)
826 if(UNIX AND NOT (APPLE OR HAIKU))
827   option(WITH_UI_TESTS "\
828 Enable user-interface tests using a headless display server. \
829 Currently this depends on WITH_GHOST_WAYLAND and the weston compositor \
830 (Experimental)"
831     OFF
832   )
833 else()
834   # TODO: support running GUI tests on other platforms.
835   set(WITH_UI_TESTS OFF)
836 endif()
838 # Enabled by default for typical use cases to speed up development cycles. However, when looking
839 # into threading or memory related issues (in dependency graph, out-of-bounds, etc) forcing single
840 # test per Blender instance could give much better clues about the root of the problem.
841 option(WITH_TESTS_BATCHED "\
842 Run multiple tests in a single Blender invocation, for faster test execution"
843   ON
845 mark_as_advanced(WITH_TESTS_BATCHED)
847 option(WITH_TESTS_SINGLE_BINARY "\
848 Link GTest tests into a single binary. \
849 For faster overall build and less disk space, but slower individual test build"
850   ON
852 mark_as_advanced(WITH_TESTS_SINGLE_BINARY)
854 # NOTE: All callers of this must add `TEST_PYTHON_EXE_EXTRA_ARGS` before any other arguments.
855 set(TEST_PYTHON_EXE "" CACHE PATH "Python executable to run unit tests")
856 mark_as_advanced(TEST_PYTHON_EXE)
858 # Documentation
859 if(UNIX AND NOT APPLE)
860   option(WITH_DOC_MANPAGE "Create a manual page (Unix manpage)" OFF)
861 endif()
864 # GPU Module
865 option(WITH_GPU_BUILDTIME_SHADER_BUILDER "\
866 Shader builder is a developer option enabling linting on GLSL during compilation"
867   OFF
869 option(WITH_RENDERDOC "Use Renderdoc API to capture frames" OFF)
871 mark_as_advanced(
872   WITH_GPU_BUILDTIME_SHADER_BUILDER
873   WITH_RENDERDOC
876 # OpenGL
877 if(NOT APPLE)
878   option(WITH_OPENGL_BACKEND "Enable OpenGL support as graphic backend" ON)
879   mark_as_advanced(WITH_OPENGL_BACKEND)
880 else()
881   set(WITH_OPENGL_BACKEND OFF)
882 endif()
884 # Vulkan
885 option(WITH_VULKAN_BACKEND "Enable Vulkan as graphics backend (experimental)" ON)
886 option(WITH_VULKAN_GUARDEDALLOC "\
887 Use guardedalloc for host allocations done inside Vulkan (development option)"
888   OFF
890 mark_as_advanced(
891   WITH_VULKAN_BACKEND
892   WITH_VULKAN_GUARDEDALLOC
894 if(APPLE)
895   option(WITH_VULKAN_MOLTENVK "Enable Vulkan over MoltenVK (development option)" OFF)
896   mark_as_advanced(
897     WITH_VULKAN_MOLTENVK
898   )
899 endif()
901 if(APPLE AND NOT WITH_VULKAN_MOLTENVK)
902   set(WITH_VULKAN_BACKEND OFF)
903 endif()
904 if(NOT WITH_EXPERIMENTAL_FEATURES)
905   if(APPLE)
906     set(WITH_VULKAN_MOLTENVK OFF)
907   endif()
908   set(WITH_VULKAN_BACKEND OFF)
909 endif()
911 # Metal
912 if(APPLE)
913   option(WITH_METAL_BACKEND "\
914 Use Metal for graphics instead of (or as well as) OpenGL on macOS."
915     ON
916   )
917   mark_as_advanced(WITH_METAL_BACKEND)
918 else()
919   set(WITH_METAL_BACKEND OFF)
920 endif()
922 if(WIN32)
923   getDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
924   set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
925 endif()
927 option(WITH_STRSIZE_DEBUG "\
928 Ensure string operations on fixed size buffers \
929 (works well with with \"WITH_COMPILER_ASAN\" & valgrind to detect incorrect buffer size arguments)"
930   OFF)
931 mark_as_advanced(WITH_STRSIZE_DEBUG)
933 # Compiler tool-chain.
934 if(UNIX)
935   if(CMAKE_COMPILER_IS_GNUCC)
936     option(WITH_LINKER_GOLD "Use ld.gold linker which is usually faster than ld.bfd" ON)
937     mark_as_advanced(WITH_LINKER_GOLD)
938   endif()
939   if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
940     option(WITH_LINKER_LLD "Use ld.lld linker which is usually faster than ld.gold" OFF)
941     mark_as_advanced(WITH_LINKER_LLD)
942     option(WITH_LINKER_MOLD "Use ld.mold linker which is usually faster than ld.gold & ld.lld" OFF)
943     mark_as_advanced(WITH_LINKER_MOLD)
944   endif()
945 endif()
947 option(WITH_COMPILER_ASAN "\
948 Build and link against address sanitizer (only for Debug & RelWithDebInfo targets)."
949   OFF
951 mark_as_advanced(WITH_COMPILER_ASAN)
952 option(WITH_COMPILER_ASAN_EXTERN "\
953 Build `extern` dependencies with address sanitizer when WITH_COMPILER_ASAN is on. \
954 Can cause linking issues due to too large binary size."
955   OFF
957 mark_as_advanced(WITH_COMPILER_ASAN_EXTERN)
959 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
960   if(WITH_COMPILER_ASAN)
961     set(_asan_defaults "\
962 -fsanitize=address \
963 -fsanitize=bool \
964 -fsanitize=bounds \
965 -fsanitize=enum \
966 -fsanitize=float-cast-overflow \
967 -fsanitize=float-divide-by-zero \
968 -fsanitize=nonnull-attribute \
969 -fsanitize=returns-nonnull-attribute \
970 -fsanitize=signed-integer-overflow \
971 -fsanitize=undefined \
972 -fsanitize=vla-bound \
973 -fno-sanitize=alignment \
976     if(MSVC)
977       # clang-cl doesn't support all sanitizers, but leak and object-size give errors/warnings.
978       set(_asan_defaults "${_asan_defaults}")
979     elseif(APPLE)
980       # AppleClang doesn't support all sanitizers, but leak gives error.
981       # Build type is not known for multi-config generator, so don't add object-size sanitizer.
982       if(CMAKE_BUILD_TYPE MATCHES "Debug" OR GENERATOR_IS_MULTI_CONFIG)
983         # Silence the warning that object-size is not effective in -O0.
984         set(_asan_defaults "${_asan_defaults}")
985       else()
986         string(APPEND _asan_defaults " -fsanitize=object-size")
987       endif()
988     elseif(CMAKE_COMPILER_IS_GNUCC)
989       string(APPEND _asan_defaults " -fsanitize=leak -fsanitize=object-size")
990     else()
991       string(APPEND _asan_defaults " -fsanitize=leak")
992     endif()
994     set(COMPILER_ASAN_CFLAGS "${_asan_defaults}" CACHE STRING "C flags for address sanitizer")
995     mark_as_advanced(COMPILER_ASAN_CFLAGS)
996     set(COMPILER_ASAN_CXXFLAGS "${_asan_defaults}" CACHE STRING "C++ flags for address sanitizer")
997     mark_as_advanced(COMPILER_ASAN_CXXFLAGS)
999     unset(_asan_defaults)
1001     if(MSVC)
1002       find_library(
1003         COMPILER_ASAN_LIBRARY NAMES clang_rt.asan-x86_64
1004         PATHS
1005         [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/7.0.0/lib/windows
1006         [HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\LLVM\\LLVM;]/lib/clang/6.0.0/lib/windows
1007       )
1008       mark_as_advanced(COMPILER_ASAN_LIBRARY)
1009     elseif(APPLE)
1010       execute_process(COMMAND ${CMAKE_CXX_COMPILER}
1011         -print-file-name=lib
1012         OUTPUT_VARIABLE CLANG_LIB_DIR
1013       )
1014       string(STRIP "${CLANG_LIB_DIR}" CLANG_LIB_DIR)
1015       find_library(
1016         COMPILER_ASAN_LIBRARY
1017         NAMES
1018           libclang_rt.asan_osx_dynamic.dylib
1019         PATHS
1020           "${CLANG_LIB_DIR}/darwin/"
1021       )
1022       unset(CLANG_LIB_DIR)
1023       mark_as_advanced(COMPILER_ASAN_LIBRARY)
1024     elseif(CMAKE_COMPILER_IS_GNUCC)
1025       find_library(
1026         COMPILER_ASAN_LIBRARY asan ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}
1027       )
1028       mark_as_advanced(COMPILER_ASAN_LIBRARY)
1029     endif()
1031   endif()
1032 endif()
1034 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
1035   option(WITH_COMPILER_SHORT_FILE_MACRO "\
1036 Make paths in macros like __FILE__ relative to top level source and build directories."
1037     ON
1038   )
1039   mark_as_advanced(WITH_COMPILER_SHORT_FILE_MACRO)
1040 endif()
1042 if(WIN32)
1043   # Use hardcoded paths or find_package to find externals
1044   option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF)
1045   mark_as_advanced(WITH_WINDOWS_FIND_MODULES)
1047   option(WINDOWS_PYTHON_DEBUG "\
1048 Include the files needed for debugging python scripts with visual studio 2017+."
1049     OFF
1050   )
1051   mark_as_advanced(WINDOWS_PYTHON_DEBUG)
1053   option(WITH_WINDOWS_BUNDLE_CRT "Bundle the C runtime for install free distribution." ON)
1054   mark_as_advanced(WITH_WINDOWS_BUNDLE_CRT)
1056   option(WITH_WINDOWS_EXTERNAL_MANIFEST "Use external manifest files" OFF)
1057   mark_as_advanced(WITH_WINDOWS_EXTERNAL_MANIFEST)
1059   option(WITH_WINDOWS_SCCACHE "Use sccache to speed up builds (Ninja builder only)" OFF)
1060   mark_as_advanced(WITH_WINDOWS_SCCACHE)
1062   option(WITH_WINDOWS_RELEASE_PDB "\
1063 Generate a pdb file for client side stacktraces for release builds"
1064     ON
1065   )
1066   mark_as_advanced(WITH_WINDOWS_RELEASE_PDB)
1068   option(WITH_WINDOWS_RELEASE_STRIPPED_PDB "Use a stripped PDB file for release builds" ON)
1069   mark_as_advanced(WITH_WINDOWS_RELEASE_STRIPPED_PDB)
1071 endif()
1073 if(WIN32 OR XCODE)
1074   option(IDE_GROUP_SOURCES_IN_FOLDERS "\
1075 Organize the source files in filters matching the source folders."
1076     ON
1077   )
1078   mark_as_advanced(IDE_GROUP_SOURCES_IN_FOLDERS)
1080   option(IDE_GROUP_PROJECTS_IN_FOLDERS "\
1081 Organize the projects according to source folder structure."
1082     ON
1083   )
1084   mark_as_advanced(IDE_GROUP_PROJECTS_IN_FOLDERS)
1086   if(IDE_GROUP_PROJECTS_IN_FOLDERS)
1087     set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1088   endif()
1089 endif()
1091 if(UNIX)
1092   # See WITH_WINDOWS_SCCACHE for Windows.
1093   option(WITH_COMPILER_CCACHE "\
1094 Use ccache to improve rebuild times (Works with Ninja, Makefiles and Xcode)"
1095     OFF
1096   )
1097   mark_as_advanced(WITH_COMPILER_CCACHE)
1098 endif()
1100 # The following only works with the Ninja generator in CMake >= 3.0.
1101 if("${CMAKE_GENERATOR}" MATCHES "Ninja")
1102   option(WITH_NINJA_POOL_JOBS "\
1103 Enable Ninja pools of jobs, to try to ease building on machines with 16GB of RAM or less \
1104 (if not yet defined, will try to set best values based on detected machine specifications)."
1105     ON
1106   )
1107   mark_as_advanced(WITH_NINJA_POOL_JOBS)
1108 endif()
1110 # Installation process.
1111 set(POSTINSTALL_SCRIPT "" CACHE FILEPATH "Run given CMake script after installation process")
1112 mark_as_advanced(POSTINSTALL_SCRIPT)
1114 set(POSTCONFIGURE_SCRIPT "" CACHE FILEPATH "\
1115 Run given CMake script as the last step of CMake configuration"
1117 mark_as_advanced(POSTCONFIGURE_SCRIPT)
1119 # end option(...)
1123 # By default we want to install to the directory we are compiling our executables
1124 # unless specified otherwise, which we currently do not allow
1125 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
1126   if(WIN32)
1127     set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE} CACHE PATH "\
1128 default install path"
1129       FORCE
1130     )
1131   elseif(APPLE)
1132     set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE} CACHE PATH "\
1133 default install path"
1134       FORCE
1135     )
1136   else()
1137     if(WITH_INSTALL_PORTABLE)
1138       set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH} CACHE PATH "default install path" FORCE)
1139     endif()
1140   endif()
1141 endif()
1143 # Effective install path including config folder, as a generator expression.
1144 get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
1145 if(GENERATOR_IS_MULTI_CONFIG)
1146   string(
1147     REPLACE "\${BUILD_TYPE}" "$<CONFIG>"
1148     CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX}
1149   )
1150 else()
1151   string(
1152     REPLACE "\${BUILD_TYPE}" ""
1153     CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX}
1154   )
1155 endif()
1158 # Apple
1160 if(APPLE)
1161   include(platform_apple_xcode)
1162 endif()
1165 # -----------------------------------------------------------------------------
1166 # Check for Conflicting/Unsupported Configurations
1168 option(WITH_STRICT_BUILD_OPTIONS "\
1169 When requirements for a build option are not met, error instead of disabling the option."
1170   OFF
1173 if(NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE AND NOT WITH_CYCLES_HYDRA_RENDER_DELEGATE)
1174   message(FATAL_ERROR
1175     "At least one of WITH_BLENDER or WITH_CYCLES_STANDALONE "
1176     "or WITH_CYCLES_HYDRA_RENDER_DELEGATE "
1177     "must be enabled, nothing to do!"
1178   )
1179 endif()
1181 set_and_warn_dependency(WITH_AUDASPACE WITH_OPENAL OFF)
1182 set_and_warn_dependency(WITH_AUDASPACE WITH_COREAUDIO OFF)
1183 set_and_warn_dependency(WITH_AUDASPACE WITH_JACK OFF)
1184 set_and_warn_dependency(WITH_AUDASPACE WITH_PULSEAUDIO OFF)
1185 set_and_warn_dependency(WITH_AUDASPACE WITH_WASAPI OFF)
1187 if(NOT WITH_SDL AND WITH_GHOST_SDL)
1188   message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL")
1189 endif()
1191 # python module, needs some different options
1192 if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
1193   message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
1194 endif()
1196 set_and_warn_dependency(WITH_PYTHON WITH_CYCLES        OFF)
1197 set_and_warn_dependency(WITH_PYTHON WITH_DRACO         OFF)
1198 set_and_warn_dependency(WITH_PYTHON WITH_MOD_FLUID     OFF)
1200 if(WITH_DRACO AND NOT WITH_PYTHON_INSTALL)
1201   message(STATUS "WITH_DRACO requires WITH_PYTHON_INSTALL to be ON, disabling WITH_DRACO for now")
1202   set(WITH_DRACO OFF)
1203 endif()
1205 # enable boost for cycles, audaspace or i18n
1206 # otherwise if the user disabled
1208 set_and_warn_dependency(WITH_BOOST WITH_INTERNATIONAL  OFF)
1209 set_and_warn_dependency(WITH_BOOST WITH_OPENVDB        OFF)
1210 set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW     OFF)
1211 set_and_warn_dependency(WITH_BOOST WITH_USD            OFF)
1212 if(WITH_CYCLES)
1213   set_and_warn_dependency(WITH_BOOST   WITH_CYCLES_OSL   OFF)
1214   set_and_warn_dependency(WITH_PUGIXML WITH_CYCLES_OSL   OFF)
1215 endif()
1217 set_and_warn_dependency(WITH_TBB WITH_CYCLES            OFF)
1218 set_and_warn_dependency(WITH_TBB WITH_USD               OFF)
1219 set_and_warn_dependency(WITH_TBB WITH_OPENVDB           OFF)
1220 set_and_warn_dependency(WITH_TBB WITH_MOD_FLUID         OFF)
1222 # NanoVDB requires OpenVDB to convert the data structure
1223 set_and_warn_dependency(WITH_OPENVDB WITH_NANOVDB       OFF)
1225 # OpenVDB, Alembic and OSL uses 'half' or 'imath' from OpenEXR
1226 set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENVDB OFF)
1227 set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_ALEMBIC OFF)
1228 set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_CYCLES_OSL OFF)
1230 # Hydra requires USD.
1231 set_and_warn_dependency(WITH_USD WITH_HYDRA OFF)
1233 if(NOT WITH_CYCLES)
1234   set(WITH_CYCLES_OSL OFF)
1235 endif()
1237 # don't store paths to libs for portable distribution
1238 if(WITH_INSTALL_PORTABLE)
1239   set(CMAKE_SKIP_BUILD_RPATH TRUE)
1240 endif()
1242 if(UNIX AND NOT (APPLE OR HAIKU))
1243   set_and_warn_incompatible(WITH_HEADLESS WITH_GHOST_WAYLAND OFF)
1244   set_and_warn_incompatible(WITH_HEADLESS WITH_GHOST_X11 OFF)
1245 endif()
1246 set_and_warn_incompatible(WITH_HEADLESS WITH_GHOST_SDL OFF)
1248 if(WITH_INPUT_IME)
1249   set_and_warn_incompatible(WITH_HEADLESS WITH_INPUT_IME OFF)
1250   set_and_warn_incompatible(WITH_GHOST_SDL WITH_INPUT_IME OFF)
1251 endif()
1253 set_and_warn_incompatible(WITH_HEADLESS WITH_XR_OPENXR OFF)
1254 set_and_warn_incompatible(WITH_GHOST_SDL WITH_XR_OPENXR OFF)
1256 if(WITH_UI_TESTS)
1257   set_and_warn_dependency(WITH_GHOST_WAYLAND WITH_UI_TESTS OFF)
1258 endif()
1260 if(WITH_BUILDINFO)
1261   find_package(Git)
1262   set_and_warn_library_found("Git" GIT_FOUND WITH_BUILDINFO)
1263 endif()
1265 if(WITH_AUDASPACE)
1266   if(NOT WITH_SYSTEM_AUDASPACE)
1267     set(AUDASPACE_C_INCLUDE_DIRS
1268       "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings/C"
1269       "${CMAKE_BINARY_DIR}/extern/audaspace"
1270     )
1271     set(AUDASPACE_PY_INCLUDE_DIRS
1272       "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings"
1273     )
1274   endif()
1275 endif()
1277 # Auto-enable CUDA dynload if toolkit is not found.
1278 if(WITH_CYCLES AND WITH_CYCLES_DEVICE_CUDA AND NOT WITH_CUDA_DYNLOAD)
1279   find_package(CUDA)
1280   if(NOT CUDA_FOUND)
1281     message(
1282       STATUS
1283       "CUDA toolkit not found, "
1284       "using dynamic runtime loading of libraries (WITH_CUDA_DYNLOAD) instead"
1285     )
1286     set(WITH_CUDA_DYNLOAD ON)
1287   endif()
1288 endif()
1290 if(WITH_CYCLES_DEVICE_HIP)
1291   # Currently HIP must be dynamically loaded, this may change in future toolkits
1292   set(WITH_HIP_DYNLOAD ON)
1293 endif()
1296 # -----------------------------------------------------------------------------
1297 # Check if Sub-modules are Cloned
1299 if(WITH_PYTHON)
1300   # While we have this as an '#error' in 'bpy_capi_utils.h',
1301   # upgrading Python tends to cause confusion for users who build.
1302   # Give the error message early to make this more obvious.
1303   #
1304   # Do this before main 'platform_*' checks,
1305   # because UNIX will search for the old Python paths which may not exist.
1306   # giving errors about missing paths before this case is met.
1307   if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.11")
1308     message(
1309       FATAL_ERROR
1310       "At least Python 3.11 is required to build, but found Python ${PYTHON_VERSION}"
1311     )
1312   endif()
1314   file(GLOB RESULT "${CMAKE_SOURCE_DIR}/scripts/addons")
1315   list(LENGTH RESULT DIR_LEN)
1316   if(DIR_LEN EQUAL 0)
1317     message(
1318       WARNING
1319       "Addons path '${CMAKE_SOURCE_DIR}/scripts/addons' is missing. "
1320       "This is an external repository which needs to be checked out. Use `make update` to do so. "
1321       "* CONTINUING WITHOUT ADDONS *"
1322     )
1323   endif()
1324 endif()
1327 # -----------------------------------------------------------------------------
1328 # InitialIze Un-cached Vars, Avoid Unused Warning
1330 # linux only, not cached
1331 set(WITH_BINRELOC OFF)
1333 # MACOSX only, set to avoid uninitialized
1334 set(EXETYPE "")
1336 # C/C++ flags
1337 set(PLATFORM_CFLAGS)
1339 # these are added to later on.
1340 set(C_WARNINGS)
1341 set(CXX_WARNINGS)
1343 # NOTE: These flags are intended for situations where where it's impractical to
1344 # suppress warnings by modifying the code or for code which is maintained externally.
1345 # For GCC this typically means adding `-Wno-*` arguments to negate warnings
1346 # that are useful in the general case.
1347 set(C_REMOVE_STRICT_FLAGS)
1348 set(CXX_REMOVE_STRICT_FLAGS)
1350 # Libraries to link to targets in setup_platform_linker_libs
1351 set(PLATFORM_LINKLIBS "")
1353 # Added to target linker flags in setup_platform_linker_flags
1354 # - CMAKE_EXE_LINKER_FLAGS
1355 # - CMAKE_EXE_LINKER_FLAGS_DEBUG
1356 set(PLATFORM_LINKFLAGS "")
1357 set(PLATFORM_LINKFLAGS_DEBUG "")
1358 set(PLATFORM_LINKFLAGS_RELEASE "")
1359 set(PLATFORM_LINKFLAGS_EXECUTABLE "")
1361 if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
1362   if(WITH_COMPILER_ASAN)
1363     if(NOT APPLE)
1364       # Avoid passing address sanitizer compiler flags to `try_compile`.
1365       # Since linker flags are not set, all compiler checks and `find_package`
1366       # calls that rely on `try_compile` will fail.
1367       # See CMP0066 also.
1368       string(APPEND CMAKE_C_FLAGS_DEBUG " ${COMPILER_ASAN_CFLAGS}")
1369       string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${COMPILER_ASAN_CFLAGS}")
1371       string(APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMPILER_ASAN_CXXFLAGS}")
1372       string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${COMPILER_ASAN_CXXFLAGS}")
1373     endif()
1374     if(MSVC)
1375       set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6")
1376     endif()
1378     if(APPLE AND COMPILER_ASAN_LIBRARY)
1379       string(REPLACE " " ";" _list_COMPILER_ASAN_CFLAGS ${COMPILER_ASAN_CFLAGS})
1380       set(_is_CONFIG_DEBUG "$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>")
1381       add_compile_options("$<${_is_CONFIG_DEBUG}:${_list_COMPILER_ASAN_CFLAGS}>")
1383       # Skip generation of the unwind tables, as they might require a lot of space when sanitizers
1384       # are enabled and not fit into the .eh_frame section. Disabling the unwind tables might have
1385       # side effects on code which does frame walking, such as
1386       #   - backtrace()
1387       #   - __attribute__((__cleanup__(f)))
1388       #   - __builtin_return_address(n), for n > 0
1389       #   - pthread_cleanup_push when it is implemented using __attribute__((__cleanup__(f)))
1390       # It should not have affect on debugging, since it uses -g flag which generates debugging
1391       # tables in the .debug_frame section.
1392       # At the time of adding these flags calling backtrace() from C code on Apple M2 did not
1393       # affect on the printed backtrace, and exception handling was correct as well.
1394       #
1395       # Related discussion:
1396       #  https://stackoverflow.com/questions/26300819
1397       add_compile_options("$<${_is_CONFIG_DEBUG}:-fno-unwind-tables>")
1398       add_compile_options("$<${_is_CONFIG_DEBUG}:-fno-asynchronous-unwind-tables>")
1400       add_compile_options("$<${_is_CONFIG_DEBUG}:-fno-omit-frame-pointer>")
1401       add_link_options("$<${_is_CONFIG_DEBUG}:-fno-omit-frame-pointer;-fsanitize=address>")
1402       unset(_list_COMPILER_ASAN_CFLAGS)
1403       unset(_is_CONFIG_DEBUG)
1404     elseif(COMPILER_ASAN_LIBRARY)
1405       set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}")
1406       set(PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY}")
1407       set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY}")
1408       if(DEFINED COMPILER_ASAN_LINKER_FLAGS)
1409         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${COMPILER_ASAN_LINKER_FLAGS}")
1410         set(PLATFORM_LINKFLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG} ${COMPILER_ASAN_LINKER_FLAGS}")
1411       endif()
1412     endif()
1413   endif()
1414 endif()
1416 # Test SIMD support, before platform includes to determine if sse2neon is needed.
1417 if(WITH_CPU_SIMD)
1418   set(COMPILER_SSE42_FLAG)
1420   # Test Neon first since macOS Arm can compile and run x86-64 SSE binaries.
1421   test_neon_support()
1422   if(NOT SUPPORT_NEON_BUILD)
1423     test_sse_support(COMPILER_SSE42_FLAG)
1424   endif()
1425 endif()
1428 # ----------------------------------------------------------------------------
1429 # Main Platform Checks
1431 # - UNIX
1432 # - WIN32
1433 # - APPLE
1435 if(UNIX AND NOT APPLE)
1436   include(platform_unix)
1437 elseif(WIN32)
1438   include(platform_win32)
1439 elseif(APPLE)
1440   include(platform_apple)
1441 endif()
1444 # -----------------------------------------------------------------------------
1445 # Common Checks for Compatible Options
1447 if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
1448   message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
1449 endif()
1451 if(WITH_INTERNATIONAL)
1452   if(NOT WITH_BOOST)
1453     message(
1454       FATAL_ERROR
1455       "Internationalization requires WITH_BOOST, the library may not have been found. "
1456       "Configure BOOST or disable WITH_INTERNATIONAL"
1457     )
1458   endif()
1459 endif()
1461 # Enable SIMD support if detected by `test_sse_support()` or `test_neon_support()`.
1463 if(WITH_CPU_SIMD)
1464   if(SUPPORT_NEON_BUILD)
1465     # Neon
1466     if(SSE2NEON_FOUND)
1467       include_directories(SYSTEM "${SSE2NEON_INCLUDE_DIRS}")
1468       add_definitions(-DWITH_SSE2NEON)
1469     endif()
1470   else()
1471     # SSE
1472     if(SUPPORT_SSE42_BUILD)
1473       string(APPEND CMAKE_CXX_FLAGS " ${COMPILER_SSE42_FLAG}")
1474       string(APPEND CMAKE_C_FLAGS " ${COMPILER_SSE42_FLAG}")
1475       # MSVC doesn't define any of these and only does the AVX and higher flags.
1476       # For consistency we define these flags for MSVC.
1477       if(WIN32)
1478         add_compile_definitions(
1479           __MMX__
1480           __SSE__
1481           __SSE2__
1482           __SSE3__
1483           __SSE4_1__
1484           __SSE4_2__
1485         )
1486       endif()
1487     endif()
1488   endif()
1489 endif()
1491 # Print instructions used on first run.
1492 if(FIRST_RUN)
1493   if(WITH_CPU_SIMD)
1494     if(SUPPORT_NEON_BUILD)
1495       if(SSE2NEON_FOUND)
1496         message(STATUS "Neon SIMD instructions enabled")
1497       else()
1498         message(STATUS "Neon SIMD instructions detected but unused, requires sse2neon")
1499       endif()
1500     elseif(SUPPORT_SSE42_BUILD)
1501       message(STATUS "SSE42 SIMD instructions enabled")
1502     else()
1503       message(STATUS "No SIMD instructions detected")
1504     endif()
1505   else()
1506     message(STATUS "SIMD instructions disabled")
1507   endif()
1508 endif()
1510 # set the endian define
1511 if(MSVC)
1512   # for some reason this fails on msvc
1513   add_definitions(-D__LITTLE_ENDIAN__)
1515   # OSX-Note: as we do cross-compiling with specific set architecture,
1516   # endianness-detection and auto-setting is counterproductive
1517   # so we just set endianness according CMAKE_OSX_ARCHITECTURES
1519 elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR
1520        CMAKE_OSX_ARCHITECTURES MATCHES x86_64 OR
1521        CMAKE_OSX_ARCHITECTURES MATCHES arm64)
1522   add_definitions(-D__LITTLE_ENDIAN__)
1523 elseif(CMAKE_OSX_ARCHITECTURES MATCHES ppc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc64)
1524   add_definitions(-D__BIG_ENDIAN__)
1526 else()
1527   include(TestBigEndian)
1528   test_big_endian(_SYSTEM_BIG_ENDIAN)
1529   if(_SYSTEM_BIG_ENDIAN)
1530     add_definitions(-D__BIG_ENDIAN__)
1531   else()
1532     add_definitions(-D__LITTLE_ENDIAN__)
1533   endif()
1534   unset(_SYSTEM_BIG_ENDIAN)
1535 endif()
1536 if(WITH_IMAGE_OPENJPEG)
1537   # Special handling of Windows platform where openjpeg is always static.
1538   if(WIN32)
1539     set(OPENJPEG_DEFINES "-DOPJ_STATIC")
1540   else()
1541     set(OPENJPEG_DEFINES "")
1542   endif()
1543 endif()
1545 if(NOT WITH_SYSTEM_EIGEN3)
1546   set(EIGEN3_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/Eigen3)
1547 endif()
1549 if(WITH_OPENVDB)
1550   list(APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB)
1552   if(WITH_OPENVDB_3_ABI_COMPATIBLE)
1553     list(APPEND OPENVDB_DEFINITIONS -DOPENVDB_3_ABI_COMPATIBLE)
1554   endif()
1556   # OpenVDB headers use deprecated TBB headers, silence warning.
1557   list(APPEND OPENVDB_DEFINITIONS -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1)
1559   list(APPEND OPENVDB_INCLUDE_DIRS
1560     ${BOOST_INCLUDE_DIR}
1561     ${TBB_INCLUDE_DIRS}
1562     ${OPENEXR_INCLUDE_DIRS}
1563   )
1565   list(APPEND OPENVDB_LIBRARIES ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
1567   if(WITH_OPENVDB_BLOSC)
1568     list(APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB_BLOSC)
1569     # Even when `WITH_OPENVDB_BLOSC` is set, `FindBlosc.cmake` isn't running.
1570     # As this might be used at some point, check the libraries are defined.
1571     if(DEFINED BLOSC_LIBRARIES)
1572       list(APPEND OPENVDB_LIBRARIES ${BLOSC_LIBRARIES})
1573     endif()
1574     list(APPEND OPENVDB_LIBRARIES ${ZLIB_LIBRARIES})
1575   endif()
1577   list(APPEND OPENVDB_LIBRARIES ${BOOST_LIBRARIES} ${TBB_LIBRARIES})
1578 endif()
1580 # -----------------------------------------------------------------------------
1581 # Configure Metal
1583 if(WITH_METAL_BACKEND)
1584   add_definitions(-DWITH_METAL_BACKEND)
1586   # No need to add frameworks here, all the ones we need for Metal and
1587   # Metal-OpenGL Interop are already being added by
1588   # build_files/cmake/platform/platform_apple.cmake
1589 endif()
1592 # -----------------------------------------------------------------------------
1593 # Configure OpenMP
1595 if(WITH_OPENMP)
1596   if(NOT OPENMP_CUSTOM)
1597     find_package(OpenMP)
1598   endif()
1600   set_and_warn_library_found("OpenMP" OPENMP_FOUND WITH_OPENMP)
1602   if(OPENMP_FOUND)
1603     if(NOT WITH_OPENMP_STATIC)
1604       string(APPEND CMAKE_C_FLAGS " ${OpenMP_C_FLAGS}")
1605       string(APPEND CMAKE_CXX_FLAGS " ${OpenMP_CXX_FLAGS}")
1606       if(DEFINED OpenMP_LINKER_FLAGS)
1607         string(APPEND CMAKE_EXE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}")
1608         string(APPEND CMAKE_MODULE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}")
1609       endif()
1610     else()
1611       # Typically avoid adding flags as defines but we can't
1612       # pass OpenMP flags to the linker for static builds, meaning
1613       # we can't add any OpenMP related flags to CFLAGS variables
1614       # since they're passed to the linker as well.
1615       add_definitions("${OpenMP_C_FLAGS}")
1617       find_library_static(OpenMP_LIBRARIES gomp ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES})
1618       mark_as_advanced(
1619         OpenMP_LIBRARIES
1620       )
1621     endif()
1622   endif()
1624   mark_as_advanced(
1625     OpenMP_C_FLAGS
1626     OpenMP_CXX_FLAGS
1627   )
1628 endif()
1631 # -----------------------------------------------------------------------------
1632 # Configure Bullet
1634 if(WITH_BULLET)
1635   if(WITH_SYSTEM_BULLET)
1636     find_package(Bullet)
1637     set_and_warn_library_found("Bullet" BULLET_FOUND WITH_BULLET)
1638   else()
1639     set(BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src")
1640     set(BULLET_LIBRARIES "extern_bullet")
1641   endif()
1642 endif()
1645 # -----------------------------------------------------------------------------
1646 # Configure Python
1648 # Not currently supported due to different required Python link flags.
1649 set_and_warn_incompatible(WITH_PYTHON_MODULE WITH_GTESTS OFF)
1652 # -----------------------------------------------------------------------------
1653 # Configure `GLog/GFlags`
1655 if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
1656   if(WITH_SYSTEM_GFLAGS)
1657     find_package(Gflags)
1658     if(NOT GFLAGS_FOUND)
1659       message(FATAL_ERROR "System wide Gflags is requested but was not found")
1660     endif()
1661     # `FindGflags` does not define this, and we are not even sure what to use here.
1662     set(GFLAGS_DEFINES)
1663   else()
1664     set(GFLAGS_DEFINES
1665       -DGFLAGS_DLL_DEFINE_FLAG=
1666       -DGFLAGS_DLL_DECLARE_FLAG=
1667       -DGFLAGS_DLL_DECL=
1668     )
1669     set(GFLAGS_NAMESPACE "gflags")
1670     set(GFLAGS_LIBRARIES extern_gflags)
1671     set(GFLAGS_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/extern/gflags/src")
1672   endif()
1674   if(WITH_SYSTEM_GLOG)
1675     find_package(Glog)
1676     if(NOT GLOG_FOUND)
1677       message(FATAL_ERROR "System wide Glog is requested but was not found")
1678     endif()
1679     # `FindGlog` does not define this, and we are not even sure what to use here.
1680     set(GLOG_DEFINES)
1681   else()
1682     set(GLOG_DEFINES
1683       -DGOOGLE_GLOG_DLL_DECL=
1684     )
1685     set(GLOG_LIBRARIES extern_glog)
1686     if(WIN32)
1687       set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/glog/src/windows)
1688     else()
1689       set(GLOG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/glog/include)
1690     endif()
1691   endif()
1692 endif()
1695 # -----------------------------------------------------------------------------
1696 # Ninja Job Limiting
1698 # Extra limits to number of jobs running in parallel for some kind os tasks.
1699 # Only supported by Ninja build system currently.
1701 if("${CMAKE_GENERATOR}" MATCHES "Ninja" AND WITH_NINJA_POOL_JOBS)
1702   if(NOT NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS AND
1703      NOT NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS AND
1704      NOT NINJA_MAX_NUM_PARALLEL_LINK_JOBS)
1705     # Try to define good default values.
1706     # Max mem of heavy cpp files compilation: about 2.5GB
1707     # Max mem during linking: about 3.3GB
1708     cmake_host_system_information(RESULT _NUM_CORES QUERY NUMBER_OF_LOGICAL_CORES)
1709     # Note: this gives mem in MB.
1710     cmake_host_system_information(RESULT _TOT_MEM QUERY TOTAL_PHYSICAL_MEMORY)
1712     # Heuristics: Assume 8Gb of RAM is needed per heavy compile job.
1713     # Typical RAM peak usage of these is actually less than 3GB currently,
1714     # but this also accounts for the part of the physical RAM being used by other unrelated
1715     # processes on the system, and the part being used by the 'regular' compile and linking jobs.
1716     #
1717     # Also always cap heavy jobs amount to `number of available threads - 1`,
1718     # to ensure that even if there would be enough RAM, the machine never ends up
1719     # handling only heavy jobs at some point.
1720     # This can have annoying sides effects, like lack of output in the console for several
1721     # minutes, which can lead to a wrong detection of 'unresponsive' state by the build-bots e.g.
1722     #
1723     # Currently, these settings applied to a 64GB/16threads linux machine will use,
1724     # for a full build:
1725     #   - release build:
1726     #      * RAM: typically less than 20%, with some peaks at 25%.
1727     #      * CPU: over 90% of usage on average over the whole build time.
1728     #   - debug with ASAN build:
1729     #      * RAM: typically less than 40%, with some peaks at 50%.
1730     #      * CPU: over 90% of usage on average over the whole build time.
1731     math(EXPR _compile_heavy_jobs "${_TOT_MEM} / 8000")
1732     math(EXPR _compile_heavy_jobs_max "${_NUM_CORES} - 1")
1733     if(${_compile_heavy_jobs} GREATER ${_compile_heavy_jobs_max})
1734       set(_compile_heavy_jobs ${_compile_heavy_jobs_max})
1735     elseif(${_compile_heavy_jobs} LESS 1)
1736       set(_compile_heavy_jobs 1)
1737     endif()
1738     set(NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS "${_compile_heavy_jobs}" CACHE STRING "\
1739 Define the maximum number of concurrent heavy compilation jobs, for ninja build system \
1740 (used for some targets which cpp files can take several GB each during compilation)."
1741       FORCE
1742     )
1743     mark_as_advanced(NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
1744     set(_compile_heavy_jobs)
1745     set(_compile_heavy_jobs_max)
1747     # Heuristics: Assume 2Gb of RAM is needed per heavy compile job.
1748     # Typical RAM peak usage of these is actually way less than 1GB usually,
1749     # but this also accounts for the part of the physical RAM being used by other unrelated
1750     # processes on the system, and the part being used by the 'heavy' compile and linking jobs.
1751     #
1752     # If there are 'enough' cores available, cap the maximum number of regular jobs to
1753     # `number of cores - 1`, otherwise allow using all cores if there is enough RAM available.
1754     # This allows to ensure that the heavy jobs won't get starved by too many normal jobs,
1755     # since the former usually take a long time to process.
1756     math(EXPR _compile_jobs "${_TOT_MEM} / 2000")
1757     if(${_NUM_CORES} GREATER 3)
1758       math(EXPR _compile_jobs_max "${_NUM_CORES} - 1")
1759     else()
1760       set(_compile_jobs_max ${_NUM_CORES})
1761     endif()
1762     if(${_compile_jobs} GREATER ${_compile_jobs_max})
1763       set(_compile_jobs ${_compile_jobs_max})
1764     elseif(${_compile_jobs} LESS 1)
1765       set(_compile_jobs 1)
1766     endif()
1767     set(NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS "${_compile_jobs}" CACHE STRING
1768         "Define the maximum number of concurrent compilation jobs, for ninja build system." FORCE)
1769     mark_as_advanced(NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS)
1770     set(_compile_jobs)
1771     set(_compile_jobs_max)
1773     # In practice, even when there is RAM available,
1774     # this proves to be quicker than running in parallel (due to slow disks accesses).
1775     set(NINJA_MAX_NUM_PARALLEL_LINK_JOBS "1" CACHE STRING
1776         "Define the maximum number of concurrent link jobs, for ninja build system." FORCE)
1777     mark_as_advanced(NINJA_MAX_NUM_PARALLEL_LINK_JOBS)
1779     set(_NUM_CORES)
1780     set(_TOT_MEM)
1781   endif()
1783   if(NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS)
1784     set_property(
1785       GLOBAL APPEND PROPERTY
1786       JOB_POOLS compile_job_pool=${NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS}
1787     )
1788     set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
1789   endif()
1791   if(NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
1792     set_property(
1793       GLOBAL APPEND PROPERTY
1794       JOB_POOLS compile_heavy_job_pool=${NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS}
1795     )
1796   endif()
1798   if(NINJA_MAX_NUM_PARALLEL_LINK_JOBS)
1799     set_property(
1800       GLOBAL APPEND PROPERTY
1801       JOB_POOLS link_job_pool=${NINJA_MAX_NUM_PARALLEL_LINK_JOBS}
1802     )
1803     set(CMAKE_JOB_POOL_LINK link_job_pool)
1804   endif()
1805 endif()
1808 # -----------------------------------------------------------------------------
1809 # Extra Compile Flags
1811 if(CMAKE_COMPILER_IS_GNUCC)
1813   add_check_c_compiler_flags(
1814     C_WARNINGS
1816     C_WARN_ALL -Wall
1817     C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration
1819     # System headers sometimes do this, disable for now, was: `-Werror=strict-prototypes`.
1820     C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes
1822     C_WARN_ERROR_RETURN_TYPE -Werror=return-type
1823     C_WARN_ERROR_VLA -Werror=vla
1824     C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes
1825     C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
1826     C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
1827     C_WARN_POINTER_ARITH -Wpointer-arith
1828     C_WARN_UNUSED_PARAMETER -Wunused-parameter
1829     C_WARN_WRITE_STRINGS -Wwrite-strings
1830     C_WARN_LOGICAL_OP -Wlogical-op
1831     C_WARN_UNDEF -Wundef
1833     # Needs: `-Wuninitialized`.
1834     C_WARN_INIT_SELF -Winit-self
1836     C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs
1837     C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero
1838     C_WARN_TYPE_LIMITS -Wtype-limits
1839     C_WARN_FORMAT_SIGN -Wformat-signedness
1840     C_WARN_RESTRICT -Wrestrict
1842     # Useful but too many false positives and inconvenient to suppress each occurrence.
1843     C_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread
1844     C_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow
1846     # C-only.
1847     C_WARN_NO_NULL -Wnonnull
1848     C_WARN_ABSOLUTE_VALUE -Wabsolute-value
1850     C_WARN_UNINITIALIZED -Wuninitialized
1851     C_WARN_REDUNDANT_DECLS -Wredundant-decls
1852     C_WARN_SHADOW -Wshadow
1854     # Disable because it gives warnings for printf() & friends.
1855     # C_WARN_DOUBLE_PROMOTION "-Wdouble-promotion -Wno-error=double-promotion"
1857     # Use `ATTR_FALLTHROUGH` macro to suppress.
1858     C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5
1859   )
1861   if(NOT APPLE)
1862     add_check_c_compiler_flags(
1863       C_WARNINGS
1864       C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable
1865     )
1866   endif()
1868   add_check_cxx_compiler_flags(
1869     CXX_WARNINGS
1871     CXX_WARN_UNINITIALIZED -Wuninitialized
1872     CXX_WARN_REDUNDANT_DECLS -Wredundant-decls
1874     CXX_WARN_ALL -Wall
1875     CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
1876     CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
1877     CXX_WARN_LOGICAL_OP -Wlogical-op
1879     # Needs: `-Wuninitialized`.
1880     CXX_WARN_INIT_SELF -Winit-self
1882     CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs
1883     CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero
1884     CXX_WARN_TYPE_LIMITS -Wtype-limits
1885     CXX_WARN_ERROR_RETURN_TYPE -Werror=return-type
1886     CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
1887     CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
1888     CXX_WARN_POINTER_ARITH -Wpointer-arith
1889     CXX_WARN_UNUSED_PARAMETER -Wunused-parameter
1890     CXX_WARN_WRITE_STRINGS -Wwrite-strings
1891     CXX_WARN_UNDEF -Wundef
1892     CXX_WARN_COMMA_SUBSCRIPT -Wcomma-subscript
1893     CXX_WARN_FORMAT_SIGN -Wformat-signedness
1894     CXX_WARN_RESTRICT -Wrestrict
1895     CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override
1896     CXX_WARN_UNINITIALIZED -Wuninitialized
1898     # NOTE(@ideasman42): In GCC 13.2.1 on Linux this causes internal compiler errors.
1899     # The crashes can be resolved by disabling the flag per module (but not via pragmas).
1900     # However this also causes a type mix-up FreeStyle  (Blender & FreeStyle's `Curve`)
1901     # so it seems to impact GCC's the internal state enough that it's too risky to enable.
1902     # When this is resolved the check can be enabled for fixed GCC versions.
1903     #
1904     # Prevents linking errors with MSVC.
1905     # `CXX_WARN_MISMATCHED_TAGS -Wmismatched-tags`
1907     # Useful but too many false positives and inconvenient to suppress each occurrence.
1908     CXX_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread
1909     CXX_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow
1911     # Use `[[fallthrough]]` or `ATTR_FALLTHROUGH` macro to suppress.
1912     CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5
1913   )
1915   # causes too many warnings
1916   if(NOT APPLE)
1917     add_check_cxx_compiler_flags(
1918       CXX_WARNINGS
1919       CXX_WARN_UNDEF -Wundef
1920       CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations
1921     )
1922   endif()
1924   # ---------------------
1925   # Suppress Strict Flags
1926   #
1927   # Exclude the following warnings from this list:
1928   # - `-Wno-address`:
1929   #   This can give useful hints that point to bugs/misleading logic.
1930   # - `-Wno-strict-prototypes`:
1931   #   No need to support older C-style prototypes.
1932   #
1933   # If code in `./extern/` needs to suppress these flags that can be done on a case-by-case basis.
1935   # flags to undo strict flags
1936   add_check_c_compiler_flags(
1937     C_REMOVE_STRICT_FLAGS
1939     C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations
1940     C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
1941     C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function
1942     C_WARN_NO_TYPE_LIMITS -Wno-type-limits
1943     C_WARN_NO_INT_IN_BOOL_CONTEXT -Wno-int-in-bool-context
1944     C_WARN_NO_FORMAT -Wno-format
1945     C_WARN_NO_SWITCH -Wno-switch
1946     C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
1947     C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized
1948     C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough
1949   )
1952   add_check_cxx_compiler_flags(
1953     CXX_REMOVE_STRICT_FLAGS
1955     CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess
1956     CXX_WARN_NO_COMMENT -Wno-comment
1957     CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs
1958     CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
1959     CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized
1960   )
1963   if(NOT APPLE)
1964     add_check_c_compiler_flags(
1965       C_REMOVE_STRICT_FLAGS
1966       C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable
1967     )
1968   endif()
1970 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
1971   # Matches both "Clang" & "AppleClang" on macOS.
1973   add_check_c_compiler_flags(
1974     C_WARNINGS
1976     # Strange, clang complains these are not supported, but then uses them.
1977     C_WARN_ALL -Wall
1978     C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration
1979     C_WARN_ERROR_RETURN_TYPE -Werror=return-type
1980     C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare
1981     C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
1982     C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
1983     C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes
1984     C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes
1985     C_WARN_UNUSED_PARAMETER -Wunused-parameter
1986     C_WARN_UNDEF -Wundef
1987     C_WARN_UNDEF_PREFIX -Wundef-prefix
1989     C_WARN_ERROR_UNGUARDED_AVAILABILITY_NEW -Werror=unguarded-availability-new
1990   )
1992   add_check_cxx_compiler_flags(
1993     CXX_WARNINGS
1995     CXX_WARN_ALL -Wall
1996     # Using C++20 features while having C++17 as the project language isn't allowed by MSVC.
1997     CXX_CXX20_DESIGNATOR -Wc++20-designator
1999     CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare
2000     CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
2001     CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
2003     # We get a lot of these, if its a problem a dev needs to look into it.
2004     CXX_WARN_NO_OVERLOADED_VIRTUAL -Wno-overloaded-virtual
2006     CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
2007     CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
2009     # Apple Clang (tested on version 12) doesn't support this flag while LLVM Clang 11 does.
2010     CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override
2012     CXX_WARN_UNDEF -Wundef
2013     CXX_WARN_UNDEF_PREFIX -Wundef-prefix
2014     CXX_WARN_UNUSED_PARAMETER -Wunused-parameter
2016     # Prevents linking errors with MSVC.
2017     CXX_WARN_MISMATCHED_TAGS -Wmismatched-tags
2019     # Gives too many unfixable warnings.
2020     # `C_WARN_UNUSED_MACROS -Wunused-macros`
2021     # `CXX_WARN_UNUSED_MACROS -Wunused-macros`
2023     CXX_WARN_ERROR_UNGUARDED_AVAILABILITY_NEW -Werror=unguarded-availability-new
2024   )
2025   if(MSVC_CLANG)
2026     # clang-cl produces an unhealthy ammount of warnings in its default
2027     # configuration as it for reasons unknown decided to enable all
2028     # warnings known to mankind. Resulting in a 5.5GB build log containing
2029     # well over 11 million warnings. The code below disables every single
2030     # one of them indiscriminately. Someone with time on their hands,
2031     # could/should go over these and either fix them or describe why we
2032     # would want to disable the warning. The list below contains both C
2033     # and C++ warnings for all warnings since clang has seemingly no
2034     # easy way to tell if something is a C or C++ specific warning and
2035     # manually auditing every single one of them just isn't in the cards
2036     # right now.
2038     # /W3 is being removed, then added back again, this is because order
2039     # matters for clang and these flags are being placed before the
2040     # CMAKE_[LANGUAGE]_FLAGS which normally contain /W3, so we would
2041     # disable certain warings here only for them to be re-enabled by /W3
2042     # later on.
2043     remove_cc_flag("/W3")
2045     add_check_c_compiler_flags(
2046       C_WARNINGS
2047       C_WARN_CLANG_CL_W3 /W3
2048       # The number behind each warn is the number of unique warning were
2049       # generated on 2024-04-24 (d2be9cecc28a03ff1f799e8c63f1f9f8eda7cce3)
2050       # especially the ones in the single and low double digits are likely
2051       # genuine problems that can be investigated.
2052       C_WARN_CLANG_CL_C++98_COMPAT -Wno-c++98-compat # 352692
2053       C_WARN_CLANG_CL_OLD_STYLE_CAST -Wno-old-style-cast # 178608
2054       C_WARN_CLANG_CL_UNSAFE_BUFFER_USAGE -Wno-unsafe-buffer-usage # 89032
2055       C_WARN_CLANG_CL_MISSING_PROTOTYPES -Wno-missing-prototypes # 25587
2056       C_WARN_CLANG_CL_SIGN_CONVERSION -Wno-sign-conversion # 20109
2057       C_WARN_CLANG_CL_MISSING_FIELD_INITIALIZERS -Wno-missing-field-initializers # 20060
2058       C_WARN_CLANG_CL_EXTRA_SEMI -Wno-extra-semi # 12513
2059       C_WARN_CLANG_CL_LANGUAGE_EXTENSION_TOKEN -Wno-language-extension-token # 11032
2060       C_WARN_CLANG_CL_IMPLICIT_FLOAT_CONVERSION -Wno-implicit-float-conversion # 11003
2061       C_WARN_CLANG_CL_C++98_COMPAT_PEDANTIC -Wno-c++98-compat-pedantic # 10336
2062       C_WARN_CLANG_CL_IMPLICIT_INT_FLOAT_CONVERSION -Wno-implicit-int-float-conversion # 7354
2063       C_WARN_CLANG_CL_DOUBLE_PROMOTION -Wno-double-promotion # 7350
2064       C_WARN_CLANG_CL_PRE_C++17_COMPAT -Wno-pre-c++17-compat # 7303
2065       C_WARN_CLANG_CL_SHORTEN_64_TO_32 -Wno-shorten-64-to-32 # 7085
2066       C_WARN_CLANG_CL_C++98_COMPAT_LOCAL_TYPE_TEMPLATE_ARGS -Wno-c++98-compat-local-type-template-args # 6906
2067       C_WARN_CLANG_CL_RESERVED_IDENTIFIER -Wno-reserved-identifier # 5886
2068       C_WARN_CLANG_CL_CAST_ALIGN -Wno-cast-align # 5513
2069       C_WARN_CLANG_CL_DOCUMENTATION -Wno-documentation # 5107
2070       C_WARN_CLANG_CL_DISABLED_MACRO_EXPANSION -Wno-disabled-macro-expansion # 4449
2071       C_WARN_CLANG_CL_EXTRA_SEMI_STMT -Wno-extra-semi-stmt # 4349
2072       C_WARN_CLANG_CL_ZERO_AS_NULL_POINTER_CONSTANT -Wno-zero-as-null-pointer-constant # 3209
2073       C_WARN_CLANG_CL_FLOAT_CONVERSION -Wno-float-conversion # 2869
2074       C_WARN_CLANG_CL_RESERVED_MACRO_IDENTIFIER -Wno-reserved-macro-identifier # 2862
2075       C_WARN_CLANG_CL_CAST_FUNCTION_TYPE_STRICT -Wno-cast-function-type-strict # 2663
2076       C_WARN_CLANG_CL_FLOAT_EQUAL -Wno-float-equal # 2153
2077       C_WARN_CLANG_CL_IMPLICIT_INT_CONVERSION -Wno-implicit-int-conversion # 2117
2078       C_WARN_CLANG_CL_SHADOW -Wno-shadow # 2068
2079       C_WARN_CLANG_CL_SHADOW_FIELD_IN_CONSTRUCTOR -Wno-shadow-field-in-constructor # 1829
2080       C_WARN_CLANG_CL_CAST_QUAL -Wno-cast-qual # 1742
2081       C_WARN_CLANG_CL_PRE_C++14_COMPAT -Wno-pre-c++14-compat # 1569
2082       C_WARN_CLANG_CL_GLOBAL_CONSTRUCTORS -Wno-global-constructors # 1402
2083       C_WARN_CLANG_CL_SWITCH_ENUM -Wno-switch-enum # 973
2084       C_WARN_CLANG_CL_EXIT_TIME_DESTRUCTORS -Wno-exit-time-destructors # 940
2085       C_WARN_CLANG_CL_CTAD_MAYBE_UNSUPPORTED -Wno-ctad-maybe-unsupported # 891
2086       C_WARN_CLANG_CL_UNDEFINED_FUNC_TEMPLATE -Wno-undefined-func-template # 863
2087       C_WARN_CLANG_CL_C++98_COMPAT_EXTRA_SEMI -Wno-c++98-compat-extra-semi # 848
2088       C_WARN_CLANG_CL_CAST_FUNCTION_TYPE -Wno-cast-function-type # 807
2089       C_WARN_CLANG_CL_NULLABILITY_EXTENSION -Wno-nullability-extension # 602
2090       C_WARN_CLANG_CL_SHADOW_FIELD -Wno-shadow-field # 585
2091       C_WARN_CLANG_CL_CONDITIONAL_UNINITIALIZED -Wno-conditional-uninitialized # 555
2092       C_WARN_CLANG_CL_UNUSED_PARAMETER -Wno-unused-parameter # 539
2093       C_WARN_CLANG_CL_SUGGEST_DESTRUCTOR_OVERRIDE -Wno-suggest-destructor-override # 356
2094       C_WARN_CLANG_CL_SHADOW_UNCAPTURED_LOCAL -Wno-shadow-uncaptured-local # 355
2095       C_WARN_CLANG_CL_UNUSED_MACROS -Wno-unused-macros # 289
2096       C_WARN_CLANG_CL_COVERED_SWITCH_DEFAULT -Wno-covered-switch-default # 233
2097       C_WARN_CLANG_CL_SIGNED_ENUM_BITFIELD -Wno-signed-enum-bitfield # 229
2098       C_WARN_CLANG_CL_DECLARATION_AFTER_STATEMENT -Wno-declaration-after-statement # 228
2099       C_WARN_CLANG_CL_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough # 164
2100       C_WARN_CLANG_CL_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor # 161
2101       C_WARN_CLANG_CL_NESTED_ANON_TYPES -Wno-nested-anon-types # 140
2102       C_WARN_CLANG_CL_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS -Wno-gnu-zero-variadic-macro-arguments # 132
2103       C_WARN_CLANG_CL_UNREACHABLE_CODE_BREAK -Wno-unreachable-code-break # 115
2104       C_WARN_CLANG_CL_INCONSISTENT_MISSING_DESTRUCTOR_OVERRIDE -Wno-inconsistent-missing-destructor-override # 104
2105       C_WARN_CLANG_CL_FORMAT_PEDANTIC -Wno-format-pedantic # 97
2106       C_WARN_CLANG_CL_NONPORTABLE_SYSTEM_INCLUDE_PATH -Wno-nonportable-system-include-path # 95
2107       C_WARN_CLANG_CL_UNDEF -Wno-undef # 94
2108       C_WARN_CLANG_CL_IGNORED_QUALIFIERS -Wno-ignored-qualifiers # 93
2109       C_WARN_CLANG_CL_USED_BUT_MARKED_UNUSED -Wno-used-but-marked-unused # 83
2110       C_WARN_CLANG_CL_HEADER_HYGIENE -Wno-header-hygiene # 79
2111       C_WARN_CLANG_CL_CHAR_SUBSCRIPTS -Wno-char-subscripts # 76
2112       C_WARN_CLANG_CL_UNREACHABLE_CODE_RETURN -Wno-unreachable-code-return # 71
2113       C_WARN_CLANG_CL_UNUSED_TEMPLATE -Wno-unused-template # 66
2114       C_WARN_CLANG_CL_GNU_ANONYMOUS_STRUCT -Wno-gnu-anonymous-struct # 63
2115       C_WARN_CLANG_CL_DEPRECATED_COPY_WITH_USER_PROVIDED_DTOR -Wno-deprecated-copy-with-user-provided-dtor # 62
2116       C_WARN_CLANG_CL_INCONSISTENT_MISSING_OVERRIDE -Wno-inconsistent-missing-override # 54
2117       C_WARN_CLANG_CL_UNREACHABLE_CODE -Wno-unreachable-code # 52
2118       C_WARN_CLANG_CL_DEPRECATED_DYNAMIC_EXCEPTION_SPEC -Wno-deprecated-dynamic-exception-spec # 51
2119       C_WARN_CLANG_CL_BAD_FUNCTION_CAST -Wno-bad-function-cast # 50
2120       C_WARN_CLANG_CL_MICROSOFT_ENUM_VALUE -Wno-microsoft-enum-value # 47
2121       C_WARN_CLANG_CL_DEPRECATED_COPY_WITH_USER_PROVIDED_COPY -Wno-deprecated-copy-with-user-provided-copy # 41
2122       C_WARN_CLANG_CL_ZERO_LENGTH_ARRAY -Wno-zero-length-array # 39
2123       C_WARN_CLANG_CL_UNUSED_FUNCTION -Wno-unused-function # 38
2124       C_WARN_CLANG_CL_PEDANTIC -Wno-pedantic # 38
2125       C_WARN_CLANG_CL_DEPRECATED_COPY_WITH_DTOR -Wno-deprecated-copy-with-dtor # 37
2126       C_WARN_CLANG_CL_DOCUMENTATION_UNKNOWN_COMMAND -Wno-documentation-unknown-command # 34
2127       C_WARN_CLANG_CL_UNDEFINED_REINTERPRET_CAST -Wno-undefined-reinterpret-cast # 33
2128       C_WARN_CLANG_CL_FORMAT_NONLITERAL -Wno-format-nonliteral # 29
2129       C_WARN_CLANG_CL_COMMA -Wno-comma # 27
2130       C_WARN_CLANG_CL_DOCUMENTATION_DEPRECATED_SYNC -Wno-documentation-deprecated-sync # 26
2131       C_WARN_CLANG_CL_SHIFT_SIGN_OVERFLOW -Wno-shift-sign-overflow # 24
2132       C_WARN_CLANG_CL_PRE_C++17_COMPAT_PEDANTIC -Wno-pre-c++17-compat-pedantic # 24
2133       C_WARN_CLANG_CL_C++98_COMPAT_UNNAMED_TYPE_TEMPLATE_ARGS -Wno-c++98-compat-unnamed-type-template-args # 22
2134       C_WARN_CLANG_CL_SIGN_COMPARE -Wno-sign-compare # 21
2135       C_WARN_CLANG_CL_FORMAT -Wno-format # 21
2136       C_WARN_CLANG_CL_C++98_COMPAT_BIND_TO_TEMPORARY_COPY -Wno-c++98-compat-bind-to-temporary-copy # 21
2137       C_WARN_CLANG_CL_ENUM_ENUM_CONVERSION -Wno-enum-enum-conversion # 20
2138       C_WARN_CLANG_CL_ANON_ENUM_ENUM_CONVERSION -Wno-anon-enum-enum-conversion # 14
2139       C_WARN_CLANG_CL_RANGE_LOOP_BIND_REFERENCE -Wno-range-loop-bind-reference # 14
2140       C_WARN_CLANG_CL_ENUM_FLOAT_CONVERSION -Wno-enum-float-conversion # 12
2141       C_WARN_CLANG_CL_KEYWORD_MACRO -Wno-keyword-macro # 10
2142       C_WARN_CLANG_CL_DEPRECATED_COPY -Wno-deprecated-copy # 10
2143       C_WARN_CLANG_CL_UNUSED_MEMBER_FUNCTION -Wno-unused-member-function # 9
2144       C_WARN_CLANG_CL_MISSING_NORETURN -Wno-missing-noreturn # 8
2145       C_WARN_CLANG_CL_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations # 8
2146       C_WARN_CLANG_CL_DOCUMENTATION_HTML -Wno-documentation-html # 6
2147       C_WARN_CLANG_CL_GNU_REDECLARED_ENUM -Wno-gnu-redeclared-enum # 6
2148       C_WARN_CLANG_CL_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations # 6
2149       C_WARN_CLANG_CL_OVERLOADED_VIRTUAL -Wno-overloaded-virtual # 5
2150       C_WARN_CLANG_CL_C++98_C++11_COMPAT_BINARY_LITERAL -Wno-c++98-c++11-compat-binary-literal # 4
2151       C_WARN_CLANG_CL_DEPRECATED_REDUNDANT_CONSTEXPR_STATIC_DEF -Wno-deprecated-redundant-constexpr-static-def # 4
2152       C_WARN_CLANG_CL_MISSING_BRACES -Wno-missing-braces # 4
2153       C_WARN_CLANG_CL_C99_EXTENSIONS -Wno-c99-extensions # 4
2154       C_WARN_CLANG_CL_STRICT_PROTOTYPES -Wno-strict-prototypes # 4
2155       C_WARN_CLANG_CL_UNREACHABLE_CODE_LOOP_INCREMENT -Wno-unreachable-code-loop-increment # 4
2156       C_WARN_CLANG_CL_GNU_CASE_RANGE -Wno-gnu-case-range # 4
2157       C_WARN_CLANG_CL_DUPLICATE_ENUM -Wno-duplicate-enum # 3
2158       C_WARN_CLANG_CL_NULL_POINTER_SUBTRACTION -Wno-null-pointer-subtraction # 2
2159       C_WARN_CLANG_CL_DEPRECATED_LITERAL_OPERATOR -Wno-deprecated-literal-operator # 2
2160       C_WARN_CLANG_CL_NEWLINE_EOF -Wno-newline-eof # 2
2161       C_WARN_CLANG_CL_MICROSOFT_CAST -Wno-microsoft-cast # 2
2162       C_WARN_CLANG_CL_DATE_TIME -Wno-date-time # 2
2163       C_WARN_CLANG_CL_DELETE_NON_ABSTRACT_NON_VIRTUAL_DTOR -Wno-delete-non-abstract-non-virtual-dtor # 2
2164       C_WARN_CLANG_CL_UNUSED_PRIVATE_FIELD -Wno-unused-private-field # 2
2165       C_WARN_CLANG_CL_FLEXIBLE_ARRAY_EXTENSIONS -Wno-flexible-array-extensions # 2
2166       C_WARN_CLANG_CL_STRING_CONVERSION -Wno-string-conversion # 2
2167       C_WARN_CLANG_CL_FINAL_DTOR_NON_FINAL_CLASS -Wno-final-dtor-non-final-class # 2
2168       C_WARN_CLANG_CL_MICROSOFT_UNQUALIFIED_FRIEND -Wno-microsoft-unqualified-friend # 2
2169       C_WARN_CLANG_CL_INVALID_NORETURN -Wno-invalid-noreturn # 1
2170       C_WARN_CLANG_CL_INVALID_UTF8 -Wno-invalid-utf8 # 1
2171       C_WARN_CLANG_CL_FOUR_CHAR_CONSTANTS -Wno-four-char-constants # 1
2172       C_WARN_CLANG_CL_PARENTHESES -Wno-parentheses # 1
2173       C_WARN_CLANG_CL_PESSIMIZING_MOVE -Wno-pessimizing-move # 1
2174       C_WARN_CLANG_CL_DEPRECATED_NON_PROTOTYPE -Wno-deprecated-non-prototype # 1
2175       C_WARN_CLANG_CL_BITFIELD_ENUM_CONVERSION -Wno-bitfield-enum-conversion # 1
2176       C_WARN_CLANG_CL_UNUSED_LAMBDA_CAPTURE -Wno-unused-lambda-capture # 1
2177       C_WARN_CLANG_CL_SHADOW_FIELD_IN_CONSTRUCTOR_MODIFIED -Wno-shadow-field-in-constructor-modified # 1
2178     )
2180   add_check_cxx_compiler_flags(
2181     CXX_WARNINGS
2182       CXX_WARN_CLANG_CL_W3 /W3
2183       CXX_WARN_CLANG_CL_C++98_COMPAT -Wno-c++98-compat # 352692
2184       CXX_WARN_CLANG_CL_OLD_STYLE_CAST -Wno-old-style-cast # 178608
2185       CXX_WARN_CLANG_CL_UNSAFE_BUFFER_USAGE -Wno-unsafe-buffer-usage # 89032
2186       CXX_WARN_CLANG_CL_MISSING_PROTOTYPES -Wno-missing-prototypes # 25587
2187       CXX_WARN_CLANG_CL_SIGN_CONVERSION -Wno-sign-conversion # 20109
2188       CXX_WARN_CLANG_CL_MISSING_FIELD_INITIALIZERS -Wno-missing-field-initializers # 20060
2189       CXX_WARN_CLANG_CL_EXTRA_SEMI -Wno-extra-semi # 12513
2190       CXX_WARN_CLANG_CL_LANGUAGE_EXTENSION_TOKEN -Wno-language-extension-token # 11032
2191       CXX_WARN_CLANG_CL_IMPLICIT_FLOAT_CONVERSION -Wno-implicit-float-conversion # 11003
2192       CXX_WARN_CLANG_CL_C++98_COMPAT_PEDANTIC -Wno-c++98-compat-pedantic # 10336
2193       CXX_WARN_CLANG_CL_IMPLICIT_INT_FLOAT_CONVERSION -Wno-implicit-int-float-conversion # 7354
2194       CXX_WARN_CLANG_CL_DOUBLE_PROMOTION -Wno-double-promotion # 7350
2195       CXX_WARN_CLANG_CL_PRE_C++17_COMPAT -Wno-pre-c++17-compat # 7303
2196       CXX_WARN_CLANG_CL_SHORTEN_64_TO_32 -Wno-shorten-64-to-32 # 7085
2197       CXX_WARN_CLANG_CL_C++98_COMPAT_LOCAL_TYPE_TEMPLATE_ARGS -Wno-c++98-compat-local-type-template-args # 6906
2198       CXX_WARN_CLANG_CL_RESERVED_IDENTIFIER -Wno-reserved-identifier # 5886
2199       CXX_WARN_CLANG_CL_CAST_ALIGN -Wno-cast-align # 5513
2200       CXX_WARN_CLANG_CL_DOCUMENTATION -Wno-documentation # 5107
2201       CXX_WARN_CLANG_CL_DISABLED_MACRO_EXPANSION -Wno-disabled-macro-expansion # 4449
2202       CXX_WARN_CLANG_CL_EXTRA_SEMI_STMT -Wno-extra-semi-stmt # 4349
2203       CXX_WARN_CLANG_CL_ZERO_AS_NULL_POINTER_CONSTANT -Wno-zero-as-null-pointer-constant # 3209
2204       CXX_WARN_CLANG_CL_FLOAT_CONVERSION -Wno-float-conversion # 2869
2205       CXX_WARN_CLANG_CL_RESERVED_MACRO_IDENTIFIER -Wno-reserved-macro-identifier # 2862
2206       CXX_WARN_CLANG_CL_CAST_FUNCTION_TYPE_STRICT -Wno-cast-function-type-strict # 2663
2207       CXX_WARN_CLANG_CL_FLOAT_EQUAL -Wno-float-equal # 2153
2208       CXX_WARN_CLANG_CL_IMPLICIT_INT_CONVERSION -Wno-implicit-int-conversion # 2117
2209       CXX_WARN_CLANG_CL_SHADOW -Wno-shadow # 2068
2210       CXX_WARN_CLANG_CL_SHADOW_FIELD_IN_CONSTRUCTOR -Wno-shadow-field-in-constructor # 1829
2211       CXX_WARN_CLANG_CL_CAST_QUAL -Wno-cast-qual # 1742
2212       CXX_WARN_CLANG_CL_PRE_C++14_COMPAT -Wno-pre-c++14-compat # 1569
2213       CXX_WARN_CLANG_CL_GLOBAL_CONSTRUCTORS -Wno-global-constructors # 1402
2214       CXX_WARN_CLANG_CL_SWITCH_ENUM -Wno-switch-enum # 973
2215       CXX_WARN_CLANG_CL_EXIT_TIME_DESTRUCTORS -Wno-exit-time-destructors # 940
2216       CXX_WARN_CLANG_CL_CTAD_MAYBE_UNSUPPORTED -Wno-ctad-maybe-unsupported # 891
2217       CXX_WARN_CLANG_CL_UNDEFINED_FUNC_TEMPLATE -Wno-undefined-func-template # 863
2218       CXX_WARN_CLANG_CL_C++98_COMPAT_EXTRA_SEMI -Wno-c++98-compat-extra-semi # 848
2219       CXX_WARN_CLANG_CL_CAST_FUNCTION_TYPE -Wno-cast-function-type # 807
2220       CXX_WARN_CLANG_CL_NULLABILITY_EXTENSION -Wno-nullability-extension # 602
2221       CXX_WARN_CLANG_CL_SHADOW_FIELD -Wno-shadow-field # 585
2222       CXX_WARN_CLANG_CL_CONDITIONAL_UNINITIALIZED -Wno-conditional-uninitialized # 555
2223       CXX_WARN_CLANG_CL_UNUSED_PARAMETER -Wno-unused-parameter # 539
2224       CXX_WARN_CLANG_CL_SUGGEST_DESTRUCTOR_OVERRIDE -Wno-suggest-destructor-override # 356
2225       CXX_WARN_CLANG_CL_SHADOW_UNCAPTURED_LOCAL -Wno-shadow-uncaptured-local # 355
2226       CXX_WARN_CLANG_CL_UNUSED_MACROS -Wno-unused-macros # 289
2227       CXX_WARN_CLANG_CL_COVERED_SWITCH_DEFAULT -Wno-covered-switch-default # 233
2228       CXX_WARN_CLANG_CL_SIGNED_ENUM_BITFIELD -Wno-signed-enum-bitfield # 229
2229       CXX_WARN_CLANG_CL_DECLARATION_AFTER_STATEMENT -Wno-declaration-after-statement # 228
2230       CXX_WARN_CLANG_CL_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough # 164
2231       CXX_WARN_CLANG_CL_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor # 161
2232       CXX_WARN_CLANG_CL_NESTED_ANON_TYPES -Wno-nested-anon-types # 140
2233       CXX_WARN_CLANG_CL_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS -Wno-gnu-zero-variadic-macro-arguments # 132
2234       CXX_WARN_CLANG_CL_UNREACHABLE_CODE_BREAK -Wno-unreachable-code-break # 115
2235       CXX_WARN_CLANG_CL_INCONSISTENT_MISSING_DESTRUCTOR_OVERRIDE -Wno-inconsistent-missing-destructor-override # 104
2236       CXX_WARN_CLANG_CL_FORMAT_PEDANTIC -Wno-format-pedantic # 97
2237       CXX_WARN_CLANG_CL_NONPORTABLE_SYSTEM_INCLUDE_PATH -Wno-nonportable-system-include-path # 95
2238       CXX_WARN_CLANG_CL_UNDEF -Wno-undef # 94
2239       CXX_WARN_CLANG_CL_IGNORED_QUALIFIERS -Wno-ignored-qualifiers # 93
2240       CXX_WARN_CLANG_CL_USED_BUT_MARKED_UNUSED -Wno-used-but-marked-unused # 83
2241       CXX_WARN_CLANG_CL_HEADER_HYGIENE -Wno-header-hygiene # 79
2242       CXX_WARN_CLANG_CL_CHAR_SUBSCRIPTS -Wno-char-subscripts # 76
2243       CXX_WARN_CLANG_CL_UNREACHABLE_CODE_RETURN -Wno-unreachable-code-return # 71
2244       CXX_WARN_CLANG_CL_UNUSED_TEMPLATE -Wno-unused-template # 66
2245       CXX_WARN_CLANG_CL_GNU_ANONYMOUS_STRUCT -Wno-gnu-anonymous-struct # 63
2246       CXX_WARN_CLANG_CL_DEPRECATED_COPY_WITH_USER_PROVIDED_DTOR -Wno-deprecated-copy-with-user-provided-dtor # 62
2247       CXX_WARN_CLANG_CL_INCONSISTENT_MISSING_OVERRIDE -Wno-inconsistent-missing-override # 54
2248       CXX_WARN_CLANG_CL_UNREACHABLE_CODE -Wno-unreachable-code # 52
2249       CXX_WARN_CLANG_CL_DEPRECATED_DYNAMIC_EXCEPTION_SPEC -Wno-deprecated-dynamic-exception-spec # 51
2250       CXX_WARN_CLANG_CL_BAD_FUNCTION_CAST -Wno-bad-function-cast # 50
2251       CXX_WARN_CLANG_CL_MICROSOFT_ENUM_VALUE -Wno-microsoft-enum-value # 47
2252       CXX_WARN_CLANG_CL_DEPRECATED_COPY_WITH_USER_PROVIDED_COPY -Wno-deprecated-copy-with-user-provided-copy # 41
2253       CXX_WARN_CLANG_CL_ZERO_LENGTH_ARRAY -Wno-zero-length-array # 39
2254       CXX_WARN_CLANG_CL_UNUSED_FUNCTION -Wno-unused-function # 38
2255       CXX_WARN_CLANG_CL_PEDANTIC -Wno-pedantic # 38
2256       CXX_WARN_CLANG_CL_DEPRECATED_COPY_WITH_DTOR -Wno-deprecated-copy-with-dtor # 37
2257       CXX_WARN_CLANG_CL_DOCUMENTATION_UNKNOWN_COMMAND -Wno-documentation-unknown-command # 34
2258       CXX_WARN_CLANG_CL_UNDEFINED_REINTERPRET_CAST -Wno-undefined-reinterpret-cast # 33
2259       CXX_WARN_CLANG_CL_FORMAT_NONLITERAL -Wno-format-nonliteral # 29
2260       CXX_WARN_CLANG_CL_COMMA -Wno-comma # 27
2261       CXX_WARN_CLANG_CL_DOCUMENTATION_DEPRECATED_SYNC -Wno-documentation-deprecated-sync # 26
2262       CXX_WARN_CLANG_CL_SHIFT_SIGN_OVERFLOW -Wno-shift-sign-overflow # 24
2263       CXX_WARN_CLANG_CL_PRE_C++17_COMPAT_PEDANTIC -Wno-pre-c++17-compat-pedantic # 24
2264       CXX_WARN_CLANG_CL_C++98_COMPAT_UNNAMED_TYPE_TEMPLATE_ARGS -Wno-c++98-compat-unnamed-type-template-args # 22
2265       CXX_WARN_CLANG_CL_SIGN_COMPARE -Wno-sign-compare # 21
2266       CXX_WARN_CLANG_CL_FORMAT -Wno-format # 21
2267       CXX_WARN_CLANG_CL_C++98_COMPAT_BIND_TO_TEMPORARY_COPY -Wno-c++98-compat-bind-to-temporary-copy # 21
2268       CXX_WARN_CLANG_CL_ENUM_ENUM_CONVERSION -Wno-enum-enum-conversion # 20
2269       CXX_WARN_CLANG_CL_ANON_ENUM_ENUM_CONVERSION -Wno-anon-enum-enum-conversion # 14
2270       CXX_WARN_CLANG_CL_RANGE_LOOP_BIND_REFERENCE -Wno-range-loop-bind-reference # 14
2271       CXX_WARN_CLANG_CL_ENUM_FLOAT_CONVERSION -Wno-enum-float-conversion # 12
2272       CXX_WARN_CLANG_CL_KEYWORD_MACRO -Wno-keyword-macro # 10
2273       CXX_WARN_CLANG_CL_DEPRECATED_COPY -Wno-deprecated-copy # 10
2274       CXX_WARN_CLANG_CL_UNUSED_MEMBER_FUNCTION -Wno-unused-member-function # 9
2275       CXX_WARN_CLANG_CL_MISSING_NORETURN -Wno-missing-noreturn # 8
2276       CXX_WARN_CLANG_CL_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations # 8
2277       CXX_WARN_CLANG_CL_DOCUMENTATION_HTML -Wno-documentation-html # 6
2278       CXX_WARN_CLANG_CL_GNU_REDECLARED_ENUM -Wno-gnu-redeclared-enum # 6
2279       CXX_WARN_CLANG_CL_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations # 6
2280       CXX_WARN_CLANG_CL_OVERLOADED_VIRTUAL -Wno-overloaded-virtual # 5
2281       CXX_WARN_CLANG_CL_C++98_C++11_COMPAT_BINARY_LITERAL -Wno-c++98-c++11-compat-binary-literal # 4
2282       CXX_WARN_CLANG_CL_DEPRECATED_REDUNDANT_CONSTEXPR_STATIC_DEF -Wno-deprecated-redundant-constexpr-static-def # 4
2283       CXX_WARN_CLANG_CL_MISSING_BRACES -Wno-missing-braces # 4
2284       CXX_WARN_CLANG_CL_C99_EXTENSIONS -Wno-c99-extensions # 4
2285       CXX_WARN_CLANG_CL_STRICT_PROTOTYPES -Wno-strict-prototypes # 4
2286       CXX_WARN_CLANG_CL_UNREACHABLE_CODE_LOOP_INCREMENT -Wno-unreachable-code-loop-increment # 4
2287       CXX_WARN_CLANG_CL_GNU_CASE_RANGE -Wno-gnu-case-range # 4
2288       CXX_WARN_CLANG_CL_DUPLICATE_ENUM -Wno-duplicate-enum # 3
2289       CXX_WARN_CLANG_CL_NULL_POINTER_SUBTRACTION -Wno-null-pointer-subtraction # 2
2290       CXX_WARN_CLANG_CL_DEPRECATED_LITERAL_OPERATOR -Wno-deprecated-literal-operator # 2
2291       CXX_WARN_CLANG_CL_NEWLINE_EOF -Wno-newline-eof # 2
2292       CXX_WARN_CLANG_CL_MICROSOFT_CAST -Wno-microsoft-cast # 2
2293       CXX_WARN_CLANG_CL_DATE_TIME -Wno-date-time # 2
2294       CXX_WARN_CLANG_CL_DELETE_NON_ABSTRACT_NON_VIRTUAL_DTOR -Wno-delete-non-abstract-non-virtual-dtor # 2
2295       CXX_WARN_CLANG_CL_UNUSED_PRIVATE_FIELD -Wno-unused-private-field # 2
2296       CXX_WARN_CLANG_CL_FLEXIBLE_ARRAY_EXTENSIONS -Wno-flexible-array-extensions # 2
2297       CXX_WARN_CLANG_CL_STRING_CONVERSION -Wno-string-conversion # 2
2298       CXX_WARN_CLANG_CL_FINAL_DTOR_NON_FINAL_CLASS -Wno-final-dtor-non-final-class # 2
2299       CXX_WARN_CLANG_CL_MICROSOFT_UNQUALIFIED_FRIEND -Wno-microsoft-unqualified-friend # 2
2300       CXX_WARN_CLANG_CL_INVALID_NORETURN -Wno-invalid-noreturn # 1
2301       CXX_WARN_CLANG_CL_INVALID_UTF8 -Wno-invalid-utf8 # 1
2302       CXX_WARN_CLANG_CL_FOUR_CHAR_CONSTANTS -Wno-four-char-constants # 1
2303       CXX_WARN_CLANG_CL_PARENTHESES -Wno-parentheses # 1
2304       CXX_WARN_CLANG_CL_PESSIMIZING_MOVE -Wno-pessimizing-move # 1
2305       CXX_WARN_CLANG_CL_DEPRECATED_NON_PROTOTYPE -Wno-deprecated-non-prototype # 1
2306       CXX_WARN_CLANG_CL_BITFIELD_ENUM_CONVERSION -Wno-bitfield-enum-conversion # 1
2307       CXX_WARN_CLANG_CL_UNUSED_LAMBDA_CAPTURE -Wno-unused-lambda-capture # 1
2308       CXX_WARN_CLANG_CL_SHADOW_FIELD_IN_CONSTRUCTOR_MODIFIED -Wno-shadow-field-in-constructor-modified # 1
2309     )
2310   endif()
2313   # ---------------------
2314   # Suppress Strict Flags
2316   # flags to undo strict flags
2318   add_check_c_compiler_flags(
2319     C_REMOVE_STRICT_FLAGS
2321     C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
2322     C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
2323     C_WARN_NO_UNUSED_MACROS -Wno-unused-macros
2324     C_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation
2326     C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations
2327     C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers
2328     C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function
2329     C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast
2330     C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes
2331     C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum
2332     C_WARN_NO_UNDEF -Wno-undef
2333     C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn
2334     C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable
2335     C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations
2336     C_WARN_NO_STRICT_PROTOTYPES -Wno-strict-prototypes
2337     C_WARN_NO_BITWISE_INSTEAD_OF_LOGICAL -Wno-bitwise-instead-of-logical
2338     C_WARN_NO_IMPLICIT_CONST_INT_FLOAT_CONVERSION -Wno-implicit-const-int-float-conversion
2339     C_WARN_NO_SINGLE_BIT_BITFIELD_CONSTANT_CONVERSION -Wno-single-bit-bitfield-constant-conversion
2340   )
2342   add_check_cxx_compiler_flags(
2343     CXX_REMOVE_STRICT_FLAGS
2345     CXX_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
2346     CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field
2347     CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing
2348     CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor
2349     CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros
2350     CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
2351     CXX_WARN_NO_REORDER -Wno-reorder
2352     CXX_WARN_NO_COMMENT -Wno-comment
2353     CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs
2354     CXX_WARN_NO_UNDEFINED_VAR_TEMPLATE -Wno-undefined-var-template
2355     CXX_WARN_NO_INSTANTIATION_AFTER_SPECIALIZATION -Wno-instantiation-after-specialization
2356     CXX_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation
2357     CXX_WARN_NO_BITWISE_INSTEAD_OF_LOGICAL -Wno-bitwise-instead-of-logical
2358     CXX_WARN_NO_IMPLICIT_CONST_INT_FLOAT_CONVERSION -Wno-implicit-const-int-float-conversion
2359     CXX_WARN_NO_UNDEF -Wno-undef
2360     CXX_WARN_NO_UNDEF_PREFIX -Wno-undef-prefix
2361   )
2363 elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
2365   add_check_c_compiler_flags(
2366     C_WARNINGS
2368     C_WARN_ALL -Wall
2369     C_WARN_POINTER_ARITH -Wpointer-arith
2370     C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
2371   )
2373   add_check_cxx_compiler_flags(
2374     CXX_WARNINGS
2376     CXX_WARN_ALL -Wall
2377     CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
2378     CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
2379   )
2381   # Disable numbered, false positives.
2382   string(APPEND C_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
2383   string(APPEND CXX_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
2384 elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
2385   # most msvc warnings are C & C++
2386   set(_WARNINGS
2387     # warning level:
2388     "/W3"
2389     "/w34062"  # switch statement contains 'default' but no 'case' labels
2390     "/w34100"  # 'identifier' : unreferenced formal parameter
2391     "/w34115"  # 'type' : named type definition in parentheses
2392     "/w34189"  # local variable is initialized but not referenced
2393     # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017
2394     "/w35038"  # order of initialization in c++ constructors
2395     # disable:
2396     "/wd4018"  # signed/unsigned mismatch
2397     "/wd4146"  # unary minus operator applied to unsigned type, result still unsigned
2398     "/wd4065"  # switch statement contains 'default' but no 'case' labels
2399     "/wd4127"  # conditional expression is constant
2400     "/wd4181"  # qualifier applied to reference type; ignored
2401     "/wd4200"  # zero-sized array in struct/union
2402     "/wd4244"  # conversion from 'type1' to 'type2', possible loss of data
2403     "/wd4267"  # conversion from 'size_t' to 'type', possible loss of data
2404     "/wd4305"  # truncation from 'type1' to 'type2'
2405     "/wd4800"  # forcing value to bool 'true' or 'false'
2406     "/wd4828"  # The file contains a character that is illegal
2407     "/wd4996"  # identifier was declared deprecated
2408     "/wd4661"  # no suitable definition provided for explicit template instantiation request
2409     "/wd4848"  # 'no_unique_address' is a vendor extension in C++17
2410     # errors:
2411     "/we4013"  # 'function' undefined; assuming extern returning int
2412     "/we4133"  # incompatible pointer types
2413     "/we4431"  # missing type specifier - int assumed
2414     "/we4033"  # 'function' must return a value
2415   )
2417   string(REPLACE ";" " " _WARNINGS "${_WARNINGS}")
2418   set(C_WARNINGS "${_WARNINGS}")
2419   set(CXX_WARNINGS "${_WARNINGS}")
2420   unset(_WARNINGS)
2421 endif()
2423 # Xcode enables additional warning flags by default. Disable some to match
2424 # command line build and other platforms more closely.
2425 if(XCODE)
2426   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO)
2427 endif()
2429 # ensure python header is found since detection can fail, this could happen
2430 # with _any_ library but since we used a fixed python version this tends to
2431 # be most problematic.
2432 if(WITH_PYTHON)
2433   if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
2434     message(
2435       FATAL_ERROR
2436       "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
2437       "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
2438       "to a valid python include path. Containing "
2439       "Python.h for python version \"${PYTHON_VERSION}\""
2440     )
2441   endif()
2443   if(WIN32)
2444     # Always use numpy bundled in precompiled libs.
2445   elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR WITH_PYTHON_NUMPY)
2446     if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
2447       find_python_package(numpy "core/include")
2448     endif()
2449   endif()
2451   if(WIN32 OR APPLE)
2452     # Always copy from precompiled libs.
2453   elseif(WITH_PYTHON_INSTALL_REQUESTS)
2454     find_python_package(requests "")
2455   endif()
2457   if(WIN32 OR APPLE)
2458     # Always copy from precompiled libs.
2459   elseif(WITH_PYTHON_INSTALL_ZSTANDARD)
2460     find_python_package(zstandard "")
2461   endif()
2462 endif()
2464 # Select C++17 as the standard for C++ projects.
2465 set(CMAKE_CXX_STANDARD 17)
2466 # If C++17 is not available, downgrading to an earlier standard is NOT OK.
2467 set(CMAKE_CXX_STANDARD_REQUIRED ON)
2468 # Do not enable compiler specific language extensions.
2469 set(CMAKE_CXX_EXTENSIONS OFF)
2471 # Visual Studio has all standards it supports available by default
2472 # Clang on windows copies this behavior and does not support these switches
2474   CMAKE_COMPILER_IS_GNUCC OR
2475   (CMAKE_C_COMPILER_ID MATCHES "Clang" AND (NOT MSVC)) OR
2476   (CMAKE_C_COMPILER_ID STREQUAL "Intel")
2478   # Use C11 + GNU extensions, works with GCC, Clang, ICC
2479   string(APPEND CMAKE_C_FLAGS " -std=gnu11")
2480 endif()
2482 if(WITH_COMPILER_SHORT_FILE_MACRO)
2483   # Use '-fmacro-prefix-map' for Clang and GCC (MSVC doesn't support this).
2484   set(C_PREFIX_MAP_FLAGS "")
2485   set(CXX_PREFIX_MAP_FLAGS "")
2486   add_check_c_compiler_flags(
2487     C_PREFIX_MAP_FLAGS
2488     C_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar
2489   )
2490   add_check_cxx_compiler_flags(
2491     CXX_PREFIX_MAP_FLAGS
2492     CXX_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar
2493   )
2494   if(C_MACRO_PREFIX_MAP AND CXX_MACRO_PREFIX_MAP)
2495     if(APPLE)
2496       if(XCODE AND ${XCODE_VERSION} VERSION_LESS 12.0)
2497       # Developers may have say LLVM Clang-10.0.1 toolchain (which supports the flag)
2498       # with Xcode-11 (the Clang of which doesn't support the flag).
2499         message(
2500           WARNING
2501           "-fmacro-prefix-map flag is NOT supported by Clang shipped with Xcode-${XCODE_VERSION}."
2502           " Some Xcode functionality in Product menu may not work. "
2503           "Disabling WITH_COMPILER_SHORT_FILE_MACRO."
2504         )
2505         set(WITH_COMPILER_SHORT_FILE_MACRO OFF)
2506       endif()
2507     endif()
2508     if(WITH_COMPILER_SHORT_FILE_MACRO)
2509       path_ensure_trailing_slash(_src_dir "${CMAKE_SOURCE_DIR}")
2510       path_ensure_trailing_slash(_bin_dir "${CMAKE_BINARY_DIR}")
2511       # Keep this variable so it can be stripped from build-info.
2512       set(PLATFORM_CFLAGS_FMACRO_PREFIX_MAP
2513         "-fmacro-prefix-map=\"${_src_dir}\"=\"\" -fmacro-prefix-map=\"${_bin_dir}\"=\"\"")
2514       string(APPEND PLATFORM_CFLAGS " ${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}")
2515       unset(_src_dir)
2516       unset(_bin_dir)
2517     endif()
2518   else()
2519     message(
2520       WARNING
2521       "-fmacro-prefix-map flag is NOT supported by C/C++ compiler."
2522       " Disabling WITH_COMPILER_SHORT_FILE_MACRO."
2523     )
2524     set(WITH_COMPILER_SHORT_FILE_MACRO OFF)
2525   endif()
2526   unset(C_PREFIX_MAP_FLAGS)
2527   unset(CXX_PREFIX_MAP_FLAGS)
2528 endif()
2530 # Include warnings first, so its possible to disable them with user defined flags
2531 # eg: -Wno-uninitialized
2532 set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
2533 set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}")
2535 # defined above, platform specific but shared names
2536 mark_as_advanced(
2537   CYCLES_OSL
2538   OSL_LIB_EXEC
2539   OSL_COMPILER
2540   OSL_LIB_COMP
2541   OSL_LIB_QUERY
2542   OSL_INCLUDE_DIR
2545 mark_as_advanced(
2546   LLVM_CONFIG
2547   LLVM_ROOT_DIR
2548   LLVM_LIBRARY
2549   LLVM_VERSION
2553 # -------------------------------------------------------------------------------
2554 # Global Defines
2556 # better not set includes here but this debugging option is off by default.
2557 if(WITH_CXX_GUARDEDALLOC)
2558   include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
2559   add_definitions(-DWITH_CXX_GUARDEDALLOC)
2560 endif()
2562 if(WITH_ASSERT_ABORT)
2563   add_definitions(-DWITH_ASSERT_ABORT)
2564 endif()
2566 # NDEBUG is the standard C define to disable asserts.
2567 if(WITH_ASSERT_RELEASE)
2568   # CMake seemingly be setting the NDEBUG flag on its own already on some configurations
2569   # therefore we need to remove the flags if they happen to be set.
2570   remove_cc_flag("-DNDEBUG") # GCC/CLang
2571   remove_cc_flag("/DNDEBUG") # MSVC
2572 else()
2573   set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
2574     $<$<CONFIG:Release>:NDEBUG>
2575     $<$<CONFIG:MinSizeRel>:NDEBUG>
2576     $<$<CONFIG:RelWithDebInfo>:NDEBUG>
2577   )
2578 endif()
2580 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
2581 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
2583 # -----------------------------------------------------------------------------
2584 # Testing Functions
2586 include(build_files/cmake/testing.cmake)
2588 # -----------------------------------------------------------------------------
2589 # Add Sub-Directories
2591 if(WITH_BLENDER)
2592   add_subdirectory(intern)
2593   add_subdirectory(extern)
2595   # source after intern and extern to gather all
2596   # internal and external library information first, for test linking
2597   add_subdirectory(source)
2598 elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
2599   add_subdirectory(intern/guardedalloc)
2600   add_subdirectory(intern/libc_compat)
2601   add_subdirectory(intern/sky)
2603   add_subdirectory(intern/cycles)
2604   if(WITH_CYCLES_LOGGING)
2605     if(NOT WITH_SYSTEM_GFLAGS)
2606       add_subdirectory(extern/gflags)
2607     endif()
2608     add_subdirectory(extern/glog)
2609   endif()
2610   if(WITH_CUDA_DYNLOAD)
2611     add_subdirectory(extern/cuew)
2612   endif()
2613   if(WITH_HIP_DYNLOAD)
2614     add_subdirectory(extern/hipew)
2615   endif()
2616 endif()
2619 # -----------------------------------------------------------------------------
2620 # Add Testing Directory
2622 add_subdirectory(tests)
2625 # -----------------------------------------------------------------------------
2626 # Add Blender Application
2628 if(WITH_BLENDER)
2629   add_subdirectory(source/creator)
2630 endif()
2633 # -----------------------------------------------------------------------------
2634 # Define 'heavy' sub-modules (for Ninja builder when using pools)
2635 setup_heavy_lib_pool()
2638 # -----------------------------------------------------------------------------
2639 # CPack for generating packages
2641 include(build_files/cmake/packaging.cmake)
2644 # -----------------------------------------------------------------------------
2645 # Use Dynamic Loading for OpenMP
2647 if(WITH_BLENDER)
2648   openmp_delayload(blender)
2649 endif()
2652 # -----------------------------------------------------------------------------
2653 # Print Final Configuration
2655 if(FIRST_RUN)
2657   set(_config_msg "\nBlender Configuration\n=====================")
2659   function(info_cfg_option
2660     _setting
2661     )
2663     set(_msg "  - ${_setting}")
2664     string(LENGTH "${_msg}" _len)
2665     while("36" GREATER "${_len}")
2666       string(APPEND _msg " ")
2667       math(EXPR _len "${_len} + 1")
2668     endwhile()
2670     set(_config_msg "${_config_msg}\n${_msg}${${_setting}}" PARENT_SCOPE)
2671   endfunction()
2673   function(info_cfg_text
2674     _text
2675     )
2677     set(_config_msg "${_config_msg}\n\n  ${_text}" PARENT_SCOPE)
2678   endfunction()
2680   message(STATUS "C Compiler:   \"${CMAKE_C_COMPILER_ID}\"")
2681   message(STATUS "C++ Compiler: \"${CMAKE_CXX_COMPILER_ID}\"")
2683   info_cfg_text("Build Options:")
2684   info_cfg_option(WITH_ALEMBIC)
2685   info_cfg_option(WITH_BULLET)
2686   info_cfg_option(WITH_CLANG)
2687   info_cfg_option(WITH_CYCLES)
2688   info_cfg_option(WITH_FFTW3)
2689   info_cfg_option(WITH_FREESTYLE)
2690   info_cfg_option(WITH_GMP)
2691   info_cfg_option(WITH_HARU)
2692   info_cfg_option(WITH_IK_ITASC)
2693   info_cfg_option(WITH_IK_SOLVER)
2694   info_cfg_option(WITH_INPUT_NDOF)
2695   info_cfg_option(WITH_INPUT_IME)
2696   info_cfg_option(WITH_INTERNATIONAL)
2697   info_cfg_option(WITH_OPENCOLLADA)
2698   info_cfg_option(WITH_OPENCOLORIO)
2699   info_cfg_option(WITH_OPENIMAGEDENOISE)
2700   info_cfg_option(WITH_OPENVDB)
2701   info_cfg_option(WITH_POTRACE)
2702   info_cfg_option(WITH_PUGIXML)
2703   info_cfg_option(WITH_QUADRIFLOW)
2704   info_cfg_option(WITH_TBB)
2705   info_cfg_option(WITH_USD)
2706   info_cfg_option(WITH_MATERIALX)
2707   info_cfg_option(WITH_XR_OPENXR)
2709   info_cfg_text("Compiler Options:")
2710   info_cfg_option(WITH_BUILDINFO)
2711   info_cfg_option(WITH_OPENMP)
2713   info_cfg_text("System Options:")
2714   info_cfg_option(WITH_INSTALL_PORTABLE)
2715   info_cfg_option(WITH_MEM_JEMALLOC)
2716   info_cfg_option(WITH_MEM_VALGRIND)
2718   info_cfg_text("GHOST Options:")
2719   info_cfg_option(WITH_GHOST_DEBUG)
2720   info_cfg_option(WITH_GHOST_SDL)
2721   if(UNIX AND NOT APPLE)
2722     info_cfg_option(WITH_GHOST_X11)
2723     info_cfg_option(WITH_GHOST_WAYLAND)
2724     if(WITH_GHOST_X11)
2725       info_cfg_option(WITH_GHOST_XDND)
2726       info_cfg_option(WITH_X11_XF86VMODE)
2727       info_cfg_option(WITH_X11_XFIXES)
2728       info_cfg_option(WITH_X11_XINPUT)
2729     endif()
2730     if(WITH_GHOST_WAYLAND)
2731       info_cfg_option(WITH_GHOST_WAYLAND_DYNLOAD)
2732       info_cfg_option(WITH_GHOST_WAYLAND_LIBDECOR)
2733     endif()
2734   endif()
2736   info_cfg_text("Image Formats:")
2737   info_cfg_option(WITH_IMAGE_CINEON)
2738   info_cfg_option(WITH_IMAGE_OPENEXR)
2739   info_cfg_option(WITH_IMAGE_OPENJPEG)
2741   info_cfg_text("Audio:")
2742   info_cfg_option(WITH_CODEC_FFMPEG)
2743   info_cfg_option(WITH_CODEC_SNDFILE)
2744   info_cfg_option(WITH_COREAUDIO)
2745   info_cfg_option(WITH_JACK)
2746   info_cfg_option(WITH_JACK_DYNLOAD)
2747   info_cfg_option(WITH_OPENAL)
2748   info_cfg_option(WITH_PULSEAUDIO)
2749   info_cfg_option(WITH_PULSEAUDIO_DYNLOAD)
2750   info_cfg_option(WITH_SDL)
2751   info_cfg_option(WITH_SDL_DYNLOAD)
2752   info_cfg_option(WITH_WASAPI)
2754   info_cfg_text("Compression:")
2755   info_cfg_option(WITH_LZMA)
2756   info_cfg_option(WITH_LZO)
2758   if(WITH_PYTHON)
2759     info_cfg_text("Python:")
2760     info_cfg_option(WITH_PYTHON_INSTALL)
2761     info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
2762     info_cfg_option(WITH_PYTHON_INSTALL_ZSTANDARD)
2763     info_cfg_option(WITH_PYTHON_MODULE)
2764     info_cfg_option(WITH_PYTHON_SAFETY)
2765   endif()
2767   info_cfg_text("Modifiers:")
2768   info_cfg_option(WITH_MOD_FLUID)
2769   info_cfg_option(WITH_MOD_OCEANSIM)
2770   info_cfg_option(WITH_MOD_REMESH)
2772   info_cfg_text("Rendering:")
2773   info_cfg_option(WITH_HYDRA)
2775   if(WITH_CYCLES)
2776     info_cfg_text("Rendering (Cycles):")
2777     info_cfg_option(WITH_CYCLES_OSL)
2778     info_cfg_option(WITH_CYCLES_EMBREE)
2779     info_cfg_option(WITH_CYCLES_PATH_GUIDING)
2780     if(NOT APPLE)
2781       info_cfg_option(WITH_CYCLES_DEVICE_OPTIX)
2782       info_cfg_option(WITH_CYCLES_DEVICE_CUDA)
2783       info_cfg_option(WITH_CYCLES_CUDA_BINARIES)
2784       info_cfg_option(WITH_CYCLES_DEVICE_ONEAPI)
2785       info_cfg_option(WITH_CYCLES_ONEAPI_BINARIES)
2786       info_cfg_option(WITH_CYCLES_DEVICE_HIP)
2787       info_cfg_option(WITH_CYCLES_HIP_BINARIES)
2788     endif()
2789     if(WIN32)
2790       info_cfg_option(WITH_CYCLES_DEVICE_HIPRT)
2791     endif()
2792   endif()
2794   info_cfg_text("")
2796   message("${_config_msg}")
2797 endif()
2799 if(0)
2800   print_all_vars()
2801 endif()
2803 # Should be the last step of configuration.
2804 if(POSTCONFIGURE_SCRIPT)
2805   include(${POSTCONFIGURE_SCRIPT})
2806 endif()