Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt501
1 files changed, 160 insertions, 341 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1416b5b4189..ed2aa4de78e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,11 +1,12 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2006 Blender Foundation. All rights reserved.
-#-----------------------------------------------------------------------------
-# We don't allow in-source builds. This causes no end of troubles because
+# -----------------------------------------------------------------------------
+# Early Initialization
+
+# NOTE: We don't allow in-source builds. This causes no end of troubles because
# all out-of-source builds will use the CMakeCache.txt file there and even
# build the libs and objects in it.
-
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
if(NOT DEFINED WITH_IN_SOURCE_BUILD)
message(FATAL_ERROR
@@ -25,13 +26,6 @@ endif()
cmake_minimum_required(VERSION 3.10)
-# Prefer LEGACY OpenGL to be compatible with all the existing releases and
-# platforms which don't have GLVND yet. Only do it if preference was not set
-# externally.
-if(NOT DEFINED OpenGL_GL_PREFERENCE)
- set(OpenGL_GL_PREFERENCE "LEGACY")
-endif()
-
if(NOT EXECUTABLE_OUTPUT_PATH)
set(FIRST_RUN TRUE)
else()
@@ -42,7 +36,7 @@ endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/platform")
-# avoid having empty buildtype
+# Avoid having an empty `CMAKE_BUILD_TYPE`.
if(NOT DEFINED CMAKE_BUILD_TYPE_INIT)
set(CMAKE_BUILD_TYPE_INIT "Release")
# Internal logic caches this variable, avoid showing it by default
@@ -66,7 +60,8 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:RelWithDebInfo>:NDEBUG>
)
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Set policy
# see "cmake --help-policy CMP0003"
@@ -96,13 +91,16 @@ endif()
if(POLICY CMP0087)
cmake_policy(SET CMP0087 NEW)
endif()
-#-----------------------------------------------------------------------------
-# Load some macros.
+
+
+# -----------------------------------------------------------------------------
+# Load Blender's Local Macros
+
include(build_files/cmake/macros.cmake)
-#-----------------------------------------------------------------------------
-# Initialize project.
+# -----------------------------------------------------------------------------
+# Initialize Project
blender_project_hack_pre()
@@ -112,8 +110,15 @@ blender_project_hack_post()
enable_testing()
-#-----------------------------------------------------------------------------
-# Redirect output files
+
+# -----------------------------------------------------------------------------
+# Test Compiler/Library Features
+
+include(build_files/cmake/have_features.cmake)
+
+
+# -----------------------------------------------------------------------------
+# Redirect Output Files
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)
@@ -125,14 +130,15 @@ else()
set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/ CACHE INTERNAL "" FORCE)
endif()
-#-----------------------------------------------------------------------------
-# Set default config options
+
+# -----------------------------------------------------------------------------
+# Set Default Configuration Options
get_blender_version()
-#-----------------------------------------------------------------------------
-# Options
+# -----------------------------------------------------------------------------
+# Declare Options
# Blender internal features
option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
@@ -158,9 +164,6 @@ mark_as_advanced(WITH_PYTHON_SECURITY) # some distributions see this as a secur
option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some efficiency, only enable for development)." OFF)
mark_as_advanced(WITH_PYTHON_SAFETY)
option(WITH_PYTHON_MODULE "Enable building as a python module which runs without a user interface, like running regular blender in background mode (experimental, only enable for development), installs to PYTHON_SITE_PACKAGES (or CMAKE_INSTALL_PREFIX if WITH_INSTALL_PORTABLE is enabled)." OFF)
-if(APPLE)
- option(WITH_PYTHON_FRAMEWORK "Enable building using the Python available in the framework (OSX only)" OFF)
-endif()
option(WITH_BUILDINFO "Include extra build details (only disable for development & faster builds)" ON)
set(BUILDINFO_OVERRIDE_DATE "" CACHE STRING "Use instead of the current date for reproducible builds (empty string disables this option)")
@@ -196,7 +199,7 @@ endif()
option(WITH_GMP "Enable features depending on GMP (Exact Boolean)" ON)
# Compositor
-option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
+option(WITH_COMPOSITOR_CPU "Enable the tile based CPU nodal compositor" ON)
option(WITH_OPENIMAGEDENOISE "Enable the OpenImageDenoise compositing node" ON)
option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" ON)
@@ -223,7 +226,7 @@ if(UNIX AND NOT (APPLE OR HAIKU))
option(WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing (under development)" OFF)
mark_as_advanced(WITH_GHOST_WAYLAND)
- if (WITH_GHOST_WAYLAND)
+ if(WITH_GHOST_WAYLAND)
option(WITH_GHOST_WAYLAND_LIBDECOR "Optionally build with LibDecor window decorations" OFF)
mark_as_advanced(WITH_GHOST_WAYLAND_LIBDECOR)
@@ -262,7 +265,6 @@ if(WITH_GHOST_X11)
option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON)
option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON)
option(WITH_X11_XFIXES "Enable X11 XWayland cursor warping workaround" ON)
- option(WITH_X11_ALPHA "Enable X11 transparent background" ON)
endif()
if(UNIX AND NOT APPLE)
@@ -366,7 +368,7 @@ if(WIN32 OR APPLE)
endif()
option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ON)
if(UNIX AND NOT APPLE)
- option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
+ option(WITH_INSTALL_PORTABLE "Install redistributable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
option(WITH_STATIC_LIBS "Try to link with static libraries, as much as possible, to make blender more portable across distributions" OFF)
if(WITH_STATIC_LIBS)
option(WITH_BOOST_ICU "Boost uses ICU library (required for linking with static Boost built with libicu)." OFF)
@@ -437,10 +439,16 @@ if(NOT APPLE)
option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF)
option(WITH_CUDA_DYNLOAD "Dynamically load CUDA libraries at runtime (for developers, makes cuda-gdb work)" ON)
+
+ set(OPTIX_ROOT_DIR "" CACHE PATH "Path to the OptiX SDK root directory, for building Cycles OptiX kernels.")
+ set(CYCLES_RUNTIME_OPTIX_ROOT_DIR "" CACHE PATH "Path to the OptiX SDK root directory. When set, this path will be used at runtime to compile OptiX kernels.")
+
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER)
mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
mark_as_advanced(WITH_CUDA_DYNLOAD)
+ mark_as_advanced(OPTIX_ROOT_DIR)
+ mark_as_advanced(CYCLES_RUNTIME_OPTIX_ROOT_DIR)
endif()
# AMD HIP
@@ -464,8 +472,8 @@ if(NOT APPLE)
option(WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED "Enable use of SYCL host (CPU) device execution by oneAPI implementation. This option is for debugging purposes and impacts GPU execution." OFF)
# https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compilation/ahead-of-time-compilation.html
- SET (CYCLES_ONEAPI_SPIR64_GEN_DEVICES "dg2" CACHE STRING "oneAPI Intel GPU architectures to build binaries for")
- SET (CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "oneAPI targets to build AOT binaries for")
+ set(CYCLES_ONEAPI_SPIR64_GEN_DEVICES "dg2" CACHE STRING "oneAPI Intel GPU architectures to build binaries for")
+ set(CYCLES_ONEAPI_SYCL_TARGETS spir64 spir64_gen CACHE STRING "oneAPI targets to build AOT binaries for")
mark_as_advanced(WITH_CYCLES_ONEAPI_SYCL_HOST_ENABLED)
mark_as_advanced(CYCLES_ONEAPI_SPIR64_GEN_DEVICES)
@@ -536,68 +544,28 @@ endif()
# OpenGL
-# Experimental EGL option.
-option(WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, GLX or WGL)" OFF)
-mark_as_advanced(WITH_GL_EGL)
-
-if(WITH_GHOST_WAYLAND)
- # Wayland can only use EGL to create OpenGL contexts, not GLX.
- set(WITH_GL_EGL ON)
-endif()
-
-if(UNIX AND NOT APPLE)
- if(WITH_GL_EGL)
- # GLEW can only be built with either GLX or EGL support. Most binary distributions are
- # built with GLX support and we have no automated way to detect this. So always build
- # GLEW from source to be sure it has EGL support.
- set(WITH_SYSTEM_GLEW OFF)
- else()
- option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF)
- endif()
-
- option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON)
-else()
- # System GLEW and GLES not an option on other platforms.
- set(WITH_SYSTEM_GLEW OFF)
- set(WITH_SYSTEM_GLES OFF)
-endif()
-
option(WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON)
-option(WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
-option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
-option(WITH_GPU_SHADER_BUILDER "Shader builder is a developer option enabling linting on GLSL during compilation" OFF)
+option(WITH_GPU_BUILDTIME_SHADER_BUILDER "Shader builder is a developer option enabling linting on GLSL during compilation" OFF)
mark_as_advanced(
WITH_OPENGL
- WITH_GLEW_ES
- WITH_GL_PROFILE_ES20
- WITH_GPU_SHADER_BUILDER
+ WITH_GPU_BUILDTIME_SHADER_BUILDER
)
# Metal
-if (APPLE)
+if(APPLE)
option(WITH_METAL_BACKEND "Use Metal for graphics instead of (or as well as) OpenGL on macOS." OFF)
mark_as_advanced(WITH_METAL_BACKEND)
else()
set(WITH_METAL_BACKEND OFF)
endif()
-if (WITH_METAL_BACKEND)
+if(WITH_METAL_BACKEND)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version" FORCE)
endif()
if(WIN32)
- option(WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF)
- mark_as_advanced(WITH_GL_ANGLE)
-endif()
-
-if(WITH_GLEW_ES AND WITH_SYSTEM_GLEW)
- message(WARNING Ignoring WITH_SYSTEM_GLEW and using WITH_GLEW_ES)
- set(WITH_SYSTEM_GLEW OFF)
-endif()
-
-if(WIN32)
getDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
endif()
@@ -773,6 +741,13 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()
endif()
+# Effective install path including config folder, as a generator expression.
+get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(GENERATOR_IS_MULTI_CONFIG)
+ string(REPLACE "\${BUILD_TYPE}" "$<CONFIG>" CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX})
+else()
+ string(REPLACE "\${BUILD_TYPE}" "" CMAKE_INSTALL_PREFIX_WITH_CONFIG ${CMAKE_INSTALL_PREFIX})
+endif()
# Apple
@@ -782,8 +757,8 @@ if(APPLE)
endif()
-#-----------------------------------------------------------------------------
-# Check for conflicting/unsupported configurations
+# -----------------------------------------------------------------------------
+# Check for Conflicting/Unsupported Configurations
if(NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE AND NOT WITH_CYCLES_HYDRA_RENDER_DELEGATE)
message(FATAL_ERROR
@@ -893,7 +868,6 @@ if(WITH_GHOST_SDL OR WITH_HEADLESS)
set(WITH_X11_XINPUT OFF)
set(WITH_X11_XF86VMODE OFF)
set(WITH_X11_XFIXES OFF)
- set(WITH_X11_ALPHA OFF)
set(WITH_GHOST_XDND OFF)
set(WITH_INPUT_IME OFF)
set(WITH_XR_OPENXR OFF)
@@ -918,7 +892,11 @@ endif()
if(WITH_CYCLES AND WITH_CYCLES_DEVICE_CUDA AND NOT WITH_CUDA_DYNLOAD)
find_package(CUDA)
if(NOT CUDA_FOUND)
- message(STATUS "CUDA toolkit not found, using dynamic runtime loading of libraries (WITH_CUDA_DYNLOAD) instead")
+ message(
+ STATUS
+ "CUDA toolkit not found, "
+ "using dynamic runtime loading of libraries (WITH_CUDA_DYNLOAD) instead"
+ )
set(WITH_CUDA_DYNLOAD ON)
endif()
endif()
@@ -928,14 +906,16 @@ if(WITH_CYCLES_DEVICE_HIP)
set(WITH_HIP_DYNLOAD ON)
endif()
-#-----------------------------------------------------------------------------
-# Check if submodules are cloned.
+
+# -----------------------------------------------------------------------------
+# Check if Sub-modules are Cloned
if(WITH_INTERNATIONAL)
file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
list(LENGTH RESULT DIR_LEN)
if(DIR_LEN EQUAL 0)
- message(WARNING
+ message(
+ WARNING
"Translation path '${CMAKE_SOURCE_DIR}/release/datafiles/locale' is missing, "
"This is a 'git submodule', which are known not to work with bridges to other version "
"control systems, disabling 'WITH_INTERNATIONAL'."
@@ -953,13 +933,17 @@ if(WITH_PYTHON)
# because UNIX will search for the old Python paths which may not exist.
# giving errors about missing paths before this case is met.
if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.10")
- message(FATAL_ERROR "At least Python 3.10 is required to build, but found Python ${PYTHON_VERSION}")
+ message(
+ FATAL_ERROR
+ "At least Python 3.10 is required to build, but found Python ${PYTHON_VERSION}"
+ )
endif()
file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/scripts/addons")
list(LENGTH RESULT DIR_LEN)
if(DIR_LEN EQUAL 0)
- message(WARNING
+ message(
+ WARNING
"Addons path '${CMAKE_SOURCE_DIR}/release/scripts/addons' is missing, "
"This is a 'git submodule', which are known not to work with bridges to other version "
"control systems: * CONTINUING WITHOUT ADDONS *"
@@ -967,8 +951,9 @@ if(WITH_PYTHON)
endif()
endif()
-#-----------------------------------------------------------------------------
-# Initialize un-cached vars, avoid unused warning
+
+# -----------------------------------------------------------------------------
+# InitialIze Un-cached Vars, Avoid Unused Warning
# linux only, not cached
set(WITH_BINRELOC OFF)
@@ -1043,6 +1028,7 @@ if(WITH_CPU_SIMD)
endif()
endif()
+
# ----------------------------------------------------------------------------
# Main Platform Checks
#
@@ -1058,8 +1044,9 @@ elseif(APPLE)
include(platform_apple)
endif()
-#-----------------------------------------------------------------------------
-# Common.
+
+# -----------------------------------------------------------------------------
+# Common Checks for Compatible Options
if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
@@ -1067,13 +1054,15 @@ endif()
if(WITH_CYCLES)
if(NOT WITH_OPENIMAGEIO)
- message(FATAL_ERROR
+ message(
+ FATAL_ERROR
"Cycles requires WITH_OPENIMAGEIO, the library may not have been found. "
"Configure OIIO or disable WITH_CYCLES"
)
endif()
if(NOT WITH_BOOST)
- message(FATAL_ERROR
+ message(
+ FATAL_ERROR
"Cycles requires WITH_BOOST, the library may not have been found. "
"Configure BOOST or disable WITH_CYCLES"
)
@@ -1081,7 +1070,8 @@ if(WITH_CYCLES)
if(WITH_CYCLES_OSL)
if(NOT WITH_LLVM)
- message(FATAL_ERROR
+ message(
+ FATAL_ERROR
"Cycles OSL requires WITH_LLVM, the library may not have been found. "
"Configure LLVM or disable WITH_CYCLES_OSL"
)
@@ -1091,7 +1081,8 @@ endif()
if(WITH_INTERNATIONAL)
if(NOT WITH_BOOST)
- message(FATAL_ERROR
+ message(
+ FATAL_ERROR
"Internationalization requires WITH_BOOST, the library may not have been found. "
"Configure BOOST or disable WITH_INTERNATIONAL"
)
@@ -1106,7 +1097,7 @@ if(WITH_CPU_SIMD)
if(SUPPORT_NEON_BUILD)
# Neon
if(SSE2NEON_FOUND)
- blender_include_dirs_sys("${SSE2NEON_INCLUDE_DIRS}")
+ include_directories(SYSTEM "${SSE2NEON_INCLUDE_DIRS}")
add_definitions(-DWITH_SSE2NEON)
endif()
else()
@@ -1192,7 +1183,8 @@ if(WITH_OPENVDB)
list(APPEND OPENVDB_INCLUDE_DIRS
${BOOST_INCLUDE_DIR}
${TBB_INCLUDE_DIRS}
- ${OPENEXR_INCLUDE_DIRS})
+ ${OPENEXR_INCLUDE_DIRS}
+ )
list(APPEND OPENVDB_LIBRARIES ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
@@ -1204,145 +1196,19 @@ if(WITH_OPENVDB)
list(APPEND OPENVDB_LIBRARIES ${BOOST_LIBRARIES} ${TBB_LIBRARIES})
endif()
-#-----------------------------------------------------------------------------
-# Configure OpenGL.
-find_package(OpenGL)
-blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
+# -----------------------------------------------------------------------------
+# Configure OpenGL
if(WITH_OPENGL)
add_definitions(-DWITH_OPENGL)
endif()
-if(WITH_SYSTEM_GLES)
- find_package_wrapper(OpenGLES)
-endif()
-
-if(WITH_GL_PROFILE_ES20)
- if(WITH_SYSTEM_GLES)
- if(NOT OPENGLES_LIBRARY)
- message(FATAL_ERROR
- "Unable to find OpenGL ES libraries. "
- "Install them or disable WITH_SYSTEM_GLES."
- )
- endif()
-
- list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}")
-
- else()
- set(OPENGLES_LIBRARY "" CACHE FILEPATH "OpenGL ES 2.0 library file")
- mark_as_advanced(OPENGLES_LIBRARY)
-
- list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}")
-
- if(NOT OPENGLES_LIBRARY)
- message(FATAL_ERROR
- "To compile WITH_GL_EGL you need to set OPENGLES_LIBRARY "
- "to the file path of an OpenGL ES 2.0 library."
- )
- endif()
-
- endif()
-
- if(WIN32)
- # Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES
-
- set(OPENGLES_DLL "" CACHE FILEPATH "OpenGL ES 2.0 redistributable DLL file")
- mark_as_advanced(OPENGLES_DLL)
-
- if(NOT OPENGLES_DLL)
- message(FATAL_ERROR
- "To compile WITH_GL_PROFILE_ES20 you need to set OPENGLES_DLL to the file "
- "path of an OpenGL ES 2.0 runtime dynamic link library (DLL)."
- )
- endif()
-
- if(WITH_GL_ANGLE)
- list(APPEND GL_DEFINITIONS -DWITH_ANGLE)
-
- set(D3DCOMPILER_DLL "" CACHE FILEPATH "Direct3D Compiler redistributable DLL file (needed by ANGLE)")
-
- get_filename_component(D3DCOMPILER_FILENAME "${D3DCOMPILER_DLL}" NAME)
- list(APPEND GL_DEFINITIONS "-DD3DCOMPILER=\"\\\"${D3DCOMPILER_FILENAME}\\\"\"")
-
- mark_as_advanced(D3DCOMPILER_DLL)
-
- if(D3DCOMPILER_DLL STREQUAL "")
- message(FATAL_ERROR
- "To compile WITH_GL_ANGLE you need to set D3DCOMPILER_DLL to the file "
- "path of a copy of the DirectX redistributable DLL file: D3DCompiler_46.dll"
- )
- endif()
-
- endif()
-
- endif()
-
-else()
- if(OpenGL_GL_PREFERENCE STREQUAL "LEGACY" AND OPENGL_gl_LIBRARY)
- list(APPEND BLENDER_GL_LIBRARIES ${OPENGL_gl_LIBRARY})
- else()
- list(APPEND BLENDER_GL_LIBRARIES ${OPENGL_opengl_LIBRARY} ${OPENGL_glx_LIBRARY})
- endif()
-endif()
-
-if(WITH_GL_EGL)
- find_package(OpenGL REQUIRED EGL)
- list(APPEND BLENDER_GL_LIBRARIES OpenGL::EGL)
-
- list(APPEND GL_DEFINITIONS -DWITH_GL_EGL -DGLEW_EGL -DGLEW_INC_EGL)
-
- if(WITH_SYSTEM_GLES)
- if(NOT OPENGLES_EGL_LIBRARY)
- message(FATAL_ERROR
- "Unable to find OpenGL ES libraries. "
- "Install them or disable WITH_SYSTEM_GLES."
- )
- endif()
-
- list(APPEND BLENDER_GL_LIBRARIES ${OPENGLES_EGL_LIBRARY})
-
- else()
- set(OPENGLES_EGL_LIBRARY "" CACHE FILEPATH "EGL library file")
- mark_as_advanced(OPENGLES_EGL_LIBRARY)
-
- list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}" "${OPENGLES_EGL_LIBRARY}")
-
- if(NOT OPENGLES_EGL_LIBRARY)
- message(FATAL_ERROR
- "To compile WITH_GL_EGL you need to set OPENGLES_EGL_LIBRARY "
- "to the file path of an EGL library."
- )
- endif()
-
- endif()
-
- if(WIN32)
- # Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES
-
- set(OPENGLES_EGL_DLL "" CACHE FILEPATH "EGL redistributable DLL file")
- mark_as_advanced(OPENGLES_EGL_DLL)
-
- if(NOT OPENGLES_EGL_DLL)
- message(FATAL_ERROR
- "To compile WITH_GL_EGL you need to set OPENGLES_EGL_DLL "
- "to the file path of an EGL runtime dynamic link library (DLL)."
- )
- endif()
-
- endif()
-
-endif()
-if(WITH_GL_PROFILE_ES20)
- list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_ES20)
-else()
- list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
-endif()
+# -----------------------------------------------------------------------------
+# Configure Metal
-#-----------------------------------------------------------------------------
-# Configure Metal.
-if (WITH_METAL_BACKEND)
+if(WITH_METAL_BACKEND)
add_definitions(-DWITH_METAL_BACKEND)
# No need to add frameworks here, all the ones we need for Metal and
@@ -1350,8 +1216,10 @@ if (WITH_METAL_BACKEND)
# build_files/cmake/platform/platform_apple.cmake
endif()
-#-----------------------------------------------------------------------------
-# Configure OpenMP.
+
+# -----------------------------------------------------------------------------
+# Configure OpenMP
+
if(WITH_OPENMP)
if(NOT OPENMP_CUSTOM)
find_package(OpenMP)
@@ -1383,67 +1251,8 @@ if(WITH_OPENMP)
)
endif()
-#-----------------------------------------------------------------------------
-# Configure GLEW
-
-if(WITH_SYSTEM_GLEW)
- find_package(GLEW)
-
- # Note: There is an assumption here that the system GLEW is not a static library.
-
- if(NOT GLEW_FOUND)
- message(FATAL_ERROR "GLEW is required to build Blender. Install it or disable WITH_SYSTEM_GLEW.")
- endif()
-
- set(GLEW_INCLUDE_PATH "${GLEW_INCLUDE_DIR}")
- set(BLENDER_GLEW_LIBRARIES ${GLEW_LIBRARY})
-else()
- if(WITH_GLEW_ES)
- set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include")
-
- list(APPEND GL_DEFINITIONS -DGLEW_STATIC -DWITH_GLEW_ES)
-
- # These definitions remove APIs from glew.h, making GLEW smaller, and catching unguarded API usage
- if(WITH_GL_PROFILE_ES20)
- list(APPEND GL_DEFINITIONS -DGLEW_ES_ONLY)
- else()
- # No ES functions are needed
- list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
- endif()
-
- if(WITH_GL_PROFILE_ES20)
- if(WITH_GL_EGL)
- list(APPEND GL_DEFINITIONS -DGLEW_USE_LIB_ES20)
- endif()
-
- # ToDo: This is an experiment to eliminate ES 1 symbols,
- # GLEW doesn't really properly provide this level of control
- # (for example, without modification it eliminates too many symbols)
- # so there are lots of modifications to GLEW to make this work,
- # and no attempt to make it work beyond Blender at this point.
- list(APPEND GL_DEFINITIONS -DGL_ES_VERSION_1_0=0 -DGL_ES_VERSION_CL_1_1=0 -DGL_ES_VERSION_CM_1_1=0)
- endif()
-
- set(BLENDER_GLEW_LIBRARIES extern_glew_es bf_intern_glew_mx)
-
- else()
- set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
-
- list(APPEND GL_DEFINITIONS -DGLEW_STATIC)
-
- # This won't affect the non-experimental glew library,
- # but is used for conditional compilation elsewhere.
- list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
-
- set(BLENDER_GLEW_LIBRARIES extern_glew)
-
- endif()
-
-endif()
-
-list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Configure Bullet
if(WITH_BULLET AND WITH_SYSTEM_BULLET)
@@ -1457,15 +1266,21 @@ else()
# set(BULLET_LIBRARIES "")
endif()
-#-----------------------------------------------------------------------------
-# Configure Python.
+
+# -----------------------------------------------------------------------------
+# Configure Python
if(WITH_PYTHON_MODULE)
- add_definitions(-DPy_ENABLE_SHARED)
+ # Not currently supported due to different required Python link flags.
+ if(WITH_GTESTS)
+ message(STATUS "GTests not compatible with Python module, disabling WITH_GTESTS")
+ set(WITH_GTESTS OFF)
+ endif()
endif()
-#-----------------------------------------------------------------------------
-# Configure GLog/GFlags
+
+# -----------------------------------------------------------------------------
+# Configure `GLog/GFlags`
if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
if(WITH_SYSTEM_GFLAGS)
@@ -1473,7 +1288,7 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
if(NOT GFLAGS_FOUND)
message(FATAL_ERROR "System wide Gflags is requested but was not found")
endif()
- # FindGflags does not define this, and we are not even sure what to use here.
+ # `FindGflags` does not define this, and we are not even sure what to use here.
set(GFLAGS_DEFINES)
else()
set(GFLAGS_DEFINES
@@ -1491,7 +1306,7 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
if(NOT GLOG_FOUND)
message(FATAL_ERROR "System wide Glog is requested but was not found")
endif()
- # FindGlog does not define this, and we are not even sure what to use here.
+ # `FindGlog` does not define this, and we are not even sure what to use here.
set(GLOG_DEFINES)
else()
set(GLOG_DEFINES
@@ -1506,9 +1321,13 @@ if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
endif()
endif()
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
+# Ninja Job Limiting
+
# Extra limits to number of jobs running in parallel for some kind os tasks.
# Only supported by Ninja build system currently.
+
if("${CMAKE_GENERATOR}" MATCHES "Ninja" AND WITH_NINJA_POOL_JOBS)
if(NOT NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS AND
NOT NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS AND
@@ -1520,7 +1339,8 @@ if("${CMAKE_GENERATOR}" MATCHES "Ninja" AND WITH_NINJA_POOL_JOBS)
# Note: this gives mem in MB.
cmake_host_system_information(RESULT _TOT_MEM QUERY TOTAL_PHYSICAL_MEMORY)
- # Heuristics... the more cores we have, the more free mem we have to keep for the non-heavy tasks too.
+ # Heuristics: the more cores we have, the more free memory we have to keep
+ # for the non-heavy tasks too.
if(${_TOT_MEM} LESS 8000 AND ${_NUM_CORES} GREATER 2)
set(_compile_heavy_jobs "1")
elseif(${_TOT_MEM} LESS 16000 AND ${_NUM_CORES} GREATER 4)
@@ -1540,7 +1360,8 @@ if("${CMAKE_GENERATOR}" MATCHES "Ninja" AND WITH_NINJA_POOL_JOBS)
mark_as_advanced(NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
set(_compile_heavy_jobs)
- # Only set regular compile jobs if we set heavy jobs, otherwise default (using all cores) if fine.
+ # Only set regular compile jobs if we set heavy jobs,
+ # otherwise default (using all cores) if fine.
if(NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
math(EXPR _compile_jobs "${_NUM_CORES} - 1")
else()
@@ -1551,8 +1372,8 @@ if("${CMAKE_GENERATOR}" MATCHES "Ninja" AND WITH_NINJA_POOL_JOBS)
mark_as_advanced(NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS)
set(_compile_jobs)
- # In practice, even when there is RAM available, this proves to be quicker than running in parallel
- # (due to slow disks accesses).
+ # In practice, even when there is RAM available,
+ # this proves to be quicker than running in parallel (due to slow disks accesses).
set(NINJA_MAX_NUM_PARALLEL_LINK_JOBS "1" CACHE STRING
"Define the maximum number of concurrent link jobs, for ninja build system." FORCE)
mark_as_advanced(NINJA_MAX_NUM_PARALLEL_LINK_JOBS)
@@ -1576,8 +1397,9 @@ if("${CMAKE_GENERATOR}" MATCHES "Ninja" AND WITH_NINJA_POOL_JOBS)
endif()
endif()
-#-----------------------------------------------------------------------------
-# Extra compile flags
+
+# -----------------------------------------------------------------------------
+# Extra Compile Flags
if(CMAKE_COMPILER_IS_GNUCC)
@@ -1667,7 +1489,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()
- #----------------------
+ # ---------------------
# Suppress Strict Flags
#
# Exclude the following warnings from this list:
@@ -1733,7 +1555,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_MACROS -Wunused-macros)
# ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS -Wunused-macros)
- #----------------------
+ # ---------------------
# Suppress Strict Flags
# flags to undo strict flags
@@ -1824,7 +1646,8 @@ endif()
# be most problematic.
if(WITH_PYTHON)
if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
- message(FATAL_ERROR
+ message(
+ FATAL_ERROR
"Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
"Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
"to a valid python include path. Containing "
@@ -1832,8 +1655,8 @@ if(WITH_PYTHON)
)
endif()
- if(WIN32 OR APPLE)
- # Windows and macOS have this bundled with Python libraries.
+ if(WIN32)
+ # Always use numpy bundled in precompiled libs.
elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR WITH_PYTHON_NUMPY)
if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
find_python_package(numpy "core/include")
@@ -1841,13 +1664,13 @@ if(WITH_PYTHON)
endif()
if(WIN32 OR APPLE)
- # pass, we have this in lib/python/site-packages
+ # Always copy from precompiled libs.
elseif(WITH_PYTHON_INSTALL_REQUESTS)
find_python_package(requests "")
endif()
if(WIN32 OR APPLE)
- # pass, we have this in lib/python/site-packages
+ # Always copy from precompiled libs.
elseif(WITH_PYTHON_INSTALL_ZSTANDARD)
find_python_package(zstandard "")
endif()
@@ -1893,9 +1716,11 @@ if(WITH_COMPILER_SHORT_FILE_MACRO)
if(XCODE AND ${XCODE_VERSION} VERSION_LESS 12.0)
# Developers may have say LLVM Clang-10.0.1 toolchain (which supports the flag)
# with Xcode-11 (the Clang of which doesn't support the flag).
- message(WARNING
+ message(
+ WARNING
"-fmacro-prefix-map flag is NOT supported by Clang shipped with Xcode-${XCODE_VERSION}."
- " Some Xcode functionality in Product menu may not work. Disabling WITH_COMPILER_SHORT_FILE_MACRO."
+ " Some Xcode functionality in Product menu may not work. "
+ "Disabling WITH_COMPILER_SHORT_FILE_MACRO."
)
set(WITH_COMPILER_SHORT_FILE_MACRO OFF)
endif()
@@ -1911,7 +1736,8 @@ if(WITH_COMPILER_SHORT_FILE_MACRO)
unset(_bin_dir)
endif()
else()
- message(WARNING
+ message(
+ WARNING
"-fmacro-prefix-map flag is NOT supported by C/C++ compiler."
" Disabling WITH_COMPILER_SHORT_FILE_MACRO."
)
@@ -1941,7 +1767,8 @@ mark_as_advanced(
LLVM_VERSION
)
-#-------------------------------------------------------------------------------
+
+# -------------------------------------------------------------------------------
# Global Defines
# better not set includes here but this debugging option is off by default.
@@ -1957,8 +1784,9 @@ endif()
# message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
# message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
-#-----------------------------------------------------------------------------
-# Libraries
+
+# -----------------------------------------------------------------------------
+# Add Sub-Directories
if(WITH_BLENDER)
add_subdirectory(intern)
@@ -1968,7 +1796,6 @@ if(WITH_BLENDER)
# internal and external library information first, for test linking
add_subdirectory(source)
elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
- add_subdirectory(intern/glew-mx)
add_subdirectory(intern/guardedalloc)
add_subdirectory(intern/libc_compat)
add_subdirectory(intern/sky)
@@ -1986,38 +1813,43 @@ elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
if(WITH_HIP_DYNLOAD)
add_subdirectory(extern/hipew)
endif()
- if(NOT WITH_SYSTEM_GLEW)
- add_subdirectory(extern/glew)
- endif()
endif()
-#-----------------------------------------------------------------------------
-# Testing
+
+# -----------------------------------------------------------------------------
+# Add Testing Directory
+
add_subdirectory(tests)
-#-----------------------------------------------------------------------------
-# Blender Application
+
+# -----------------------------------------------------------------------------
+# Add Blender Application
+
if(WITH_BLENDER)
add_subdirectory(source/creator)
endif()
-#-----------------------------------------------------------------------------
-# Define 'heavy' submodules (for Ninja builder when using pools).
+# -----------------------------------------------------------------------------
+# Define 'heavy' sub-modules (for Ninja builder when using pools)
setup_heavy_lib_pool()
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# CPack for generating packages
+
include(build_files/cmake/packaging.cmake)
-#-----------------------------------------------------------------------------
-# Use dynamic loading for OpenMP
+
+# -----------------------------------------------------------------------------
+# Use Dynamic Loading for OpenMP
+
if(WITH_BLENDER)
openmp_delayload(blender)
endif()
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Print Final Configuration
if(FIRST_RUN)
@@ -2081,8 +1913,6 @@ if(FIRST_RUN)
info_cfg_option(WITH_INSTALL_PORTABLE)
info_cfg_option(WITH_MEM_JEMALLOC)
info_cfg_option(WITH_MEM_VALGRIND)
- info_cfg_option(WITH_SYSTEM_GLEW)
- info_cfg_option(WITH_X11_ALPHA)
info_cfg_option(WITH_X11_XF86VMODE)
info_cfg_option(WITH_X11_XFIXES)
info_cfg_option(WITH_X11_XINPUT)
@@ -2115,9 +1945,6 @@ if(FIRST_RUN)
info_cfg_option(WITH_LZO)
info_cfg_text("Python:")
- if(APPLE)
- info_cfg_option(WITH_PYTHON_FRAMEWORK)
- endif()
info_cfg_option(WITH_PYTHON_INSTALL)
info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
info_cfg_option(WITH_PYTHON_INSTALL_ZSTANDARD)
@@ -2129,14 +1956,6 @@ if(FIRST_RUN)
info_cfg_option(WITH_MOD_OCEANSIM)
info_cfg_option(WITH_MOD_REMESH)
- info_cfg_text("OpenGL:")
- if(WIN32)
- info_cfg_option(WITH_GL_ANGLE)
- endif()
- info_cfg_option(WITH_GL_EGL)
- info_cfg_option(WITH_GL_PROFILE_ES20)
- info_cfg_option(WITH_GLEW_ES)
-
info_cfg_text("")
message("${_config_msg}")