Add Chromium-only Blender WebEngine parity work

This commit is contained in:
mes123456
2026-08-12 04:47:48 -04:00
commit 9fd26010f6
18225 changed files with 11622124 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2016 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Alembic library
# Find the native Alembic includes and libraries
# This module defines
# ALEMBIC_INCLUDE_DIRS, where to find Alembic headers, Set when
# ALEMBIC_INCLUDE_DIR is found.
# ALEMBIC_LIBRARIES, libraries to link against to use Alembic.
# ALEMBIC_ROOT_DIR, The base directory to search for Alembic.
# This can also be an environment variable.
# ALEMBIC_FOUND, If false, do not try to use Alembic.
#
# If `ALEMBIC_ROOT_DIR` was defined in the environment, use it.
if(DEFINED ALEMBIC_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{ALEMBIC_ROOT_DIR})
set(ALEMBIC_ROOT_DIR $ENV{ALEMBIC_ROOT_DIR})
else()
set(ALEMBIC_ROOT_DIR "")
endif()
set(_alembic_SEARCH_DIRS
${ALEMBIC_ROOT_DIR}
/opt/lib/alembic
)
find_path(ALEMBIC_INCLUDE_DIR
NAMES
Alembic/Abc/All.h
HINTS
${_alembic_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(ALEMBIC_LIBRARY
NAMES
Alembic
HINTS
${_alembic_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib lib/static
)
# handle the QUIETLY and REQUIRED arguments and set ALEMBIC_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Alembic DEFAULT_MSG ALEMBIC_LIBRARY ALEMBIC_INCLUDE_DIR)
if(ALEMBIC_FOUND)
set(ALEMBIC_LIBRARIES ${ALEMBIC_LIBRARY})
set(ALEMBIC_INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR})
endif()
mark_as_advanced(
ALEMBIC_INCLUDE_DIR
ALEMBIC_LIBRARY
)
unset(_alembic_SEARCH_DIRS)

View File

@@ -0,0 +1,115 @@
# SPDX-FileCopyrightText: 2014 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Try to find audaspace
# Once done, this will define
#
# AUDASPACE_FOUND - system has audaspace
# AUDASPACE_INCLUDE_DIRS - the audaspace include directories
# AUDASPACE_LIBRARIES - link these to use audaspace
# AUDASPACE_C_FOUND - system has audaspace's C binding
# AUDASPACE_C_INCLUDE_DIRS - the audaspace's C binding include directories
# AUDASPACE_C_LIBRARIES - link these to use audaspace's C binding
# AUDASPACE_PY_FOUND - system has audaspace's python binding
# AUDASPACE_PY_INCLUDE_DIRS - the audaspace's python binding include directories
# AUDASPACE_PY_LIBRARIES - link these to use audaspace's python binding
if(NOT AUDASPACE_ROOT_DIR AND NOT $ENV{AUDASPACE_ROOT_DIR} STREQUAL "")
set(AUDASPACE_ROOT_DIR $ENV{AUDASPACE_ROOT_DIR})
endif()
set(_audaspace_SEARCH_DIRS
${AUDASPACE_ROOT_DIR}
)
# Use pkg-config to get hints about paths
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(AUDASPACE_PKGCONF audaspace)
endif()
# Include dir
find_path(AUDASPACE_INCLUDE_DIR
NAMES ISound.h
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES include/audaspace
)
# Library
find_library(AUDASPACE_LIBRARY
NAMES audaspace
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
PATH_SUFFIXES lib lib64
)
# Include dir
find_path(AUDASPACE_C_INCLUDE_DIR
NAMES AUD_Sound.h
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES include/audaspace
)
# Library
find_library(AUDASPACE_C_LIBRARY
NAMES audaspace-c
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
PATH_SUFFIXES lib lib64
)
# Include dir
find_path(AUDASPACE_PY_INCLUDE_DIR
NAMES python/PyAPI.h
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES include/audaspace
)
# Library
find_library(AUDASPACE_PY_LIBRARY
NAMES audaspace-py
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
PATH_SUFFIXES lib lib64
)
find_package(PackageHandleStandardArgs)
find_package_handle_standard_args(Audaspace DEFAULT_MSG AUDASPACE_LIBRARY AUDASPACE_INCLUDE_DIR)
find_package_handle_standard_args(Audaspace_C DEFAULT_MSG AUDASPACE_C_LIBRARY AUDASPACE_C_INCLUDE_DIR)
find_package_handle_standard_args(Audaspace_Py DEFAULT_MSG AUDASPACE_PY_LIBRARY AUDASPACE_PY_INCLUDE_DIR)
if(AUDASPACE_FOUND)
set(AUDASPACE_LIBRARIES ${AUDASPACE_LIBRARY})
set(AUDASPACE_INCLUDE_DIRS ${AUDASPACE_INCLUDE_DIR})
endif()
if(AUDASPACE_C_FOUND)
set(AUDASPACE_C_LIBRARIES ${AUDASPACE_C_LIBRARY})
set(AUDASPACE_C_INCLUDE_DIRS ${AUDASPACE_C_INCLUDE_DIR})
endif()
if(AUDASPACE_PY_FOUND)
set(AUDASPACE_PY_LIBRARIES ${AUDASPACE_PY_LIBRARY})
set(AUDASPACE_PY_INCLUDE_DIRS ${AUDASPACE_PY_INCLUDE_DIR})
endif()
mark_as_advanced(
AUDASPACE_LIBRARY
AUDASPACE_LIBRARIES
AUDASPACE_INCLUDE_DIR
AUDASPACE_INCLUDE_DIRS
AUDASPACE_C_LIBRARY
AUDASPACE_C_LIBRARIES
AUDASPACE_C_INCLUDE_DIR
AUDASPACE_C_INCLUDE_DIRS
AUDASPACE_PY_LIBRARY
AUDASPACE_PY_LIBRARIES
AUDASPACE_PY_INCLUDE_DIR
AUDASPACE_PY_INCLUDE_DIRS
)
unset(_audaspace_SEARCH_DIRS)

View File

@@ -0,0 +1,68 @@
# SPDX-FileCopyrightText: 2018 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Blosc library
# Find the native Blosc includes and library
# This module defines
# BLOSC_INCLUDE_DIRS, where to find blosc.h, Set when
# Blosc is found.
# BLOSC_LIBRARIES, libraries to link against to use Blosc.
# BLOSC_ROOT_DIR, The base directory to search for Blosc.
# This can also be an environment variable.
# BLOSC_FOUND, If false, do not try to use Blosc.
#
# also defined, but not for general use are
# BLOSC_LIBRARY, where to find the Blosc library.
# If `BLOSC_ROOT_DIR` was defined in the environment, use it.
if(DEFINED BLOSC_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{BLOSC_ROOT_DIR})
set(BLOSC_ROOT_DIR $ENV{BLOSC_ROOT_DIR})
else()
set(BLOSC_ROOT_DIR "")
endif()
set(_blosc_SEARCH_DIRS
${BLOSC_ROOT_DIR}
/opt/lib/blosc
)
find_path(BLOSC_INCLUDE_DIR
NAMES
blosc.h
HINTS
${_blosc_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(BLOSC_LIBRARY
NAMES
blosc
HINTS
${_blosc_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set BLOSC_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Blosc DEFAULT_MSG
BLOSC_LIBRARY BLOSC_INCLUDE_DIR)
if(BLOSC_FOUND)
set(BLOSC_LIBRARIES ${BLOSC_LIBRARY})
set(BLOSC_INCLUDE_DIRS ${BLOSC_INCLUDE_DIR})
else()
set(BLOSC_FOUND FALSE)
endif()
mark_as_advanced(
BLOSC_INCLUDE_DIR
BLOSC_LIBRARY
)
unset(_blosc_SEARCH_DIRS)

View File

@@ -0,0 +1,84 @@
# SPDX-FileCopyrightText: 2022 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Brotli library (compression for freetype/woff2).
# This module defines
# BROTLI_INCLUDE_DIRS, where to find Brotli headers, Set when
# BROTLI_INCLUDE_DIR is found.
# BROTLI_LIBRARIES, libraries to link against to use Brotli.
# BROTLI_ROOT_DIR, The base directory to search for Brotli.
# This can also be an environment variable.
# BROTLI_FOUND, If false, do not try to use Brotli.
#
# If `BROTLI_ROOT_DIR` was defined in the environment, use it.
if(DEFINED BROTLI_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{BROTLI_ROOT_DIR})
set(BROTLI_ROOT_DIR $ENV{BROTLI_ROOT_DIR})
else()
set(BROTLI_ROOT_DIR "")
endif()
set(_brotli_SEARCH_DIRS
${BROTLI_ROOT_DIR}
)
find_path(BROTLI_INCLUDE_DIR
NAMES
brotli/decode.h
HINTS
${_brotli_SEARCH_DIRS}
PATH_SUFFIXES
include
DOC "Brotli header files"
)
find_library(BROTLI_LIBRARY_COMMON
NAMES
# Some builds use a special `-static` postfix in their static libraries names.
brotlicommon-static
brotlicommon
HINTS
${_brotli_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib lib/static
DOC "Brotli static common library"
)
find_library(BROTLI_LIBRARY_DEC
NAMES
# Some builds use a special `-static` postfix in their static libraries names.
brotlidec-static
brotlidec
HINTS
${_brotli_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib lib/static
DOC "Brotli static decode library"
)
if((NOT BROTLI_LIBRARY_COMMON) OR (NOT BROTLI_LIBRARY_DEC))
set(BROTLI_FOUND FALSE)
else()
# handle the QUIETLY and REQUIRED arguments and set BROTLI_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Brotli DEFAULT_MSG BROTLI_LIBRARY_COMMON BROTLI_LIBRARY_DEC BROTLI_INCLUDE_DIR)
if(BROTLI_FOUND)
get_filename_component(BROTLI_LIBRARY_DIR ${BROTLI_LIBRARY_COMMON} DIRECTORY)
set(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR})
set(BROTLI_LIBRARIES ${BROTLI_LIBRARY_DEC} ${BROTLI_LIBRARY_COMMON})
endif()
endif()
mark_as_advanced(
BROTLI_INCLUDE_DIR
BROTLI_LIBRARY_COMMON
BROTLI_LIBRARY_DEC
BROTLI_LIBRARY_DIR
)
unset(_brotli_SEARCH_DIRS)

View File

@@ -0,0 +1,130 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Clang library
# Find the native Clang includes and library
# This module defines
# CLANG_INCLUDE_DIRS, where to find AST/AST.h, Set when
# CLANG_INCLUDE_DIR is found.
# CLANG_LIBRARIES, libraries to link against to use Clang.
# CLANG_ROOT_DIR, The base directory to search for Clang.
# This can also be an environment variable.
# CLANG_FOUND, If false, do not try to use Clang.
# If `CLANG_ROOT_DIR` was defined in the environment, use it.
if(DEFINED CLANG_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{CLANG_ROOT_DIR})
set(CLANG_ROOT_DIR $ENV{CLANG_ROOT_DIR})
else()
set(CLANG_ROOT_DIR "")
endif()
if(NOT LLVM_ROOT_DIR)
if(DEFINED LLVM_VERSION)
message(STATUS "Running llvm-config-${LLVM_VERSION}")
find_program(LLVM_CONFIG llvm-config-${LLVM_VERSION})
endif()
if(NOT LLVM_CONFIG)
find_program(LLVM_CONFIG llvm-config)
endif()
execute_process(COMMAND ${LLVM_CONFIG} --prefix
OUTPUT_VARIABLE LLVM_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_ROOT_DIR ${LLVM_ROOT_DIR} CACHE PATH "Path to the LLVM installation")
endif()
set(_clang_SEARCH_DIRS
${CLANG_ROOT_DIR}
${LLVM_ROOT_DIR}
/opt/lib/clang
)
find_path(CLANG_INCLUDE_DIR
NAMES
AST/AST.h
HINTS
${_clang_SEARCH_DIRS}
PATH_SUFFIXES
include
include/clang
)
set(_clang_FIND_COMPONENTS
clangDependencyScanning
clangDynamicASTMatchers
clangFrontendTool
clangStaticAnalyzerFrontend
clangHandleCXX
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangToolingASTDiff
clangToolingRefactoring
clangToolingSyntax
clangARCMigrate
clangCodeGen
clangCrossTU
clangIndex
clangTooling
clangFormat
clangToolingInclusions
clangRewriteFrontend
clangFrontend
clangSerialization
clangDriver
clangToolingCore
clangParse
clangRewrite
clangSema
clangEdit
clangAnalysis
clangASTMatchers
clangAST
clangLex
clangBasic
)
set(_clang_LIBRARIES "")
foreach(COMPONENT ${_clang_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
find_library(CLANG_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${_clang_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
if(CLANG_${UPPERCOMPONENT}_LIBRARY)
list(APPEND _clang_LIBRARIES "${CLANG_${UPPERCOMPONENT}_LIBRARY}")
endif()
endforeach()
# Handle the QUIETLY and REQUIRED arguments and set CLANG_FOUND to TRUE if
# all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Clang DEFAULT_MSG
_clang_LIBRARIES CLANG_INCLUDE_DIR)
if(CLANG_FOUND)
set(CLANG_LIBRARIES ${_clang_LIBRARIES})
set(CLANG_INCLUDE_DIRS ${CLANG_INCLUDE_DIR})
endif()
mark_as_advanced(
CLANG_INCLUDE_DIR
)
foreach(COMPONENT ${_clang_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
mark_as_advanced(CLANG_${UPPERCOMPONENT}_LIBRARY)
endforeach()
unset(_clang_SEARCH_DIRS)
unset(_clang_FIND_COMPONENTS)
unset(_clang_LIBRARIES)

View File

@@ -0,0 +1,108 @@
# SPDX-FileCopyrightText: 2020 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find clang-tidy executable
#
# Find the native clang-tidy executable
#
# This module defines
# CLANG_TIDY_EXECUTABLE, the full path to clang-tidy executable
#
# CLANG_TIDY_VERSION, the full version of the clang-tidy in the
# major,minor.patch format
#
# CLANG_TIDY_VERSION_MAJOR,
# CLANG_TIDY_VERSION_MINOR,
# CLANG_TIDY_VERSION_PATCH, individual components of the clang-tidy version.
#
# CLANG_TIDY_FOUND, If false, do not try to use clang-tidy.
# If `CLANG_TIDY_ROOT_DIR` was defined in the environment, use it.
if(DEFINED CLANG_TIDY_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{CLANG_TIDY_ROOT_DIR})
set(CLANG_TIDY_ROOT_DIR $ENV{CLANG_TIDY_ROOT_DIR})
else()
set(CLANG_TIDY_ROOT_DIR "")
endif()
set(_clang_tidy_SEARCH_DIRS
${CLANG_TIDY_ROOT_DIR}
/usr/local/bin
)
# TODO(sergey): Find more reliable way of finding the latest clang-tidy.
find_program(CLANG_TIDY_EXECUTABLE
NAMES
clang-tidy-12
clang-tidy-11
clang-tidy-10
clang-tidy-9
clang-tidy-8
clang-tidy-7
clang-tidy
HINTS
${_clang_tidy_SEARCH_DIRS}
)
if(CLANG_TIDY_EXECUTABLE AND NOT EXISTS "${CLANG_TIDY_EXECUTABLE}")
message(WARNING "Cached or directly specified Clang-Tidy executable does not exist.")
set(CLANG_TIDY_FOUND FALSE)
elseif(CLANG_TIDY_EXECUTABLE)
# Mark clang-tidy as found.
set(CLANG_TIDY_FOUND TRUE)
# Setup fallback values.
set(CLANG_TIDY_VERSION_MAJOR 0)
set(CLANG_TIDY_VERSION_MINOR 0)
set(CLANG_TIDY_VERSION_PATCH 0)
# Get version from the output.
#
# NOTE: Don't use name of the executable file since that only includes a
# major version. Also, even the major version might be missing in the
# executable name.
execute_process(COMMAND ${CLANG_TIDY_EXECUTABLE} -version
OUTPUT_VARIABLE CLANG_TIDY_VERSION_RAW
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Parse parts.
if(CLANG_TIDY_VERSION_RAW MATCHES "LLVM version .*")
# Strip the LLVM prefix and get list of individual version components.
string(REGEX REPLACE
".*LLVM version ([.0-9]+).*" "\\1"
CLANG_SEMANTIC_VERSION "${CLANG_TIDY_VERSION_RAW}")
string(REPLACE "." ";" CLANG_VERSION_PARTS "${CLANG_SEMANTIC_VERSION}")
list(LENGTH CLANG_VERSION_PARTS NUM_CLANG_TIDY_VERSION_PARTS)
# Extract components into corresponding variables.
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 0)
list(GET CLANG_VERSION_PARTS 0 CLANG_TIDY_VERSION_MAJOR)
endif()
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 1)
list(GET CLANG_VERSION_PARTS 1 CLANG_TIDY_VERSION_MINOR)
endif()
if(NUM_CLANG_TIDY_VERSION_PARTS GREATER 2)
list(GET CLANG_VERSION_PARTS 2 CLANG_TIDY_VERSION_PATCH)
endif()
# Unset temp variables.
unset(NUM_CLANG_TIDY_VERSION_PARTS)
unset(CLANG_SEMANTIC_VERSION)
unset(CLANG_VERSION_PARTS)
endif()
# Construct full semantic version.
set(CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION_MAJOR}.\
${CLANG_TIDY_VERSION_MINOR}.\
${CLANG_TIDY_VERSION_PATCH}")
unset(CLANG_TIDY_VERSION_RAW)
message(STATUS "Found clang-tidy ${CLANG_TIDY_EXECUTABLE} (${CLANG_TIDY_VERSION})")
else()
set(CLANG_TIDY_FOUND FALSE)
endif()
unset(_clang_tidy_SEARCH_DIRS)

View File

@@ -0,0 +1,136 @@
# SPDX-FileCopyrightText: 2018 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Embree library
# Find the native Embree includes and library
# This module defines
# EMBREE_INCLUDE_DIRS, where to find rtcore.h, Set when
# EMBREE_INCLUDE_DIR is found.
# EMBREE_LIBRARIES, libraries to link against to use Embree.
# EMBREE_ROOT_DIR, The base directory to search for Embree.
# This can also be an environment variable.
# EMBREE_FOUND, If false, do not try to use Embree.
# If `EMBREE_ROOT_DIR` was defined in the environment, use it.
if(DEFINED EMBREE_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{EMBREE_ROOT_DIR})
set(EMBREE_ROOT_DIR $ENV{EMBREE_ROOT_DIR})
else()
set(EMBREE_ROOT_DIR "")
endif()
set(_embree_SEARCH_DIRS
${EMBREE_ROOT_DIR}
/opt/lib/embree
)
find_path(EMBREE_INCLUDE_DIR
NAMES
embree4/rtcore.h
embree3/rtcore.h
HINTS
${_embree_SEARCH_DIRS}
PATH_SUFFIXES
include
)
if(EXISTS ${EMBREE_INCLUDE_DIR}/embree4/rtcore_config.h)
set(EMBREE_MAJOR_VERSION 4)
else()
set(EMBREE_MAJOR_VERSION 3)
endif()
if(EMBREE_INCLUDE_DIR)
file(READ ${EMBREE_INCLUDE_DIR}/embree${EMBREE_MAJOR_VERSION}/rtcore_config.h _embree_config_header)
if(_embree_config_header MATCHES "#define EMBREE_STATIC_LIB")
set(EMBREE_STATIC_LIB TRUE)
else()
set(EMBREE_STATIC_LIB FALSE)
endif()
if(_embree_config_header MATCHES "#define EMBREE_SYCL_SUPPORT")
set(EMBREE_SYCL_SUPPORT TRUE)
else()
set(EMBREE_SYCL_SUPPORT FALSE)
endif()
unset(_embree_config_header)
endif()
if(EMBREE_STATIC_LIB)
if((CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") OR (APPLE AND (CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")))
set(_embree_SIMD_COMPONENTS
embree_sse42
embree_avx
embree_avx2
)
endif()
if(EMBREE_SYCL_SUPPORT)
set(_embree_GPU_COMPONENTS
embree4_sycl
embree_rthwif
)
endif()
set(_embree_FIND_COMPONENTS
embree${EMBREE_MAJOR_VERSION}
${_embree_SIMD_COMPONENTS}
${_embree_GPU_COMPONENTS}
lexers
math
simd
sys
tasking
)
else()
set(_embree_FIND_COMPONENTS
embree${EMBREE_MAJOR_VERSION}
)
if(EMBREE_SYCL_SUPPORT)
list(APPEND _embree_FIND_COMPONENTS
embree4_sycl
)
endif()
endif()
set(_embree_LIBRARIES "")
foreach(COMPONENT ${_embree_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
find_library(EMBREE_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${_embree_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
list(APPEND _embree_LIBRARIES "${EMBREE_${UPPERCOMPONENT}_LIBRARY}")
endforeach()
# handle the QUIETLY and REQUIRED arguments and set EMBREE_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Embree DEFAULT_MSG
_embree_LIBRARIES EMBREE_INCLUDE_DIR)
if(EMBREE_FOUND)
set(EMBREE_LIBRARIES ${_embree_LIBRARIES})
set(EMBREE_INCLUDE_DIRS ${EMBREE_INCLUDE_DIR})
endif()
mark_as_advanced(
EMBREE_INCLUDE_DIR
EMBREE_MAJOR_VERSION
EMBREE_SYCL_SUPPORT
EMBREE_STATIC_LIB
)
foreach(COMPONENT ${_embree_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
mark_as_advanced(EMBREE_${UPPERCOMPONENT}_LIBRARY)
endforeach()
unset(_embree_SEARCH_DIRS)
unset(_embree_FIND_COMPONENTS)
unset(_embree_LIBRARIES)

View File

@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: 2022 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# This module defines
# EPOXY_INCLUDE_DIRS, where to find epoxy/gl.h
# EPOXY_LIBRARIES, where to find the epoxy library.
# EPOXY_ROOT_DIR, The base directory to search for epoxy.
# This can also be an environment variable.
# EPOXY_FOUND, If false, do not try to use epoxy.
# If `EPOXY_ROOT_DIR` was defined in the environment, use it.
if(DEFINED EPOXY_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{EPOXY_ROOT_DIR})
set(EPOXY_ROOT_DIR $ENV{EPOXY_ROOT_DIR})
else()
set(EPOXY_ROOT_DIR "")
endif()
find_path(EPOXY_INCLUDE_DIR
NAMES
epoxy/gl.h
HINTS
${EPOXY_ROOT_DIR}
PATH_SUFFIXES
include
)
find_library(EPOXY_LIBRARY
NAMES
epoxy
HINTS
${EPOXY_ROOT_DIR}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set EPOXY_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Epoxy DEFAULT_MSG
EPOXY_LIBRARY EPOXY_INCLUDE_DIR)
if(EPOXY_FOUND)
set(EPOXY_INCLUDE_DIRS ${EPOXY_INCLUDE_DIR})
set(EPOXY_LIBRARIES ${EPOXY_LIBRARY})
endif()
mark_as_advanced(
EPOXY_INCLUDE_DIR
EPOXY_LIBRARY
)

View File

@@ -0,0 +1,93 @@
# SPDX-FileCopyrightText: 2020 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find FFmpeg library and includes.
# Set FFMPEG_FIND_COMPONENTS to the canonical names of the libraries
# before using the module.
# This module defines
# FFMPEG_INCLUDE_DIRS, where to find libavcodec/ac3_parser.h.
# FFMPEG_LIBRARIES, libraries to link against to use FFmpeg.
# FFMPEG_ROOT_DIR, The base directory to search for FFmpeg.
# This can also be an environment variable.
# FFMPEG_FOUND, If false, do not try to use FFmpeg.
# FFMPEG_<COMPONENT>_LIBRARY, the given individual component libraries.
# If `FFMPEG_ROOT_DIR` was defined in the environment, use it.
if(DEFINED FFMPEG_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{FFMPEG_ROOT_DIR})
set(FFMPEG_ROOT_DIR $ENV{FFMPEG_ROOT_DIR})
else()
set(FFMPEG_ROOT_DIR "")
endif()
set(_ffmpeg_SEARCH_DIRS
${FFMPEG_ROOT_DIR}
/opt/lib/ffmpeg
)
if(NOT FFMPEG_FIND_COMPONENTS)
set(FFMPEG_FIND_COMPONENTS
# List taken from http://ffmpeg.org/download.html#build-mac
avcodec
avdevice
avfilter
avformat
avutil
swscale
swresample
)
endif()
find_path(_ffmpeg_INCLUDE_DIR
NAMES
libavcodec/ac3_parser.h
HINTS
${_ffmpeg_SEARCH_DIRS}
PATH_SUFFIXES
include
# Used by `ffmpeg-devel` on Fedora (see #147952).
include/ffmpeg
)
set(_ffmpeg_LIBRARIES "")
foreach(_component ${FFMPEG_FIND_COMPONENTS})
string(TOUPPER ${_component} _upper_COMPONENT)
find_library(FFMPEG_${_upper_COMPONENT}_LIBRARY
NAMES
${_component}
HINTS
${_ffmpeg_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
if(NOT FFMPEG_${_upper_COMPONENT}_LIBRARY)
message(WARNING "Could NOT find FFmpeg ${_upper_COMPONENT}.")
endif()
list(APPEND _ffmpeg_LIBRARIES ${FFMPEG_${_upper_COMPONENT}_LIBRARY})
mark_as_advanced(FFMPEG_${_upper_COMPONENT}_LIBRARY)
endforeach()
unset(_component)
unset(_upper_COMPONENT)
# handle the QUIETLY and REQUIRED arguments and set FFMPEG_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFmpeg DEFAULT_MSG
_ffmpeg_LIBRARIES _ffmpeg_INCLUDE_DIR)
if(FFMPEG_FOUND)
set(FFMPEG_LIBRARIES ${_ffmpeg_LIBRARIES})
set(FFMPEG_INCLUDE_DIRS ${_ffmpeg_INCLUDE_DIR})
endif()
mark_as_advanced(
FFMPEG_INCLUDE_DIR
)
unset(_ffmpeg_SEARCH_DIRS)
unset(_ffmpeg_LIBRARIES)
# In cmake version 3.21 and up, we can instead use the NO_CACHE option for
# find_path so we don't need to clear it from the cache here.
unset(_ffmpeg_INCLUDE_DIR CACHE)

View File

@@ -0,0 +1,88 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Fftw3 library
# Find the native Fftw3 includes and library
# This module defines
# FFTW3_INCLUDE_DIRS, where to find fftw3.h, Set when
# FFTW3_INCLUDE_DIR is found.
# FFTW3_LIBRARIES, libraries to link against to use Fftw3.
# FFTW3_ROOT_DIR, The base directory to search for Fftw3.
# This can also be an environment variable.
# FFTW3_FOUND, If false, do not try to use Fftw3.
#
# also defined, but not for general use are
# FFTW3_LIBRARY_F, where to find the Fftw3 library (single precision float).
# FFTW3_LIBRARY_THREADS_F, where to find the Fftw3 threads library (single precision float).
# FFTW3_LIBRARY_D, where to find the Fftw3 library (double precision float).
# If `FFTW3_ROOT_DIR` was defined in the environment, use it.
if(DEFINED FFTW3_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{FFTW3_ROOT_DIR})
set(FFTW3_ROOT_DIR $ENV{FFTW3_ROOT_DIR})
else()
set(FFTW3_ROOT_DIR "")
endif()
set(_fftw3_SEARCH_DIRS
${FFTW3_ROOT_DIR}
)
find_path(FFTW3_INCLUDE_DIR
NAMES
fftw3.h
HINTS
${_fftw3_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(FFTW3_LIBRARY_F
NAMES
fftw3f
HINTS
${_fftw3_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(FFTW3_LIBRARY_THREADS_F
NAMES
fftw3f_threads
HINTS
${_fftw3_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(FFTW3_LIBRARY_D
NAMES
fftw3
HINTS
${_fftw3_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Fftw3 DEFAULT_MSG
FFTW3_LIBRARY_F FFTW3_LIBRARY_THREADS_F FFTW3_LIBRARY_D FFTW3_INCLUDE_DIR)
if(FFTW3_FOUND)
set(FFTW3_LIBRARIES ${FFTW3_LIBRARY_F} ${FFTW3_LIBRARY_D} ${FFTW3_LIBRARY_THREADS_F})
set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR})
endif()
mark_as_advanced(
FFTW3_INCLUDE_DIR
FFTW3_LIBRARY_F
FFTW3_LIBRARY_THREADS_F
FFTW3_LIBRARY_D
)
unset(_fftw3_SEARCH_DIRS)

View File

@@ -0,0 +1,59 @@
# SPDX-FileCopyrightText: 2023 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Fribidi library
# Find the native fribidi includes and library
# This module defines
# LIBFRIBIDI_INCLUDE_DIRS, where to find fribidi/fribidi.h, Set when
# LIBFRIBIDI_INCLUDE_DIR is found.
# LIBFRIBIDI_LIBRARIES, libraries to link against to use fribidi.
# LIBFRIBIDI_ROOT_DIR, The base directory to search for Fribidi.
# This can also be an environment variable.
# FRIBIDI_FOUND, If false, do not try to use Fribidi.
#
# also defined, but not for general use are
# LIBFRIBIDI_LIBRARY, where to find the Fribidi library.
# If LIBFRIBIDI_ROOT_DIR was defined in the environment, use it.
if(NOT LIBFRIBIDI_ROOT_DIR AND NOT $ENV{LIBFRIBIDI_ROOT_DIR} STREQUAL "")
set(LIBFRIBIDI_ROOT_DIR $ENV{LIBFRIBIDI_ROOT_DIR})
endif()
set(_fribidi_SEARCH_DIRS
${LIBFRIBIDI_ROOT_DIR}
)
find_path(LIBFRIBIDI_INCLUDE_DIR fribidi/fribidi.h
HINTS
${_fribidi_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(LIBFRIBIDI_LIBRARY
NAMES
fribidi
HINTS
${_fribidi_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set FRIBIDI_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Fribidi DEFAULT_MSG
LIBFRIBIDI_LIBRARY LIBFRIBIDI_INCLUDE_DIR)
if(FRIBIDI_FOUND)
set(LIBFRIBIDI_LIBRARIES ${LIBFRIBIDI_LIBRARY})
set(LIBFRIBIDI_INCLUDE_DIRS ${LIBFRIBIDI_INCLUDE_DIR})
endif()
mark_as_advanced(
LIBFRIBIDI_INCLUDE_DIR
LIBFRIBIDI_LIBRARY
)
unset(_fribidi_SEARCH_DIRS)

View File

@@ -0,0 +1,95 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find GMP library
# Find the native GMP includes and library
# This module defines
# GMP_INCLUDE_DIRS, where to find gmp.h, Set when
# GMP_INCLUDE_DIR is found.
# GMP_LIBRARIES, libraries to link against to use GMP.
# GMP_ROOT_DIR, The base directory to search for GMP.
# This can also be an environment variable.
# GMP_FOUND, If false, do not try to use GMP.
#
# also defined, but not for general use are
# GMP_LIBRARY, where to find the GMP library.
# If `GMP_ROOT_DIR` was defined in the environment, use it.
if(DEFINED GMP_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{GMP_ROOT_DIR})
set(GMP_ROOT_DIR $ENV{GMP_ROOT_DIR})
else()
set(GMP_ROOT_DIR "")
endif()
set(_gmp_SEARCH_DIRS
${GMP_ROOT_DIR}
/opt/lib/gmp
)
find_path(GMP_INCLUDE_DIR
NAMES
gmp.h
HINTS
${_gmp_SEARCH_DIRS}
PATH_SUFFIXES
include/gmp
)
find_path(GMPXX_INCLUDE_DIR
NAMES
gmpxx.h
HINTS
${_gmp_SEARCH_DIRS}
PATH_SUFFIXES
include/gmp
)
find_library(GMP_LIBRARY
NAMES
gmp
HINTS
${_gmp_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(GMPXX_LIBRARY
NAMES
gmpxx
HINTS
${_gmp_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
if(GMP_INCLUDE_DIR)
set(_version_regex "^#define[ \t]+__GNU_MP_VERSION[ \t]+([0-9]+).*")
file(STRINGS "${GMP_INCLUDE_DIR}/gmp.h"
GMP_VERSION REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1"
GMP_VERSION "${GMP_VERSION}")
unset(_version_regex)
endif()
# handle the QUIETLY and REQUIRED arguments and set GMP_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GMP DEFAULT_MSG
GMP_LIBRARY GMPXX_LIBRARY GMP_INCLUDE_DIR GMPXX_INCLUDE_DIR)
if(GMP_FOUND)
set(GMP_LIBRARIES ${GMPXX_LIBRARY} ${GMP_LIBRARY})
set(GMP_INCLUDE_DIRS ${GMP_INCLUDE_DIR} ${GMPXX_INCLUDE_DIR})
endif()
mark_as_advanced(
GMP_INCLUDE_DIR
GMP_LIBRARY
GMPXX_INCLUDE_DIR
GMPXX_LIBRARY
)
unset(_gmp_SEARCH_DIRS)

View File

@@ -0,0 +1,581 @@
# SPDX-FileCopyrightText: 2015 Google Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# Ceres Solver - A fast non-linear least squares minimizer http://ceres-solver.org/
# Author: Alex Stewart <alexs.mac@gmail.com>
# FindGflags.cmake - Find Google gflags logging library.
#
# This module will attempt to find gflags, either via an exported CMake
# configuration (generated by gflags >= 2.1 which are built with CMake), or
# by performing a standard search for all gflags components. The order of
# precedence for these two methods of finding gflags is controlled by:
# GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION.
#
# This module defines the following variables:
#
# GFLAGS_FOUND: TRUE iff gflags is found.
# GFLAGS_INCLUDE_DIRS: Include directories for gflags.
# GFLAGS_LIBRARIES: Libraries required to link gflags.
# GFLAGS_NAMESPACE: The namespace in which gflags is defined. In versions of
# gflags < 2.1, this was google, for versions >= 2.1 it is
# by default gflags, although can be configured when building
# gflags to be something else (i.e. google for legacy
# compatibility).
#
# The following variables control the behavior of this module when an exported
# gflags CMake configuration is not found.
#
# GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION: TRUE/FALSE, iff TRUE
# then prefer using an exported CMake configuration
# generated by gflags >= 2.1 over searching for the
# gflags components manually. Otherwise (FALSE)
# ignore any exported gflags CMake configurations and
# always perform a manual search for the components.
# Default: TRUE iff user does not define this variable
# before we are called, and does NOT specify either
# GFLAGS_INCLUDE_DIR_HINTS or GFLAGS_LIBRARY_DIR_HINTS
# otherwise FALSE.
# GFLAGS_INCLUDE_DIR_HINTS: List of additional directories in which to
# search for gflags includes, e.g: /timbuktu/include.
# GFLAGS_LIBRARY_DIR_HINTS: List of additional directories in which to
# search for gflags libraries, e.g: /timbuktu/lib.
# GFLAGS_ROOT_DIR, The base directory to search for Gflags.
# This can also be an environment variable.
#
# The following variables are also defined by this module, but in line with
# CMake recommended FindPackage() module style should NOT be referenced directly
# by callers (use the plural variables detailed above instead). These variables
# do however affect the behavior of the module via FIND_[PATH/LIBRARY]() which
# are NOT re-called (i.e. search for library is not repeated) if these variables
# are set with valid values _in the CMake cache_. This means that if these
# variables are set directly in the cache, either by the user in the CMake GUI,
# or by the user passing -DVAR=VALUE directives to CMake when called (which
# explicitly defines a cache variable), then they will be used verbatim,
# bypassing the HINTS variables and other hard-coded search locations.
#
# GFLAGS_INCLUDE_DIR: Include directory for gflags, not including the
# include directory of any dependencies.
# GFLAGS_LIBRARY: gflags library, not including the libraries of any
# dependencies.
# If `GFLAGS_ROOT_DIR` was defined in the environment, use it.
if(DEFINED GFLAGS_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{GFLAGS_ROOT_DIR})
set(GFLAGS_ROOT_DIR $ENV{GFLAGS_ROOT_DIR})
else()
set(GFLAGS_ROOT_DIR "")
endif()
if(DEFINED GFLAGS_ROOT_DIR)
set(GFLAGS_ROOT_DIR_INCLUDE "${GFLAGS_ROOT_DIR}/include")
set(GFLAGS_ROOT_DIR_LIB "${GFLAGS_ROOT_DIR}/lib")
endif()
# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when FindGflags was
# invoked, necessary for MSVC.
#
# NOTE: must be a macro, modifies `CMAKE_FIND_LIBRARY_PREFIXES`
# in the caller's scope to restore the original value.
macro(GFLAGS_RESET_FIND_LIBRARY_PREFIX)
if(MSVC)
set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}")
endif()
endmacro()
# Called if we failed to find gflags or any of its required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
#
# NOTE: must be a macro, uses `return()` to exit the calling Find module's
# scope. A function's `return()` would only exit the function itself.
macro(GFLAGS_REPORT_NOT_FOUND REASON_MSG)
unset(GFLAGS_FOUND)
unset(GFLAGS_INCLUDE_DIRS)
unset(GFLAGS_LIBRARIES)
# Do not use unset, as we want to keep GFLAGS_NAMESPACE in the cache,
# but simply clear its value.
set(GFLAGS_NAMESPACE "" CACHE STRING
"gflags namespace (google or gflags)" FORCE)
# Make results of search visible in the CMake GUI if gflags has not
# been found so that user does not have to toggle to advanced view.
mark_as_advanced(CLEAR GFLAGS_INCLUDE_DIR
GFLAGS_LIBRARY
GFLAGS_NAMESPACE)
gflags_reset_find_library_prefix()
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage()
# use the camelcase library name, not uppercase.
if(Gflags_FIND_QUIETLY)
message(STATUS "Failed to find gflags - " ${REASON_MSG} ${ARGN})
elseif(Gflags_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find gflags - " ${REASON_MSG} ${ARGN})
else()
# Neither QUIETLY nor REQUIRED, use no priority which emits a message
# but continues configuration and allows generation.
message(STATUS "Failed to find gflags - " ${REASON_MSG} ${ARGN})
endif()
return()
endmacro()
# Verify that all variable names passed as arguments are defined (can be empty
# but must be defined) or raise a fatal error.
function(GFLAGS_CHECK_VARS_DEFINED)
foreach(CHECK_VAR ${ARGN})
if(NOT DEFINED ${CHECK_VAR})
message(FATAL_ERROR "Ceres Bug: ${CHECK_VAR} is not defined.")
endif()
endforeach()
endfunction()
# Use check_cxx_source_compiles() to compile trivial test programs to determine
# the gflags namespace. This works on all OSs except Windows. If using Visual
# Studio, it fails because msbuild forces check_cxx_source_compiles() to use
# CMAKE_BUILD_TYPE=Debug for the test project, which usually breaks detection
# because MSVC requires that the test project use the same build type as gflags,
# which would normally be built in Release.
#
# Defines: GFLAGS_NAMESPACE in the caller's scope with the detected namespace,
# which is blank (empty string, will test FALSE is CMake conditionals)
# if detection failed.
function(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE)
# Verify that all required variables are defined.
gflags_check_vars_defined(
GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
# Ensure that GFLAGS_NAMESPACE is always unset on completion unless
# we explicitly set if after having the correct namespace.
set(GFLAGS_NAMESPACE "" PARENT_SCOPE)
include(CheckCXXSourceCompiles)
# Setup include path & link library for gflags for CHECK_CXX_SOURCE_COMPILES.
set(CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES})
# First try the (older) google namespace. Note that the output variable
# MUST be unique to the build type as otherwise the test is not repeated as
# it is assumed to have already been performed.
check_cxx_source_compiles(
"#include <gflags/gflags.h>
int main(int argc, char * argv[]) {
google::ParseCommandLineFlags(&argc, &argv, true);
return 0;
}"
GFLAGS_IN_GOOGLE_NAMESPACE)
if(GFLAGS_IN_GOOGLE_NAMESPACE)
set(GFLAGS_NAMESPACE google PARENT_SCOPE)
return()
endif()
# Try (newer) gflags namespace instead. Note that the output variable
# MUST be unique to the build type as otherwise the test is not repeated as
# it is assumed to have already been performed.
set(CMAKE_REQUIRED_INCLUDES ${GFLAGS_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES})
check_cxx_source_compiles(
"#include <gflags/gflags.h>
int main(int argc, char * argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
return 0;
}"
GFLAGS_IN_GFLAGS_NAMESPACE)
if(GFLAGS_IN_GFLAGS_NAMESPACE)
set(GFLAGS_NAMESPACE gflags PARENT_SCOPE)
return()
endif()
endfunction()
# Use regex on the gflags headers to attempt to determine the gflags namespace.
# Checks both gflags.h (contained namespace on versions < 2.1.2) and
# gflags_declare.h, which contains the namespace on versions >= 2.1.2.
# In general, this method should only be used when
# GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_TRY_COMPILE() cannot be used, or has
# failed.
#
# Defines: GFLAGS_NAMESPACE in the caller's scope with the detected namespace,
# which is blank (empty string, will test FALSE is CMake conditionals)
# if detection failed.
function(GFLAGS_CHECK_GFLAGS_NAMESPACE_USING_REGEX)
# Verify that all required variables are defined.
gflags_check_vars_defined(GFLAGS_INCLUDE_DIR)
# Ensure that GFLAGS_NAMESPACE is always undefined on completion unless
# we explicitly set if after having the correct namespace.
set(GFLAGS_NAMESPACE "" PARENT_SCOPE)
# Scan gflags.h to identify what namespace gflags was built with. On
# versions of gflags < 2.1.2, gflags.h was configured with the namespace
# directly, on >= 2.1.2, gflags.h uses the GFLAGS_NAMESPACE #define which
# is defined in gflags_declare.h, we try each location in turn.
set(GFLAGS_HEADER_FILE ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h)
if(NOT EXISTS ${GFLAGS_HEADER_FILE})
gflags_report_not_found(
"Could not find file: ${GFLAGS_HEADER_FILE} "
"containing namespace information in gflags install located at: "
"${GFLAGS_INCLUDE_DIR}.")
endif()
file(READ ${GFLAGS_HEADER_FILE} GFLAGS_HEADER_FILE_CONTENTS)
string(REGEX MATCH "namespace [A-Za-z]+"
GFLAGS_NAMESPACE "${GFLAGS_HEADER_FILE_CONTENTS}")
string(REGEX REPLACE "namespace ([A-Za-z]+)" "\\1"
GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}")
if(NOT GFLAGS_NAMESPACE)
gflags_report_not_found(
"Failed to extract gflags namespace from header file: "
"${GFLAGS_HEADER_FILE}.")
endif()
if(GFLAGS_NAMESPACE STREQUAL "google" OR
GFLAGS_NAMESPACE STREQUAL "gflags")
# Found valid gflags namespace from gflags.h.
set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE)
return()
endif()
# Failed to find gflags namespace from gflags.h, gflags is likely a new
# version, check gflags_declare.h, which in newer versions (>= 2.1.2) contains
# the GFLAGS_NAMESPACE #define, which is then referenced in gflags.h.
set(GFLAGS_DECLARE_FILE ${GFLAGS_INCLUDE_DIR}/gflags/gflags_declare.h)
if(NOT EXISTS ${GFLAGS_DECLARE_FILE})
gflags_report_not_found(
"Could not find file: ${GFLAGS_DECLARE_FILE} "
"containing namespace information in gflags install located at: "
"${GFLAGS_INCLUDE_DIR}.")
endif()
file(READ ${GFLAGS_DECLARE_FILE} GFLAGS_DECLARE_FILE_CONTENTS)
string(REGEX MATCH "#define GFLAGS_NAMESPACE [A-Za-z]+"
GFLAGS_NAMESPACE "${GFLAGS_DECLARE_FILE_CONTENTS}")
string(REGEX REPLACE "#define GFLAGS_NAMESPACE ([A-Za-z]+)" "\\1"
GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}")
if(NOT GFLAGS_NAMESPACE)
gflags_report_not_found(
"Failed to extract gflags namespace from declare file: "
"${GFLAGS_DECLARE_FILE}.")
endif()
if(GFLAGS_NAMESPACE STREQUAL "google" OR
GFLAGS_NAMESPACE STREQUAL "gflags")
# Found valid gflags namespace from gflags.h.
set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE)
return()
endif()
endfunction()
# -----------------------------------------------------------------
# By default, if the user has expressed no preference for using an exported
# gflags CMake configuration over performing a search for the installed
# components, and has not specified any hints for the search locations, then
# prefer a gflags exported configuration if available.
if(NOT DEFINED GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION
AND NOT GFLAGS_INCLUDE_DIR_HINTS
AND NOT GFLAGS_LIBRARY_DIR_HINTS)
message(STATUS "No preference for use of exported gflags CMake configuration "
"set, and no hints for include/library directories provided. "
"Defaulting to preferring an installed/exported gflags CMake configuration "
"if available.")
set(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE)
endif()
if(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
# Try to find an exported CMake configuration for gflags, as generated by
# gflags versions >= 2.1.
#
# We search twice, s/t we can invert the ordering of precedence used by
# find_package() for exported package build directories, and installed
# packages (found via CMAKE_SYSTEM_PREFIX_PATH), listed as items 6) and 7)
# respectively in [1].
#
# By default, exported build directories are (in theory) detected first, and
# this is usually the case on Windows. However, on OS X & Linux, the install
# path (/usr/local) is typically present in the PATH environment variable
# which is checked in item 4) in [1] (i.e. before both of the above, unless
# NO_SYSTEM_ENVIRONMENT_PATH is passed). As such on those OSs installed
# packages are usually detected in preference to exported package build
# directories.
#
# To ensure a more consistent response across all OSs, and as users usually
# want to prefer an installed version of a package over a locally built one
# where both exist (esp. as the exported build directory might be removed
# after installation), we first search with NO_CMAKE_PACKAGE_REGISTRY which
# means any build directories exported by the user are ignored, and thus
# installed directories are preferred. If this fails to find the package
# we then research again, but without NO_CMAKE_PACKAGE_REGISTRY, so any
# exported build directories will now be detected.
#
# To prevent confusion on Windows, we also pass NO_CMAKE_BUILDS_PATH (which
# is item 5) in [1]), to not preferentially use projects that were built
# recently with the CMake GUI to ensure that we always prefer an installed
# version if available.
#
# [1] http://www.cmake.org/cmake/help/v2.8.11/cmake.html#command:find_package
find_package(gflags QUIET
NO_MODULE
NO_CMAKE_PACKAGE_REGISTRY
NO_CMAKE_BUILDS_PATH)
if(gflags_FOUND)
message(STATUS "Found installed version of gflags: ${gflags_DIR}")
else()
# Failed to find an installed version of gflags, repeat search allowing
# exported build directories.
message(STATUS "Failed to find installed gflags CMake configuration, "
"searching for gflags build directories exported with CMake.")
# Again pass NO_CMAKE_BUILDS_PATH, as we know that gflags is exported and
# do not want to treat projects built with the CMake GUI preferentially.
find_package(gflags QUIET
NO_MODULE
NO_CMAKE_BUILDS_PATH)
if(gflags_FOUND)
message(STATUS "Found exported gflags build directory: ${gflags_DIR}")
endif()
endif()
set(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION ${gflags_FOUND})
# gflags v2.1 - 2.1.2 shipped with a bug in their gflags-config.cmake [1]
# whereby gflags_LIBRARIES = "gflags", but there was no imported target
# called "gflags", they were called: gflags[_nothreads]-[static/shared].
# As this causes linker errors when gflags is not installed in a location
# on the current library paths, detect if this problem is present and
# fix it.
#
# [1] https://github.com/gflags/gflags/issues/110
if(gflags_FOUND)
# NOTE: This is not written as additional conditions in the outer
# if(gflags_FOUND) as the NOT TARGET "${gflags_LIBRARIES}"
# condition causes problems if gflags is not found.
if(${gflags_VERSION} VERSION_LESS 2.1.3 AND
NOT TARGET "${gflags_LIBRARIES}")
message(STATUS "Detected broken gflags install in: ${gflags_DIR}, "
"version: ${gflags_VERSION} <= 2.1.2 which defines gflags_LIBRARIES = "
"${gflags_LIBRARIES} which is not an imported CMake target, see: "
"https://github.com/gflags/gflags/issues/110. Attempting to fix by "
"detecting correct gflags target.")
# Ordering here expresses preference for detection, specifically we do not
# want to use the _nothreads variants if the full library is available.
list(APPEND CHECK_GFLAGS_IMPORTED_TARGET_NAMES
gflags-shared gflags-static
gflags_nothreads-shared gflags_nothreads-static)
foreach(CHECK_GFLAGS_TARGET ${CHECK_GFLAGS_IMPORTED_TARGET_NAMES})
if(TARGET ${CHECK_GFLAGS_TARGET})
message(STATUS "Found valid gflags target: ${CHECK_GFLAGS_TARGET}, "
"updating gflags_LIBRARIES.")
set(gflags_LIBRARIES ${CHECK_GFLAGS_TARGET})
break()
endif()
endforeach()
if(NOT TARGET ${gflags_LIBRARIES})
message(STATUS "Failed to fix detected broken gflags install in: "
"${gflags_DIR}, version: ${gflags_VERSION} <= 2.1.2, none of the "
"imported targets for gflags: ${CHECK_GFLAGS_IMPORTED_TARGET_NAMES} "
"are defined. Will continue with a manual search for gflags "
"components. We recommend you build/install a version of gflags > "
"2.1.2 (or master).")
set(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION FALSE)
endif()
endif()
endif()
if(FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
message(STATUS "Detected gflags version: ${gflags_VERSION}")
set(GFLAGS_FOUND ${gflags_FOUND})
set(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR})
set(GFLAGS_LIBRARY ${gflags_LIBRARIES})
# gflags does not export the namespace in their CMake configuration, so
# use our function to determine what it should be, as it can be either
# gflags or google dependent upon version & configuration.
#
# NOTE: We use the regex method to determine the namespace here, as
# check_cxx_source_compiles() will not use imported targets, which
# is what gflags will be in this case.
gflags_check_gflags_namespace_using_regex()
if(NOT GFLAGS_NAMESPACE)
gflags_report_not_found(
"Failed to determine gflags namespace using regex for gflags "
"version: ${gflags_VERSION} exported here: ${gflags_DIR} using CMake.")
endif()
else()
message(STATUS "Failed to find an installed/exported CMake configuration "
"for gflags, will perform search for installed gflags components.")
endif()
endif()
if(NOT GFLAGS_FOUND)
# Either failed to find an exported gflags CMake configuration, or user
# told us not to use one. Perform a manual search for all gflags components.
# Handle possible presence of lib prefix for libraries on MSVC, see
# also GFLAGS_RESET_FIND_LIBRARY_PREFIX().
if(MSVC)
# Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES
# s/t we can set it back before returning.
set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
# The empty string in this list is important, it represents the case when
# the libraries have no prefix (shared libraries / DLLs).
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}")
endif()
# Search user-installed locations first, so that we prefer user installs
# to system installs where both exist.
list(APPEND GFLAGS_CHECK_INCLUDE_DIRS
${GFLAGS_ROOT_DIR_INCLUDE}
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include
/opt/lib/gflags/include)
list(APPEND GFLAGS_CHECK_PATH_SUFFIXES
gflags/include # Windows (for C:/Program Files prefix).
gflags/Include) # Windows (for C:/Program Files prefix).
list(APPEND GFLAGS_CHECK_LIBRARY_DIRS
${GFLAGS_ROOT_DIR_LIB}
/usr/local/lib
/usr/local/homebrew/lib # Mac OS X.
/opt/local/lib
/usr/lib
/opt/lib/gflags/lib)
list(APPEND GFLAGS_CHECK_LIBRARY_SUFFIXES
gflags/lib # Windows (for C:/Program Files prefix).
gflags/Lib) # Windows (for C:/Program Files prefix).
# Search supplied hint directories first if supplied.
find_path(GFLAGS_INCLUDE_DIR
NAMES gflags/gflags.h
PATHS ${GFLAGS_INCLUDE_DIR_HINTS}
${GFLAGS_CHECK_INCLUDE_DIRS}
PATH_SUFFIXES ${GFLAGS_CHECK_PATH_SUFFIXES})
if(NOT GFLAGS_INCLUDE_DIR OR
NOT EXISTS ${GFLAGS_INCLUDE_DIR})
gflags_report_not_found(
"Could not find gflags include directory, set GFLAGS_INCLUDE_DIR "
"to directory containing gflags/gflags.h")
endif()
find_library(GFLAGS_LIBRARY NAMES gflags
PATHS ${GFLAGS_LIBRARY_DIR_HINTS}
${GFLAGS_CHECK_LIBRARY_DIRS}
PATH_SUFFIXES ${GFLAGS_CHECK_LIBRARY_SUFFIXES})
if(NOT GFLAGS_LIBRARY OR
NOT EXISTS ${GFLAGS_LIBRARY})
gflags_report_not_found(
"Could not find gflags library, set GFLAGS_LIBRARY "
"to full path to libgflags.")
endif()
# gflags typically requires a threading library (which is OS dependent), note
# that this defines the CMAKE_THREAD_LIBS_INIT variable. If we are able to
# detect threads, we assume that gflags requires it.
find_package(Threads QUIET)
set(GFLAGS_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
# On Windows (including MinGW), the Shlwapi library is used by gflags if
# available.
if(WIN32)
include(CheckIncludeFileCXX)
check_include_file_cxx("shlwapi.h" HAVE_SHLWAPI)
if(HAVE_SHLWAPI)
list(APPEND GFLAGS_LINK_LIBRARIES shlwapi.lib)
endif()
endif()
# Mark internally as found, then verify. GFLAGS_REPORT_NOT_FOUND() unsets
# if called.
set(GFLAGS_FOUND TRUE)
# Identify what namespace gflags was built with.
if(GFLAGS_INCLUDE_DIR AND NOT GFLAGS_NAMESPACE)
# To handle Windows peculiarities / CMake bugs on MSVC we try two approaches
# to detect the gflags namespace:
#
# 1) Try to use check_cxx_source_compiles() to compile a trivial program
# with the two choices for the gflags namespace.
#
# 2) [In the event 1) fails] Use regex on the gflags headers to try to
# determine the gflags namespace. Whilst this is less robust than 1),
# it does avoid any interaction with msbuild.
gflags_check_gflags_namespace_using_try_compile()
if(NOT GFLAGS_NAMESPACE)
# Failed to determine gflags namespace using check_cxx_source_compiles()
# method, try and obtain it using regex on the gflags headers instead.
message(STATUS "Failed to find gflags namespace using "
"check_cxx_source_compiles(), trying namespace regex instead, "
"this is expected on Windows.")
gflags_check_gflags_namespace_using_regex()
if(NOT GFLAGS_NAMESPACE)
gflags_report_not_found(
"Failed to determine gflags namespace either by "
"check_cxx_source_compiles(), or namespace regex.")
endif()
endif()
endif()
# Make the GFLAGS_NAMESPACE a cache variable s/t the user can view it, and could
# overwrite it in the CMake GUI.
set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" CACHE STRING
"gflags namespace (google or gflags)" FORCE)
# gflags does not seem to provide any record of the version in its
# source tree, thus cannot extract version.
# Catch case when caller has set GFLAGS_NAMESPACE in the cache / GUI
# with an invalid value.
if(GFLAGS_NAMESPACE AND
NOT GFLAGS_NAMESPACE STREQUAL "google" AND
NOT GFLAGS_NAMESPACE STREQUAL "gflags")
gflags_report_not_found(
"Caller defined GFLAGS_NAMESPACE:"
" ${GFLAGS_NAMESPACE} is not valid, not google or gflags.")
endif()
# Catch case when caller has set GFLAGS_INCLUDE_DIR in the cache / GUI and
# thus FIND_[PATH/LIBRARY] are not called, but specified locations are
# invalid, otherwise we would report the library as found.
if(GFLAGS_INCLUDE_DIR AND
NOT EXISTS ${GFLAGS_INCLUDE_DIR}/gflags/gflags.h)
gflags_report_not_found(
"Caller defined GFLAGS_INCLUDE_DIR:"
" ${GFLAGS_INCLUDE_DIR} does not contain gflags/gflags.h header.")
endif()
# TODO: This regex for gflags library is pretty primitive, we use lowercase
# for comparison to handle Windows using CamelCase library names, could
# this check be better?
string(TOLOWER "${GFLAGS_LIBRARY}" LOWERCASE_GFLAGS_LIBRARY)
if(GFLAGS_LIBRARY AND
NOT "${LOWERCASE_GFLAGS_LIBRARY}" MATCHES ".*gflags[^/]*")
gflags_report_not_found(
"Caller defined GFLAGS_LIBRARY: "
"${GFLAGS_LIBRARY} does not match gflags.")
endif()
gflags_reset_find_library_prefix()
endif()
# Set standard CMake FindPackage variables if found.
if(GFLAGS_FOUND)
set(GFLAGS_INCLUDE_DIRS ${GFLAGS_INCLUDE_DIR})
set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARY} ${GFLAGS_LINK_LIBRARIES})
endif()
# Handle REQUIRED / QUIET optional arguments.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GFLAGS DEFAULT_MSG
GFLAGS_INCLUDE_DIRS GFLAGS_LIBRARIES GFLAGS_NAMESPACE)
# Only mark internal variables as advanced if we found gflags, otherwise
# leave them visible in the standard GUI for the user to set manually.
if(GFLAGS_FOUND)
mark_as_advanced(FORCE GFLAGS_INCLUDE_DIR
GFLAGS_LIBRARY
GFLAGS_NAMESPACE
gflags_DIR) # Autogenerated by find_package(gflags)
endif()

View File

@@ -0,0 +1,208 @@
# SPDX-FileCopyrightText: 2015 Google Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# Ceres Solver - A fast non-linear least squares minimizer http://ceres-solver.org/
# Author: Alex Stewart <alexs.mac@gmail.com>
# FindGlog.cmake - Find Google glog logging library.
#
# This module defines the following variables:
#
# GLOG_FOUND: TRUE iff glog is found.
# GLOG_INCLUDE_DIRS: Include directories for glog.
# GLOG_LIBRARIES: Libraries required to link glog.
#
# The following variables control the behaviour of this module:
#
# GLOG_INCLUDE_DIR_HINTS: List of additional directories in which to
# search for glog includes, e.g: /timbuktu/include.
# GLOG_LIBRARY_DIR_HINTS: List of additional directories in which to
# search for glog libraries, e.g: /timbuktu/lib.
# GLOG_ROOT_DIR, The base directory to search for Glog.
# This can also be an environment variable.
#
# The following variables are also defined by this module, but in line with
# CMake recommended FindPackage() module style should NOT be referenced directly
# by callers (use the plural variables detailed above instead). These variables
# do however affect the behaviour of the module via FIND_[PATH/LIBRARY]() which
# are NOT re-called (i.e. search for library is not repeated) if these variables
# are set with valid values _in the CMake cache_. This means that if these
# variables are set directly in the cache, either by the user in the CMake GUI,
# or by the user passing -DVAR=VALUE directives to CMake when called (which
# explicitly defines a cache variable), then they will be used verbatim,
# bypassing the HINTS variables and other hard-coded search locations.
#
# GLOG_INCLUDE_DIR: Include directory for glog, not including the
# include directory of any dependencies.
# GLOG_LIBRARY: glog library, not including the libraries of any
# dependencies.
# If `GLOG_ROOT_DIR` was defined in the environment, use it.
if(DEFINED GLOG_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{GLOG_ROOT_DIR})
set(GLOG_ROOT_DIR $ENV{GLOG_ROOT_DIR})
else()
set(GLOG_ROOT_DIR "")
endif()
if(DEFINED GLOG_ROOT_DIR)
set(GLOG_ROOT_DIR_INCLUDE "${GLOG_ROOT_DIR}/include")
set(GLOG_ROOT_DIR_LIB "${GLOG_ROOT_DIR}/lib")
endif()
# Reset CALLERS_CMAKE_FIND_LIBRARY_PREFIXES to its value when
# FindGlog was invoked.
#
# NOTE: must be a macro, modifies `CMAKE_FIND_LIBRARY_PREFIXES`
# in the caller's scope to restore the original value.
macro(GLOG_RESET_FIND_LIBRARY_PREFIX)
if(MSVC)
set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}")
endif()
endmacro()
# Called if we failed to find glog or any of its required dependencies,
# unsets all public (designed to be used externally) variables and reports
# error message at priority depending upon [REQUIRED/QUIET/<NONE>] argument.
#
# NOTE: must be a macro, uses `return()` to exit the calling Find module's
# scope. A function's `return()` would only exit the function itself.
macro(GLOG_REPORT_NOT_FOUND REASON_MSG)
unset(GLOG_FOUND)
unset(GLOG_INCLUDE_DIRS)
unset(GLOG_LIBRARIES)
# Make results of search visible in the CMake GUI if glog has not
# been found so that user does not have to toggle to advanced view.
mark_as_advanced(CLEAR GLOG_INCLUDE_DIR
GLOG_LIBRARY)
glog_reset_find_library_prefix()
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by FindPackage()
# use the camelcase library name, not uppercase.
if(Glog_FIND_QUIETLY)
message(STATUS "Failed to find glog - " ${REASON_MSG} ${ARGN})
elseif(Glog_FIND_REQUIRED)
message(FATAL_ERROR "Failed to find glog - " ${REASON_MSG} ${ARGN})
else()
# Neither QUIETLY nor REQUIRED, use no priority which emits a message
# but continues configuration and allows generation.
message(STATUS "Failed to find glog - " ${REASON_MSG} ${ARGN})
endif()
return()
endmacro()
# Handle possible presence of lib prefix for libraries on MSVC, see
# also GLOG_RESET_FIND_LIBRARY_PREFIX().
if(MSVC)
# Preserve the caller's original values for CMAKE_FIND_LIBRARY_PREFIXES
# s/t we can set it back before returning.
set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
# The empty string in this list is important, it represents the case when
# the libraries have no prefix (shared libraries / DLLs).
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}")
endif()
# Search user-installed locations first, so that we prefer user installs
# to system installs where both exist.
list(APPEND GLOG_CHECK_INCLUDE_DIRS
${GLOG_ROOT_DIR_INCLUDE}
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include
/opt/lib/glog/include)
# Windows (for C:/Program Files prefix).
list(APPEND GLOG_CHECK_PATH_SUFFIXES
glog/include
glog/Include
Glog/include
Glog/Include)
list(APPEND GLOG_CHECK_LIBRARY_DIRS
${GLOG_ROOT_DIR_LIB}
/usr/local/lib
/usr/local/homebrew/lib # Mac OS X.
/opt/local/lib
/usr/lib
/opt/lib/glog/lib)
# Windows (for C:/Program Files prefix).
list(APPEND GLOG_CHECK_LIBRARY_SUFFIXES
glog/lib
glog/Lib
Glog/lib
Glog/Lib)
# Search supplied hint directories first if supplied.
find_path(GLOG_INCLUDE_DIR
NAMES glog/logging.h
PATHS ${GLOG_INCLUDE_DIR_HINTS}
${GLOG_CHECK_INCLUDE_DIRS}
PATH_SUFFIXES ${GLOG_CHECK_PATH_SUFFIXES})
if(NOT GLOG_INCLUDE_DIR OR
NOT EXISTS ${GLOG_INCLUDE_DIR})
glog_report_not_found(
"Could not find glog include directory, set GLOG_INCLUDE_DIR "
"to directory containing glog/logging.h")
endif()
find_library(GLOG_LIBRARY NAMES glog
PATHS ${GLOG_LIBRARY_DIR_HINTS}
${GLOG_CHECK_LIBRARY_DIRS}
PATH_SUFFIXES ${GLOG_CHECK_LIBRARY_SUFFIXES})
if(NOT GLOG_LIBRARY OR
NOT EXISTS ${GLOG_LIBRARY})
glog_report_not_found(
"Could not find glog library, set GLOG_LIBRARY "
"to full path to libglog.")
endif()
# Mark internally as found, then verify. GLOG_REPORT_NOT_FOUND() unsets
# if called.
set(GLOG_FOUND TRUE)
# Glog does not seem to provide any record of the version in its
# source tree, thus cannot extract version.
# Catch case when caller has set GLOG_INCLUDE_DIR in the cache / GUI and
# thus FIND_[PATH/LIBRARY] are not called, but specified locations are
# invalid, otherwise we would report the library as found.
if(GLOG_INCLUDE_DIR AND
NOT EXISTS ${GLOG_INCLUDE_DIR}/glog/logging.h)
glog_report_not_found(
"Caller defined GLOG_INCLUDE_DIR:"
" ${GLOG_INCLUDE_DIR} does not contain glog/logging.h header.")
endif()
# TODO: This regex for glog library is pretty primitive, we use lowercase
# for comparison to handle Windows using CamelCase library names, could
# this check be better?
string(TOLOWER "${GLOG_LIBRARY}" LOWERCASE_GLOG_LIBRARY)
if(GLOG_LIBRARY AND
NOT "${LOWERCASE_GLOG_LIBRARY}" MATCHES ".*glog[^/]*")
glog_report_not_found(
"Caller defined GLOG_LIBRARY: "
"${GLOG_LIBRARY} does not match glog.")
endif()
# Set standard CMake FindPackage variables if found.
if(GLOG_FOUND)
set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
set(GLOG_LIBRARIES ${GLOG_LIBRARY})
endif()
glog_reset_find_library_prefix()
# Handle REQUIRED / QUIET optional arguments.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLOG DEFAULT_MSG
GLOG_INCLUDE_DIRS GLOG_LIBRARIES)
# Only mark internal variables as advanced if we found glog, otherwise
# leave them visible in the standard GUI for the user to set manually.
if(GLOG_FOUND)
mark_as_advanced(FORCE GLOG_INCLUDE_DIR
GLOG_LIBRARY)
endif()

View File

@@ -0,0 +1,77 @@
# SPDX-FileCopyrightText: 2021 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# Find HIP compiler. This module defines
# HIP_HIPCC_EXECUTABLE, the full path to the hipcc executable
# HIP_VERSION, the HIP compiler version
# HIP_FOUND, if the HIP toolkit is found.
if(NOT (DEFINED HIP_ROOT_DIR))
set(HIP_ROOT_DIR "")
endif()
# If `HIP_ROOT_DIR` was defined in the environment, use it.
if(HIP_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{HIP_ROOT_DIR})
set(HIP_ROOT_DIR $ENV{HIP_ROOT_DIR})
elseif(DEFINED ENV{HIP_PATH})
# Built-in environment variable from SDK.
set(HIP_ROOT_DIR $ENV{HIP_PATH})
endif()
set(_hip_SEARCH_DIRS
${HIP_ROOT_DIR}
/opt/rocm
/opt/rocm/hip
"C:/Program Files/AMD/ROCm/*"
)
find_program(HIP_HIPCC_EXECUTABLE
NAMES
hipcc
HINTS
${_hip_SEARCH_DIRS}
PATH_SUFFIXES
bin
)
if(HIP_HIPCC_EXECUTABLE)
if(NOT HIP_ROOT_DIR)
get_filename_component(HIP_ROOT_DIR ${HIP_HIPCC_EXECUTABLE} DIRECTORY)
get_filename_component(HIP_ROOT_DIR ${HIP_ROOT_DIR} DIRECTORY)
endif()
set(HIP_VERSION_MAJOR 0)
set(HIP_VERSION_MINOR 0)
set(HIP_VERSION_PATCH 0)
# Get version from the header.
set(_hip_version_file "${HIP_ROOT_DIR}/include/hip/hip_version.h")
if(EXISTS ${_hip_version_file})
file(STRINGS ${_hip_version_file} _tmp REGEX "^#define HIP_VERSION_MAJOR.*$")
string(REGEX MATCHALL "[0-9]+" HIP_VERSION_MAJOR ${_tmp})
file(STRINGS ${_hip_version_file} _tmp REGEX "^#define HIP_VERSION_MINOR.*$")
string(REGEX MATCHALL "[0-9]+" HIP_VERSION_MINOR ${_tmp})
file(STRINGS ${_hip_version_file} _tmp REGEX "^#define HIP_VERSION_PATCH.*$")
string(REGEX MATCHALL "[0-9]+" HIP_VERSION_PATCH ${_tmp})
unset(_tmp)
endif()
unset(_hip_version_file)
# Construct full semantic version.
set(HIP_VERSION "${HIP_VERSION_MAJOR}.${HIP_VERSION_MINOR}.${HIP_VERSION_PATCH}")
set(HIP_VERSION_SHORT "${HIP_VERSION_MAJOR}.${HIP_VERSION_MINOR}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HIP
REQUIRED_VARS HIP_HIPCC_EXECUTABLE
VERSION_VAR HIP_VERSION)
mark_as_advanced(
HIP_HIPCC_EXECUTABLE
)
unset(_hip_SEARCH_DIRS)

View File

@@ -0,0 +1,108 @@
# SPDX-FileCopyrightText: 2021 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# Find HIPRT SDK. This module defines:
# HIPRT_INCLUDE_DIRS, path to HIPRT include directory
# HIPRT_LIBRARIES, libraries to link against to use HIPRT.
# HIPRT_VERSION, the HIPRT library version string.
# HIPRT_FOUND, if SDK found
#
# also defined, but not for general use are
# HIPRT_INCLUDE_DIR, path to HIPRT include directory
# HIPRT_LIBRARY, where to find the HIPRT library.
if(NOT (DEFINED HIPRT_ROOT_DIR))
set(HIPRT_ROOT_DIR "")
endif()
# If `HIPRT_ROOT_DIR` was defined in the environment, use it.
if(HIPRT_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{HIPRT_ROOT_DIR})
set(HIPRT_ROOT_DIR $ENV{HIPRT_ROOT_DIR})
elseif(DEFINED ENV{HIP_PATH})
# Built-in environment variable from SDK.
set(HIPRT_ROOT_DIR $ENV{HIP_PATH})
endif()
set(_hiprt_SEARCH_DIRS
${HIPRT_ROOT_DIR}
/opt/lib/hiprt
)
find_path(HIPRT_INCLUDE_DIR
NAMES
hiprt/hiprt.h
HINTS
${_hiprt_SEARCH_DIRS}
PATH_SUFFIXES
include
)
set(HIPRT_VERSION "")
if(HIPRT_INCLUDE_DIR)
file(STRINGS "${HIPRT_INCLUDE_DIR}/hiprt/hiprt.h" _hiprt_version
REGEX "^#define HIPRT_VERSION_STR[ \t]\".*\"$")
string(REGEX MATCHALL "[0-9]+[.0-9]+" HIPRT_VERSION ${_hiprt_version})
unset(_hiprt_version)
endif()
# Special code that side-steps annoyance of updating to a newer HIP-RT version: CMake caches the
# library path variable and it does include an API in the file path. Without any extra logic manual
# steps of updating local CMakeCache.txt would be needed.
# The code checks that the API of the cached variable is what it is expected to be based on the
# headers. If the API mismatches and the library exists skip the logic, assuming developers
# requested such configuration explicitly.
if(HIPRT_LIBRARY AND NOT EXISTS "${HIPRT_LIBRARY}")
get_filename_component(hiprt_library_name_we "${HIPRT_LIBRARY}" NAME_WE)
# The file name is not guaranteed to have API in it. Check for it to explicitly set the API to an
# empty string. Conditional group in the regex could help, but it is not trivial to address it in
# the replacement string.
if("${hiprt_library_name_we}" MATCHES "^(lib)?hiprt([0-9]+)64$")
string(REGEX REPLACE "^(lib)?hiprt([0-9]+)64$" "\\2"
hiprt_library_api "${hiprt_library_name_we}")
else()
set(hiprt_library_api "")
endif()
if(NOT "${HIPRT_VERSION}" STREQUAL "${hiprt_library_api}")
message(STATUS "${HIPRT_LIBRARY} does not exist and has wrong API."
"Forcing re-discovery."
)
unset(HIPRT_LIBRARY CACHE)
endif()
unset(hiprt_library_name_we)
unset(hiprt_library_api)
endif()
find_library(HIPRT_LIBRARY
NAMES
hiprt64
hiprt${HIPRT_VERSION}64
HINTS
${_hiprt_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib bin
# Skip CMake install prefix to prevent library from being found under
# `bin/lib/libhiprt<api>64.so` in the build folder.
NO_CMAKE_INSTALL_PREFIX
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HIPRT
REQUIRED_VARS HIPRT_LIBRARY HIPRT_INCLUDE_DIR
VERSION_VAR HIPRT_VERSION)
if(HIPRT_FOUND)
set(HIPRT_LIBRARIES ${HIPRT_LIBRARY})
set(HIPRT_INCLUDE_DIRS ${HIPRT_INCLUDE_DIR})
endif()
mark_as_advanced(
HIPRT_INCLUDE_DIR
HIPRT_LIBRARY
)
unset(_hiprt_SEARCH_DIRS)

View File

@@ -0,0 +1,59 @@
# SPDX-FileCopyrightText: 2023 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Harfbuzz library
# Find the native harfbuzz includes and library
# This module defines
# LIBHARFBUZZ_INCLUDE_DIRS, where to find hb.h, Set when
# LIBHARFBUZZ_INCLUDE_DIR is found.
# LIBHARFBUZZ_LIBRARIES, libraries to link against to use harfbuzz.
# LIBHARFBUZZ_ROOT_DIR, The base directory to search for Harfbuzz.
# This can also be an environment variable.
# HARFBUZZ_FOUND, If false, do not try to use Harfbuzz.
#
# also defined, but not for general use are
# LIBHARFBUZZ_LIBRARY, where to find the Harfbuzz library.
# If LIBHARFBUZZ_ROOT_DIR was defined in the environment, use it.
if(NOT LIBHARFBUZZ_ROOT_DIR AND NOT $ENV{LIBHARFBUZZ_ROOT_DIR} STREQUAL "")
set(LIBHARFBUZZ_ROOT_DIR $ENV{LIBHARFBUZZ_ROOT_DIR})
endif()
set(_harfbuzz_SEARCH_DIRS
${LIBHARFBUZZ_ROOT_DIR}
)
find_path(LIBHARFBUZZ_INCLUDE_DIR harfbuzz/hb.h
HINTS
${_harfbuzz_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(LIBHARFBUZZ_LIBRARY
NAMES
harfbuzz
HINTS
${_harfbuzz_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set HARFBUZZ_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Harfbuzz DEFAULT_MSG
LIBHARFBUZZ_LIBRARY LIBHARFBUZZ_INCLUDE_DIR)
if(HARFBUZZ_FOUND)
set(LIBHARFBUZZ_LIBRARIES ${LIBHARFBUZZ_LIBRARY})
set(LIBHARFBUZZ_INCLUDE_DIRS ${LIBHARFBUZZ_INCLUDE_DIR})
endif()
mark_as_advanced(
LIBHARFBUZZ_INCLUDE_DIR
LIBHARFBUZZ_LIBRARY
)
unset(_harfbuzz_SEARCH_DIRS)

View File

@@ -0,0 +1,67 @@
# SPDX-FileCopyrightText: 2021 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find HARU library
# Find the native Haru includes and library
# This module defines
# HARU_INCLUDE_DIRS, where to find hpdf.h, set when
# HARU_INCLUDE_DIR is found.
# HARU_LIBRARIES, libraries to link against to use Haru.
# HARU_ROOT_DIR, The base directory to search for Haru.
# This can also be an environment variable.
# HARU_FOUND, If false, do not try to use Haru.
#
# also defined, but not for general use are
# HARU_LIBRARY, where to find the Haru library.
# If `HARU_ROOT_DIR` was defined in the environment, use it.
if(DEFINED HARU_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{HARU_ROOT_DIR})
set(HARU_ROOT_DIR $ENV{HARU_ROOT_DIR})
else()
set(HARU_ROOT_DIR "")
endif()
set(_haru_SEARCH_DIRS
${HARU_ROOT_DIR}
/opt/lib/haru
)
find_path(HARU_INCLUDE_DIR
NAMES
hpdf.h
HINTS
${_haru_SEARCH_DIRS}
PATH_SUFFIXES
include/haru
include
)
find_library(HARU_LIBRARY
NAMES
hpdfs
hpdf
HINTS
${_haru_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# Handle the QUIETLY and REQUIRED arguments and set HARU_FOUND to TRUE if
# all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Haru DEFAULT_MSG HARU_LIBRARY HARU_INCLUDE_DIR)
if(HARU_FOUND)
set(HARU_LIBRARIES ${HARU_LIBRARY})
set(HARU_INCLUDE_DIRS ${HARU_INCLUDE_DIR})
endif()
mark_as_advanced(
HARU_INCLUDE_DIR
HARU_LIBRARY
)
unset(_haru_SEARCH_DIRS)

View File

@@ -0,0 +1,141 @@
# SPDX-FileCopyrightText: 2012 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find static icu libraries
# Find the native static icu libraries (needed for static boost_locale :/ ).
# This module defines
# ICU_LIBRARIES, libraries to link against to use icu.
# ICU_ROOT_DIR, The base directory to search for icu.
# This can also be an environment variable.
# ICU_FOUND, If false, do not try to use icu.
#
# also defined, but not for general use are
# ICU_LIBRARY_xxx, where to find the icu libraries.
# If `ICU_ROOT_DIR` was defined in the environment, use it.
if(DEFINED ICU_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{ICU_ROOT_DIR})
set(ICU_ROOT_DIR $ENV{ICU_ROOT_DIR})
else()
set(ICU_ROOT_DIR "")
endif()
if(Boost_USE_STATIC_LIBS)
set(_icu_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
set(_icu_SEARCH_DIRS
${ICU_ROOT_DIR}
)
# We don't need includes, only libs to link against...
# find_path(ICU_INCLUDE_DIR
# NAMES
# utf.h
# HINTS
# ${_icu_SEARCH_DIRS}
# PATH_SUFFIXES
# include/unicode
# )
find_library(ICU_LIBRARY_DATA
NAMES
icudata
HINTS
${_icu_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(ICU_LIBRARY_I18N
NAMES
icui18n
HINTS
${_icu_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(ICU_LIBRARY_IO
NAMES
icuio
HINTS
${_icu_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(ICU_LIBRARY_LE
NAMES
icule
HINTS
${_icu_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(ICU_LIBRARY_LX
NAMES
iculx
HINTS
${_icu_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(ICU_LIBRARY_TU
NAMES
icutu
HINTS
${_icu_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_library(ICU_LIBRARY_UC
NAMES
icuuc
HINTS
${_icu_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# Restore the original find library ordering
if(Boost_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_icu_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
# handle the QUIETLY and REQUIRED arguments and set ICU_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Icu DEFAULT_MSG
ICU_LIBRARY_DATA
ICU_LIBRARY_I18N
ICU_LIBRARY_IO
ICU_LIBRARY_LE
ICU_LIBRARY_LX
ICU_LIBRARY_TU
ICU_LIBRARY_UC
)
if(ICU_FOUND)
set(ICU_LIBRARIES ${ICU_LIBRARY_DATA} ${ICU_LIBRARY_I18N} ${ICU_LIBRARY_IO} ${ICU_LIBRARY_LE} ${ICU_LIBRARY_LX} ${ICU_LIBRARY_TU} ${ICU_LIBRARY_UC})
set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
endif()
mark_as_advanced(
ICU_INCLUDE_DIR
ICU_LIBRARY_DATA
ICU_LIBRARY_I18N
ICU_LIBRARY_IO
ICU_LIBRARY_LE
ICU_LIBRARY_LX
ICU_LIBRARY_TU
ICU_LIBRARY_UC
)
unset(_icu_SEARCH_DIRS)

View File

@@ -0,0 +1,65 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find JACK library
# Find the native JACK includes and library
# This module defines
# JACK_INCLUDE_DIRS, where to find jack.h, Set when
# JACK_INCLUDE_DIR is found.
# JACK_LIBRARIES, libraries to link against to use JACK.
# JACK_ROOT_DIR, The base directory to search for JACK.
# This can also be an environment variable.
# JACK_FOUND, If false, do not try to use JACK.
#
# also defined, but not for general use are
# JACK_LIBRARY, where to find the JACK library.
# If `JACK_ROOT_DIR` was defined in the environment, use it.
if(DEFINED JACK_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{JACK_ROOT_DIR})
set(JACK_ROOT_DIR $ENV{JACK_ROOT_DIR})
else()
set(JACK_ROOT_DIR "")
endif()
set(_jack_SEARCH_DIRS
${JACK_ROOT_DIR}
)
find_path(JACK_INCLUDE_DIR
NAMES
jack.h
HINTS
${_jack_SEARCH_DIRS}
PATH_SUFFIXES
include/jack
)
find_library(JACK_LIBRARY
NAMES
jack
HINTS
${_jack_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set JACK_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Jack DEFAULT_MSG
JACK_LIBRARY JACK_INCLUDE_DIR)
if(JACK_FOUND)
set(JACK_LIBRARIES ${JACK_LIBRARY})
set(JACK_INCLUDE_DIRS ${JACK_INCLUDE_DIR})
endif()
mark_as_advanced(
JACK_INCLUDE_DIR
JACK_LIBRARY
)
unset(_jack_SEARCH_DIRS)

View File

@@ -0,0 +1,92 @@
# SPDX-FileCopyrightText: 2015 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find LLVM library
# Find the native LLVM includes and library
# This module defines
# LLVM_INCLUDE_DIRS, where to find LLVM.h, Set when LLVM_INCLUDE_DIR is found.
# LLVM_LIBRARIES, libraries to link against to use LLVM.
# LLVM_ROOT_DIR, The base directory to search for LLVM.
# This can also be an environment variable.
# LLVM_FOUND, If false, do not try to use LLVM.
#
# also defined, but not for general use are
# LLVM_LIBRARY, where to find the LLVM library.
if(LLVM_ROOT_DIR)
if(DEFINED LLVM_VERSION)
find_program(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS ${LLVM_ROOT_DIR}/bin NO_CMAKE_PATH)
endif()
if(NOT LLVM_CONFIG)
find_program(LLVM_CONFIG llvm-config HINTS ${LLVM_ROOT_DIR}/bin NO_CMAKE_PATH)
endif()
else()
if(DEFINED LLVM_VERSION)
message(STATUS "Running llvm-config-${LLVM_VERSION}")
find_program(LLVM_CONFIG llvm-config-${LLVM_VERSION})
endif()
if(NOT LLVM_CONFIG)
find_program(LLVM_CONFIG llvm-config)
endif()
endif()
execute_process(COMMAND ${LLVM_CONFIG} --includedir
OUTPUT_VARIABLE LLVM_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT DEFINED LLVM_VERSION)
execute_process(COMMAND ${LLVM_CONFIG} --version
OUTPUT_VARIABLE LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_VERSION ${LLVM_VERSION} CACHE STRING "Version of LLVM to use")
endif()
if(NOT LLVM_ROOT_DIR)
execute_process(COMMAND ${LLVM_CONFIG} --prefix
OUTPUT_VARIABLE LLVM_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_ROOT_DIR ${LLVM_ROOT_DIR} CACHE PATH "Path to the LLVM installation")
endif()
if(NOT LLVM_LIBPATH)
execute_process(COMMAND ${LLVM_CONFIG} --libdir
OUTPUT_VARIABLE LLVM_LIBPATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LLVM_LIBPATH ${LLVM_LIBPATH} CACHE PATH "Path to the LLVM library path")
mark_as_advanced(LLVM_LIBPATH)
endif()
if(LLVM_STATIC)
find_library(LLVM_LIBRARY
NAMES LLVMAnalysis # first of a whole bunch of libs to get
PATHS ${LLVM_LIBPATH})
else()
find_library(LLVM_LIBRARY
NAMES
LLVM-${LLVM_VERSION}
LLVMAnalysis # check for the static library as a fall-back
PATHS ${LLVM_LIBPATH})
endif()
if(LLVM_LIBRARY AND LLVM_ROOT_DIR AND LLVM_LIBPATH)
if(LLVM_STATIC)
# if static LLVM libraries were requested, use llvm-config to generate
# the list of what libraries we need, and substitute that in the right
# way for LLVM_LIBRARY.
execute_process(COMMAND ${LLVM_CONFIG} --libfiles
OUTPUT_VARIABLE LLVM_LIBRARY
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE " " ";" LLVM_LIBRARY "${LLVM_LIBRARY}")
endif()
endif()
# handle the QUIETLY and REQUIRED arguments and set LLVM_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LLVM DEFAULT_MSG
LLVM_LIBRARY)
mark_as_advanced(
LLVM_LIBRARY
)

View File

@@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2015 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find LZO library
# Find the native LZO includes and library
# This module defines
# LZO_INCLUDE_DIRS, where to find lzo1x.h, Set when
# LZO_INCLUDE_DIR is found.
# LZO_LIBRARIES, libraries to link against to use LZO.
# LZO_ROOT_DIR, The base directory to search for LZO.
# This can also be an environment variable.
# LZO_FOUND, If false, do not try to use LZO.
#
# also defined, but not for general use are
# LZO_LIBRARY, where to find the LZO library.
# If `LZO_ROOT_DIR` was defined in the environment, use it.
if(DEFINED LZO_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{LZO_ROOT_DIR})
set(LZO_ROOT_DIR $ENV{LZO_ROOT_DIR})
else()
set(LZO_ROOT_DIR "")
endif()
set(_lzo_SEARCH_DIRS
${LZO_ROOT_DIR}
)
find_path(LZO_INCLUDE_DIR lzo/lzo1x.h
HINTS
${_lzo_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(LZO_LIBRARY
NAMES
lzo2
HINTS
${_lzo_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set LZO_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZO DEFAULT_MSG
LZO_LIBRARY LZO_INCLUDE_DIR)
if(LZO_FOUND)
set(LZO_LIBRARIES ${LZO_LIBRARY})
set(LZO_INCLUDE_DIRS ${LZO_INCLUDE_DIR})
endif()
mark_as_advanced(
LZO_INCLUDE_DIR
LZO_LIBRARY
)
unset(_lzo_SEARCH_DIRS)

View File

@@ -0,0 +1,64 @@
# SPDX-FileCopyrightText: 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Level Zero library
# Find Level Zero headers and libraries needed by oneAPI implementation
# This module defines
# LEVEL_ZERO_LIBRARY, libraries to link against in order to use L0.
# LEVEL_ZERO_INCLUDE_DIR, directories where L0 headers can be found.
# LEVEL_ZERO_ROOT_DIR, The base directory to search for L0 files.
# This can also be an environment variable.
# LEVEL_ZERO_FOUND, If false, then don't try to use L0.
# If `LEVEL_ZERO_ROOT_DIR` was defined in the environment, use it.
if(DEFINED LEVEL_ZERO_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{LEVEL_ZERO_ROOT_DIR})
set(LEVEL_ZERO_ROOT_DIR $ENV{LEVEL_ZERO_ROOT_DIR})
else()
set(LEVEL_ZERO_ROOT_DIR "")
endif()
set(_level_zero_SEARCH_DIRS
${LEVEL_ZERO_ROOT_DIR}
/usr/lib
/usr/local/lib
)
find_library(LEVEL_ZERO_LIBRARY
NAMES
ze_loader
HINTS
${_level_zero_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
find_path(LEVEL_ZERO_INCLUDE_DIR
NAMES
level_zero/ze_api.h
HINTS
${_level_zero_SEARCH_DIRS}
PATH_SUFFIXES
include
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LevelZero DEFAULT_MSG LEVEL_ZERO_LIBRARY LEVEL_ZERO_INCLUDE_DIR)
if(LevelZero_FOUND)
set(LEVEL_ZERO_FOUND TRUE)
else()
unset(LEVEL_ZERO_LIBRARY)
unset(LEVEL_ZERO_INCLUDE_DIR)
set(LEVEL_ZERO_FOUND FALSE)
endif()
mark_as_advanced(
LEVEL_ZERO_LIBRARY
LEVEL_ZERO_INCLUDE_DIR
)
unset(_level_zero_SEARCH_DIRS)

View File

@@ -0,0 +1,48 @@
# SPDX-FileCopyrightText: 2022 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# This module defines
# LIBEPOXY_INCLUDE_DIRS, where to find epoxy/gl.h
# LIBEPOXY_LIBRARIES, where to find the epoxy library.
# LIBEPOXY_ROOT_DIR, The base directory to search for libepoxy.
# This can also be an environment variable.
# LIBEPOXY_FOUND, If false, do not try to use libepoxy.
if(NOT EPOXY_ROOT_DIR AND NOT $ENV{EPOXY_ROOT_DIR} STREQUAL "")
set(EPOXY_ROOT_DIR $ENV{EPOXY_ROOT_DIR})
endif()
find_path(LIBEPOXY_INCLUDE_DIR
NAMES
epoxy/gl.h
HINTS
${EPOXY_ROOT_DIR}
PATH_SUFFIXES
include
)
find_library(LIBEPOXY_LIBRARY
NAMES
epoxy
HINTS
${EPOXY_ROOT_DIR}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set LIBEPOXY_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibEpoxy DEFAULT_MSG
LIBEPOXY_LIBRARY LIBEPOXY_INCLUDE_DIR)
if(LIBEPOXY_FOUND)
set(LIBEPOXY_INCLUDE_DIRS ${LIBEPOXY_INCLUDE_DIR})
set(LIBEPOXY_LIBRARIES ${LIBEPOXY_LIBRARY})
endif()
mark_as_advanced(
LIBEPOXY_INCLUDE_DIR
LIBEPOXY_LIBRARY
)

View File

@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: 2020 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find NanoVDB library
# Find the native NanoVDB includes and library
# This module defines
# NANOVDB_INCLUDE_DIRS, where to find nanovdb.h, Set when
# NANOVDB_INCLUDE_DIR is found.
# NANOVDB_ROOT_DIR, The base directory to search for NanoVDB.
# This can also be an environment variable.
# NANOVDB_FOUND, If false, do not try to use NanoVDB.
# If `NANOVDB_ROOT_DIR` was defined in the environment, use it.
if(DEFINED NANOVDB_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{NANOVDB_ROOT_DIR})
set(NANOVDB_ROOT_DIR $ENV{NANOVDB_ROOT_DIR})
else()
set(NANOVDB_ROOT_DIR "")
endif()
set(_nanovdb_SEARCH_DIRS
${NANOVDB_ROOT_DIR}
)
find_path(NANOVDB_INCLUDE_DIR
NAMES
nanovdb/NanoVDB.h
HINTS
${_nanovdb_SEARCH_DIRS}
PATH_SUFFIXES
include
)
# handle the QUIETLY and REQUIRED arguments and set NANOVDB_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NanoVDB DEFAULT_MSG
NANOVDB_INCLUDE_DIR)
if(NANOVDB_FOUND)
set(NANOVDB_INCLUDE_DIRS ${NANOVDB_INCLUDE_DIR})
endif()
mark_as_advanced(
NANOVDB_INCLUDE_DIR
)
unset(_nanovdb_SEARCH_DIRS)

View File

@@ -0,0 +1,128 @@
# SPDX-FileCopyrightText: 2019 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find OpenImageDenoise library
# Find the native OpenImageDenoise includes and library
# This module defines
# OPENIMAGEDENOISE_INCLUDE_DIRS, where to find oidn.h, Set when
# OPENIMAGEDENOISE is found.
# OPENIMAGEDENOISE_LIBRARIES, libraries to link against to use OpenImageDenoise.
# OPENIMAGEDENOISE_ROOT_DIR, The base directory to search for OpenImageDenoise.
# This can also be an environment variable.
# OPENIMAGEDENOISE_FOUND, If false, do not try to use OpenImageDenoise.
#
# also defined, but not for general use are
# OPENIMAGEDENOISE_LIBRARY, where to find the OpenImageDenoise library.
# If `OPENIMAGEDENOISE_ROOT_DIR` was defined in the environment, use it.
if(DEFINED OPENIMAGEDENOISE_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{OPENIMAGEDENOISE_ROOT_DIR})
set(OPENIMAGEDENOISE_ROOT_DIR $ENV{OPENIMAGEDENOISE_ROOT_DIR})
else()
set(OPENIMAGEDENOISE_ROOT_DIR "")
endif()
set(_openimagedenoise_SEARCH_DIRS
${OPENIMAGEDENOISE_ROOT_DIR}
/opt/lib/openimagedenoise
)
find_path(OPENIMAGEDENOISE_INCLUDE_DIR
NAMES
OpenImageDenoise/oidn.h
HINTS
${_openimagedenoise_SEARCH_DIRS}
PATH_SUFFIXES
include
)
set(_openimagedenoise_FIND_COMPONENTS
OpenImageDenoise
)
# These are needed when building statically
set(_openimagedenoise_FIND_STATIC_COMPONENTS
common
# These additional library names change between versions, we list all of them
# so builds work with multiple versions. Missing libraries are skipped.
dnnl_cpu
dnnl_common
dnnl_cpu # Second time because of circular dependency
mkldnn
dnnl
)
set(_openimagedenoise_LIBRARIES "")
foreach(COMPONENT ${_openimagedenoise_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
find_library(OPENIMAGEDENOISE_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${_openimagedenoise_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
list(APPEND _openimagedenoise_LIBRARIES "${OPENIMAGEDENOISE_${UPPERCOMPONENT}_LIBRARY}")
endforeach()
foreach(COMPONENT ${_openimagedenoise_FIND_STATIC_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
find_library(OPENIMAGEDENOISE_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${_openimagedenoise_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
mark_as_advanced(OPENIMAGEDENOISE_${UPPERCOMPONENT}_LIBRARY)
if(OPENIMAGEDENOISE_${UPPERCOMPONENT}_LIBRARY)
list(APPEND _openimagedenoise_LIBRARIES "${OPENIMAGEDENOISE_${UPPERCOMPONENT}_LIBRARY}")
endif()
endforeach()
find_library(OPENIMAGEDENOISE_LIBRARY
NAMES
OpenImageDenoise
HINTS
${_openimagedenoise_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set OPENIMAGEDENOISE_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenImageDenoise DEFAULT_MSG
OPENIMAGEDENOISE_LIBRARY OPENIMAGEDENOISE_INCLUDE_DIR)
if(OPENIMAGEDENOISE_FOUND)
set(OPENIMAGEDENOISE_LIBRARIES ${_openimagedenoise_LIBRARIES})
set(OPENIMAGEDENOISE_INCLUDE_DIRS ${OPENIMAGEDENOISE_INCLUDE_DIR})
else()
set(OPENIMAGEDENOISE_FOUND FALSE)
endif()
mark_as_advanced(
OPENIMAGEDENOISE_INCLUDE_DIR
OPENIMAGEDENOISE_LIBRARY
)
foreach(COMPONENT ${_openimagedenoise_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
mark_as_advanced(OPENIMAGEDENOISE_${UPPERCOMPONENT}_LIBRARY)
endforeach()
unset(COMPONENT)
unset(UPPERCOMPONENT)
unset(_openimagedenoise_FIND_COMPONENTS)
unset(_openimagedenoise_FIND_STATIC_COMPONENTS)
unset(_openimagedenoise_LIBRARIES)
unset(_openimagedenoise_SEARCH_DIRS)

View File

@@ -0,0 +1,76 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find OpenJPEG library
# Find the native OpenJPEG includes and library
# This module defines
# OPENJPEG_INCLUDE_DIRS, where to find openjpeg.h, Set when
# OPENJPEG_INCLUDE_DIR is found.
# OPENJPEG_LIBRARIES, libraries to link against to use OpenJPEG.
# OPENJPEG_ROOT_DIR, The base directory to search for OpenJPEG.
# This can also be an environment variable.
# OPENJPEG_FOUND, If false, do not try to use OpenJPEG.
#
# also defined, but not for general use are
# OPENJPEG_LIBRARY, where to find the OpenJPEG library.
# If `OPENJPEG_ROOT_DIR` was defined in the environment, use it.
if(DEFINED OPENJPEG_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{OPENJPEG_ROOT_DIR})
set(OPENJPEG_ROOT_DIR $ENV{OPENJPEG_ROOT_DIR})
else()
set(OPENJPEG_ROOT_DIR "")
endif()
set(_openjpeg_SEARCH_DIRS
${OPENJPEG_ROOT_DIR}
)
find_path(OPENJPEG_INCLUDE_DIR
NAMES
openjpeg.h
HINTS
${_openjpeg_SEARCH_DIRS}
PATH_SUFFIXES
include
# Support future versions
openjpeg-2.9
openjpeg-2.8
openjpeg-2.7
openjpeg-2.6
openjpeg-2.5
openjpeg-2.4
openjpeg-2.3
openjpeg-2.2
openjpeg-2.1
openjpeg-2.0
)
find_library(OPENJPEG_LIBRARY
NAMES
openjp2
HINTS
${_openjpeg_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set OPENJPEG_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenJPEG DEFAULT_MSG
OPENJPEG_LIBRARY OPENJPEG_INCLUDE_DIR)
if(OPENJPEG_FOUND)
set(OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARY})
set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR})
endif()
mark_as_advanced(
OPENJPEG_INCLUDE_DIR
OPENJPEG_LIBRARY
)
unset(_openjpeg_SEARCH_DIRS)

View File

@@ -0,0 +1,96 @@
# SPDX-FileCopyrightText: 2013 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find OpenSubdiv library
# Find the native OpenSubdiv includes and library
# This module defines
# OPENSUBDIV_INCLUDE_DIRS, where to find OpenSubdiv headers, Set when
# OPENSUBDIV_INCLUDE_DIR is found.
# OPENSUBDIV_LIBRARIES, libraries to link against to use OpenSubdiv.
# OPENSUBDIV_ROOT_DIR, the base directory to search for OpenSubdiv.
# This can also be an environment variable.
# OPENSUBDIV_FOUND, if false, do not try to use OpenSubdiv.
# If `OPENSUBDIV_ROOT_DIR` was defined in the environment, use it.
if(DEFINED OPENSUBDIV_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{OPENSUBDIV_ROOT_DIR})
set(OPENSUBDIV_ROOT_DIR $ENV{OPENSUBDIV_ROOT_DIR})
else()
set(OPENSUBDIV_ROOT_DIR "")
endif()
set(_opensubdiv_FIND_COMPONENTS
osdGPU
osdCPU
)
set(_opensubdiv_SEARCH_DIRS
${OPENSUBDIV_ROOT_DIR}
/opt/lib/opensubdiv
/opt/lib/osd # install_deps.sh
)
find_path(OPENSUBDIV_INCLUDE_DIR
NAMES
opensubdiv/osd/mesh.h
HINTS
${_opensubdiv_SEARCH_DIRS}
PATH_SUFFIXES
include
)
set(_opensubdiv_LIBRARIES "")
foreach(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
find_library(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${_opensubdiv_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
list(APPEND _opensubdiv_LIBRARIES "${OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY}")
endforeach()
# Return values:
# - `${variable_name}`: `TRUE` if the controller include file exists.
function(OPENSUBDIV_CHECK_CONTROLLER
controller_include_file
variable_name)
if(EXISTS "${OPENSUBDIV_INCLUDE_DIR}/opensubdiv/osd/${controller_include_file}")
set(${variable_name} TRUE PARENT_SCOPE)
else()
set(${variable_name} FALSE PARENT_SCOPE)
endif()
endfunction()
# handle the QUIETLY and REQUIRED arguments and set OPENSUBDIV_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenSubdiv DEFAULT_MSG
_opensubdiv_LIBRARIES OPENSUBDIV_INCLUDE_DIR)
if(OPENSUBDIV_FOUND)
set(OPENSUBDIV_LIBRARIES ${_opensubdiv_LIBRARIES})
set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR})
endif()
mark_as_advanced(
OPENSUBDIV_INCLUDE_DIR
)
foreach(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
mark_as_advanced(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY)
endforeach()
unset(COMPONENT)
unset(UPPERCOMPONENT)
unset(_opensubdiv_FIND_COMPONENTS)
unset(_opensubdiv_SEARCH_DIRS)
unset(_opensubdiv_LIBRARIES)

View File

@@ -0,0 +1,66 @@
# SPDX-FileCopyrightText: 2015 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find OPENVDB library
# Find the native OPENVDB includes and library
# This module defines
# OPENVDB_INCLUDE_DIRS, where to find openvdb.h, Set when
# OPENVDB_INCLUDE_DIR is found.
# OPENVDB_LIBRARIES, libraries to link against to use OPENVDB.
# OPENVDB_ROOT_DIR, The base directory to search for OPENVDB.
# This can also be an environment variable.
# OPENVDB_FOUND, If false, do not try to use OPENVDB.
#
# also defined, but not for general use are
# OPENVDB_LIBRARY, where to find the OPENVDB library.
# If `OPENVDB_ROOT_DIR` was defined in the environment, use it.
if(DEFINED OPENVDB_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{OPENVDB_ROOT_DIR})
set(OPENVDB_ROOT_DIR $ENV{OPENVDB_ROOT_DIR})
else()
set(OPENVDB_ROOT_DIR "")
endif()
set(_openvdb_SEARCH_DIRS
${OPENVDB_ROOT_DIR}
/opt/lib/openvdb
)
find_path(OPENVDB_INCLUDE_DIR
NAMES
openvdb/openvdb.h
HINTS
${_openvdb_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(OPENVDB_LIBRARY
NAMES
openvdb
HINTS
${_openvdb_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set OPENVDB_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenVDB DEFAULT_MSG
OPENVDB_LIBRARY OPENVDB_INCLUDE_DIR)
if(OPENVDB_FOUND)
set(OPENVDB_LIBRARIES ${OPENVDB_LIBRARY})
set(OPENVDB_INCLUDE_DIRS ${OPENVDB_INCLUDE_DIR})
endif()
mark_as_advanced(
OPENVDB_INCLUDE_DIR
OPENVDB_LIBRARY
)
unset(_openvdb_SEARCH_DIRS)

View File

@@ -0,0 +1,65 @@
# SPDX-FileCopyrightText: 2019 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find OptiX library
# Find the native OptiX includes and library
# This module defines
# OPTIX_INCLUDE_DIRS, where to find optix.h, Set when
# OPTIX_INCLUDE_DIR is found.
# OPTIX_ROOT_DIR, The base directory to search for OptiX.
# This can also be an environment variable.
# OPTIX_FOUND, If false, do not try to use OptiX.
if(NOT (DEFINED OPTIX_ROOT_DIR))
set(OPTIX_ROOT_DIR "")
endif()
# If `OPTIX_ROOT_DIR` was defined in the environment, use it.
if(OPTIX_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{OPTIX_ROOT_DIR})
set(OPTIX_ROOT_DIR $ENV{OPTIX_ROOT_DIR})
endif()
set(_optix_SEARCH_DIRS
${OPTIX_ROOT_DIR}
)
find_path(OPTIX_INCLUDE_DIR
NAMES
optix.h
HINTS
${_optix_SEARCH_DIRS}
PATH_SUFFIXES
include
)
if(EXISTS "${OPTIX_INCLUDE_DIR}/optix.h")
file(STRINGS "${OPTIX_INCLUDE_DIR}/optix.h" _optix_version REGEX "^#define OPTIX_VERSION[ \t].*$")
string(REGEX MATCHALL "[0-9]+" _optix_version ${_optix_version})
math(EXPR _optix_version_major "${_optix_version} / 10000")
math(EXPR _optix_version_minor "(${_optix_version} % 10000) / 100")
math(EXPR _optix_version_patch "${_optix_version} % 100")
set(OPTIX_VERSION "${_optix_version_major}.${_optix_version_minor}.${_optix_version_patch}")
endif()
# handle the QUIETLY and REQUIRED arguments and set OPTIX_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OptiX
REQUIRED_VARS OPTIX_INCLUDE_DIR
VERSION_VAR OPTIX_VERSION)
if(OPTIX_FOUND)
set(OPTIX_INCLUDE_DIRS ${OPTIX_INCLUDE_DIR})
endif()
mark_as_advanced(
OPTIX_INCLUDE_DIR
OPTIX_VERSION
)
unset(_optix_SEARCH_DIRS)

View File

@@ -0,0 +1,68 @@
# SPDX-FileCopyrightText: 2020 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find potrace library
# Find the potrace include and library
# This module defines
# POTRACE_INCLUDE_DIRS, where to find potracelib.h, Set when
# POTRACE is found.
# POTRACE_LIBRARIES, libraries to link against to use POTRACE.
# POTRACE_ROOT_DIR, The base directory to search for POTRACE.
# This can also be an environment variable.
# POTRACE_FOUND, If false, do not try to use POTRACE.
#
# also defined, but not for general use are
# POTRACE_LIBRARY, where to find the POTRACE library.
# If `POTRACE_ROOT_DIR` was defined in the environment, use it.
if(DEFINED POTRACE_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{POTRACE_ROOT_DIR})
set(POTRACE_ROOT_DIR $ENV{POTRACE_ROOT_DIR})
else()
set(POTRACE_ROOT_DIR "")
endif()
set(_potrace_SEARCH_DIRS
${POTRACE_ROOT_DIR}
/opt/lib/potrace
/usr/include
/usr/local/include
)
find_path(POTRACE_INCLUDE_DIR
NAMES
potracelib.h
HINTS
${_potrace_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(POTRACE_LIBRARY
NAMES
potrace
HINTS
${_potrace_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set POTRACE_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Potrace DEFAULT_MSG
POTRACE_LIBRARY POTRACE_INCLUDE_DIR)
if(POTRACE_FOUND)
set(POTRACE_LIBRARIES ${POTRACE_LIBRARY})
set(POTRACE_INCLUDE_DIRS ${POTRACE_INCLUDE_DIR})
endif()
mark_as_advanced(
POTRACE_INCLUDE_DIR
POTRACE_LIBRARY
)
unset(_potrace_SEARCH_DIRS)

View File

@@ -0,0 +1,68 @@
# SPDX-FileCopyrightText: 2014 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find PugiXML library
# Find the native PugiXML includes and library
# This module defines
# PUGIXML_INCLUDE_DIRS, where to find pugixml.hpp, Set when
# PugiXML is found.
# PUGIXML_LIBRARIES, libraries to link against to use PugiXML.
# PUGIXML_ROOT_DIR, The base directory to search for PugiXML.
# This can also be an environment variable.
# PUGIXML_FOUND, If false, do not try to use PugiXML.
#
# also defined, but not for general use are
# PUGIXML_LIBRARY, where to find the PugiXML library.
# If `PUGIXML_ROOT_DIR` was defined in the environment, use it.
if(DEFINED PUGIXML_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{PUGIXML_ROOT_DIR})
set(PUGIXML_ROOT_DIR $ENV{PUGIXML_ROOT_DIR})
else()
set(PUGIXML_ROOT_DIR "")
endif()
set(_pugixml_SEARCH_DIRS
${PUGIXML_ROOT_DIR}
/opt/lib/oiio
)
find_path(PUGIXML_INCLUDE_DIR
NAMES
pugixml.hpp
HINTS
${_pugixml_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(PUGIXML_LIBRARY
NAMES
pugixml
HINTS
${_pugixml_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set PUGIXML_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PugiXML DEFAULT_MSG
PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)
if(PUGIXML_FOUND)
set(PUGIXML_LIBRARIES ${PUGIXML_LIBRARY})
set(PUGIXML_INCLUDE_DIRS ${PUGIXML_INCLUDE_DIR})
else()
set(PUGIXML_FOUND FALSE)
endif()
mark_as_advanced(
PUGIXML_INCLUDE_DIR
PUGIXML_LIBRARY
)
unset(_pugixml_SEARCH_DIRS)

View File

@@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2021 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find PulseAudio library
# Find the native PulseAudio includes and library
# This module defines
# LIBPULSE_INCLUDE_DIRS, where to find pulse/pulseaudio.h, Set when
# LIBPULSE_INCLUDE_DIR is found.
# LIBPULSE_LIBRARIES, libraries to link against to use PulseAudio.
# LIBPULSE_ROOT_DIR, The base directory to search for PulseAudio.
# This can also be an environment variable.
# PULSE_FOUND, If false, do not try to use PulseAudio.
#
# also defined, but not for general use are
# LIBPULSE_LIBRARY, where to find the PulseAudio library.
# If `LIBPULSE_ROOT_DIR` was defined in the environment, use it.
if(DEFINED LIBPULSE_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{LIBPULSE_ROOT_DIR})
set(LIBPULSE_ROOT_DIR $ENV{LIBPULSE_ROOT_DIR})
else()
set(LIBPULSE_ROOT_DIR "")
endif()
set(_pulse_SEARCH_DIRS
${LIBPULSE_ROOT_DIR}
)
find_path(LIBPULSE_INCLUDE_DIR pulse/pulseaudio.h
HINTS
${_pulse_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(LIBPULSE_LIBRARY
NAMES
pulse
HINTS
${_pulse_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set PULSE_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Pulse DEFAULT_MSG
LIBPULSE_LIBRARY LIBPULSE_INCLUDE_DIR)
if(PULSE_FOUND)
set(LIBPULSE_LIBRARIES ${LIBPULSE_LIBRARY})
set(LIBPULSE_INCLUDE_DIRS ${LIBPULSE_INCLUDE_DIR})
endif()
mark_as_advanced(
LIBPULSE_INCLUDE_DIR
LIBPULSE_LIBRARY
)
unset(_pulse_SEARCH_DIRS)

View File

@@ -0,0 +1,297 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Python libraries
# Find the native Python includes and library
#
# Note:, This is not _yet_ intended to be a general python module for other
# projects to use since its hard coded to fixed Python version
# as Blender only supports a single Python version at the moment.
#
# Note:
# this is for Blender/Unix Python only.
#
# This module defines
# PYTHON_VERSION
# PYTHON_VERSION_NO_DOTS
# PYTHON_INCLUDE_DIRS
# PYTHON_INCLUDE_CONFIG_DIR
# PYTHON_LIBRARIES
# PYTHON_LIBPATH, Used for installation
# PYTHON_SITE_PACKAGES, Used for installation (as a Python module)
# PYTHON_LINKFLAGS
# PYTHON_ROOT_DIR, The base directory to search for Python.
# This can also be an environment variable.
#
# also defined, but not for general use are
# PYTHON_LIBRARY, where to find the python library.
# If `PYTHON_ROOT_DIR` was defined in the environment, use it.
if(DEFINED PYTHON_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{PYTHON_ROOT_DIR})
set(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR})
else()
set(PYTHON_ROOT_DIR "")
endif()
set(_PYTHON_VERSION_SUPPORTED 3.13)
set(PYTHON_VERSION ${_PYTHON_VERSION_SUPPORTED} CACHE STRING "Python Version (major and minor only)")
mark_as_advanced(PYTHON_VERSION)
if(APPLE)
if(WITH_PYTHON_MODULE)
set(PYTHON_LINKFLAGS "-undefined dynamic_lookup")
else()
set(PYTHON_LINKFLAGS "")
endif()
else()
# See: http://docs.python.org/extending/embedding.html#linking-requirements
set(PYTHON_LINKFLAGS "-Xlinker -export-dynamic" CACHE STRING "Linker flags for python")
mark_as_advanced(PYTHON_LINKFLAGS)
endif()
# if the user passes these defines as args, we don't want to overwrite
set(_IS_INC_DEF OFF)
set(_IS_INC_CONF_DEF OFF)
set(_IS_LIB_DEF OFF)
set(_IS_LIB_PATH_DEF OFF)
if(DEFINED PYTHON_INCLUDE_DIR)
set(_IS_INC_DEF ON)
endif()
if(DEFINED PYTHON_INCLUDE_CONFIG_DIR)
set(_IS_INC_CONF_DEF ON)
endif()
if(DEFINED PYTHON_LIBRARY)
set(_IS_LIB_DEF ON)
endif()
if(DEFINED PYTHON_LIBPATH)
set(_IS_LIB_PATH_DEF ON)
endif()
string(REPLACE "." "" PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
set(_PYTHON_ABI_FLAGS "")
set(_python_SEARCH_DIRS
${PYTHON_ROOT_DIR}
"$ENV{HOME}/py${PYTHON_VERSION_NO_DOTS}"
"/opt/lib/python-${PYTHON_VERSION}"
)
# only search for the dirs if we haven't already
if((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_LIB_PATH_DEF))
# When PYTHON_ROOT_DIR is set, remove matching paths from CMAKE_IGNORE_PATH
# so system Python installations (e.g. /usr) can be found.
if(PYTHON_ROOT_DIR AND CMAKE_IGNORE_PATH)
set(_cmake_ignore_path_backup ${CMAKE_IGNORE_PATH})
# Strip trailing slash and match with "/" suffix to avoid
# false matches (e.g. "/usr" matching "/usrfoo").
string(REGEX REPLACE "/$" "" _python_root_rstrip_slash "${PYTHON_ROOT_DIR}")
list(FILTER CMAKE_IGNORE_PATH EXCLUDE REGEX "^${_python_root_rstrip_slash}/")
unset(_python_root_rstrip_slash)
endif()
set(_PYTHON_ABI_FLAGS_TEST
"u; " # release
"du;d" # debug
)
foreach(_CURRENT_ABI_FLAGS ${_PYTHON_ABI_FLAGS_TEST})
# if(CMAKE_BUILD_TYPE STREQUAL Debug)
# set(_CURRENT_ABI_FLAGS "d${_CURRENT_ABI_FLAGS}")
# endif()
string(REPLACE " " "" _CURRENT_ABI_FLAGS ${_CURRENT_ABI_FLAGS})
set(_python_INCLUDE_PATH_SUFFIXES
include/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
)
if(DEFINED CMAKE_LIBRARY_ARCHITECTURE)
if(CMAKE_LIBRARY_ARCHITECTURE)
list(APPEND _python_INCLUDE_PATH_SUFFIXES
include/${CMAKE_LIBRARY_ARCHITECTURE}/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
)
endif()
endif()
if(NOT DEFINED PYTHON_INCLUDE_DIR)
find_path(PYTHON_INCLUDE_DIR
NAMES
Python.h
HINTS
${_python_SEARCH_DIRS}
PATH_SUFFIXES
${_python_INCLUDE_PATH_SUFFIXES}
)
endif()
if(NOT DEFINED PYTHON_INCLUDE_CONFIG_DIR)
find_path(PYTHON_INCLUDE_CONFIG_DIR
NAMES
pyconfig.h
HINTS
${_python_SEARCH_DIRS}
PATH_SUFFIXES
${_python_INCLUDE_PATH_SUFFIXES}
)
if((NOT PYTHON_INCLUDE_CONFIG_DIR) AND PYTHON_INCLUDE_DIR)
# Fallback...
unset(PYTHON_INCLUDE_CONFIG_DIR CACHE)
set(PYTHON_INCLUDE_CONFIG_DIR ${PYTHON_INCLUDE_DIR} CACHE PATH "")
endif()
endif()
if(NOT DEFINED PYTHON_LIBRARY)
find_library(PYTHON_LIBRARY
NAMES
"python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}"
HINTS
${_python_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
endif()
if(NOT DEFINED PYTHON_LIBPATH)
find_path(PYTHON_LIBPATH
NAMES
"python${PYTHON_VERSION}/abc.py" # This is a bit hackish! :/
HINTS
${_python_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
if((NOT PYTHON_LIBPATH) AND PYTHON_LIBRARY)
# Fallback...
unset(PYTHON_LIBPATH CACHE)
get_filename_component(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
endif()
endif()
if(PYTHON_LIBRARY AND PYTHON_LIBPATH AND PYTHON_INCLUDE_DIR AND PYTHON_INCLUDE_CONFIG_DIR)
set(_PYTHON_ABI_FLAGS "${_CURRENT_ABI_FLAGS}")
break()
else()
# ensure we don't find values from 2 different ABI versions
if(NOT _IS_INC_DEF)
unset(PYTHON_INCLUDE_DIR CACHE)
endif()
if(NOT _IS_INC_CONF_DEF)
unset(PYTHON_INCLUDE_CONFIG_DIR CACHE)
endif()
if(NOT _IS_LIB_DEF)
unset(PYTHON_LIBRARY CACHE)
endif()
if(NOT _IS_LIB_PATH_DEF)
unset(PYTHON_LIBPATH CACHE)
endif()
endif()
endforeach()
unset(_CURRENT_ABI_FLAGS)
unset(_CURRENT_PATH)
unset(_python_INCLUDE_PATH_SUFFIXES)
unset(_PYTHON_ABI_FLAGS_TEST)
# Restore CMAKE_IGNORE_PATH if it was modified.
if(DEFINED _cmake_ignore_path_backup)
set(CMAKE_IGNORE_PATH ${_cmake_ignore_path_backup})
unset(_cmake_ignore_path_backup)
endif()
endif()
unset(_IS_INC_DEF)
unset(_IS_INC_CONF_DEF)
unset(_IS_LIB_DEF)
unset(_IS_LIB_PATH_DEF)
# handle the QUIETLY and REQUIRED arguments and SET PYTHONLIBSUNIX_FOUND to TRUE IF
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
# NOTE(@ideasman42): Instead of `DEFAULT_MSG` use a custom message because users
# may have newer versions Python and not be using pre-compiled libraries
# (on other UNIX systems or using an esoteric architecture).
# Some Python developers might want to use the newer features of Python too.
# While we could automatically detect and use newer versions but this would result in
# developers using a configuration which isn't officially supported without realizing it.
# So warn that the officially supported Python version is not found and let the developer
# explicitly set the newer version if they wish.
# From a maintenance perspective it's typically not a problem to support newer versions,
# doing so can help ease the process of upgrading too, nevertheless these versions don't
# have the same level of testing & support.
if(${_PYTHON_VERSION_SUPPORTED} STREQUAL ${PYTHON_VERSION})
# Default version.
set(_python_MISSING_MSG
"\
'PYTHON_VERSION=${_PYTHON_VERSION_SUPPORTED}' not found! \
This is the only officially supported version. \
If you wish to use a newer Python version you may set 'PYTHON_VERSION' \
however we do not guarantee full compatibility in this case."
)
else()
# Default version overridden, use a different message.
set(_python_MISSING_MSG
"\
'PYTHON_VERSION=${PYTHON_VERSION}' not found! \
This is *not* the officially supported version. \
Either configure 'PYTHON_ROOT_DIR' to point to the Python installation \
or use the officially supported version ('${_PYTHON_VERSION_SUPPORTED}') \
which may have pre-compiled binaries for your platform."
)
endif()
find_package_handle_standard_args(PythonLibsUnix
"${_python_MISSING_MSG}"
PYTHON_LIBRARY PYTHON_LIBPATH PYTHON_INCLUDE_DIR PYTHON_INCLUDE_CONFIG_DIR)
unset(_python_MISSING_MSG)
if(PYTHONLIBSUNIX_FOUND)
# Assign cache items
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR} ${PYTHON_INCLUDE_CONFIG_DIR})
if(NOT WITH_PYTHON_MODULE)
set(PYTHON_LIBRARIES ${PYTHON_LIBRARY})
endif()
find_file(PYTHON_SITE_PACKAGES
NAMES
# debian specific
dist-packages
site-packages
HINTS
${PYTHON_LIBPATH}/python${PYTHON_VERSION}
)
# we need this for installation
# XXX No more valid with debian-like py3.5 packages...
# get_filename_component(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
# not required for build, just used when bundling Python.
find_program(
PYTHON_EXECUTABLE
NAMES
"python${PYTHON_VERSION}${_PYTHON_ABI_FLAGS}"
"python${PYTHON_VERSION}"
"python"
HINTS
${_python_SEARCH_DIRS}
PATH_SUFFIXES bin
)
endif()
mark_as_advanced(
PYTHON_INCLUDE_DIR
PYTHON_INCLUDE_CONFIG_DIR
PYTHON_LIBRARY
PYTHON_LIBPATH
PYTHON_SITE_PACKAGES
PYTHON_EXECUTABLE
)
unset(_PYTHON_ABI_FLAGS)
unset(_PYTHON_VERSION_SUPPORTED)
unset(_python_SEARCH_DIRS)

View File

@@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2025 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Rubberband libraries
# Find the Rubberband includes and libraries
# This module defines
# RUBBERBAND_INCLUDE_DIRS, where to find Rubberband headers, Set when
# RUBBERBAND_INCLUDE_DIR is found.
# RUBBERBAND_LIBRARIES, libraries to link against to use Rubberband.
# RUBBERBAND_ROOT_DIR, The base directory to search for Rubberband.
# This can also be an environment variable.
# RUBBERBAND_FOUND, If false, do not try to use the Rubberband library.
#
# also defined, but not for general use are
# RUBBERBAND_LIBRARY, where to find the Rubberband library.
if(DEFINED RUBBERBAND_ROOT_DIR)
elseif(DEFINED ENV{RUBBERBAND_ROOT_DIR})
set(RUBBERBAND_ROOT_DIR $ENV{RUBBERBAND_ROOT_DIR})
else()
set(RUBBERBAND_ROOT_DIR "")
endif()
set(_rubberband_SEARCH_DIRS
${RUBBERBAND_ROOT_DIR}
)
find_path(RUBBERBAND_INCLUDE_DIR
NAMES
rubberband/RubberBandStretcher.h
HINTS
${_rubberband_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(RUBBERBAND_LIBRARY
NAMES
rubberband
HINTS
${_rubberband_SEARCH_DIRS}
PATH_SUFFIXES
lib lib64
)
# handle the QUIETLY and REQUIRED arguments and set RUBBERBAND_FOUND to TRUE if
# all listed variables are TRUE
find_package(PackageHandleStandardArgs)
find_package_handle_standard_args(Rubberband DEFAULT_MSG RUBBERBAND_LIBRARY RUBBERBAND_INCLUDE_DIR)
if(RUBBERBAND_FOUND)
set(RUBBERBAND_LIBRARIES ${RUBBERBAND_LIBRARY})
set(RUBBERBAND_INCLUDE_DIRS ${RUBBERBAND_INCLUDE_DIR})
endif()
mark_as_advanced(
RUBBERBAND_LIBRARY
RUBBERBAND_INCLUDE_DIR
)
unset(_rubberband_SEARCH_DIRS)

View File

@@ -0,0 +1,139 @@
# SPDX-FileCopyrightText: 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find SYCL library
# Find the native SYCL header and libraries needed by oneAPI implementation
# This module defines
# SYCL_COMPILER, compiler which will be used for compilation of SYCL code
# SYCL_LIBRARY, libraries to link against in order to use SYCL.
# SYCL_INCLUDE_DIR, directories where SYCL headers can be found
# SYCL_ROOT_DIR, The base directory to search for SYCL files.
# This can also be an environment variable.
# SYCL_FOUND, If false, then don't try to use SYCL.
if(NOT (DEFINED SYCL_ROOT_DIR))
set(SYCL_ROOT_DIR "")
endif()
if(SYCL_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{SYCL_ROOT_DIR} AND NOT $ENV{SYCL_ROOT_DIR} STREQUAL "")
set(SYCL_ROOT_DIR $ENV{SYCL_ROOT_DIR})
endif()
set(_sycl_SEARCH_DIRS
${SYCL_ROOT_DIR}
/usr/lib
/usr/local/lib
/opt/intel/oneapi/compiler/latest/linux/
C:/Program\ Files\ \(x86\)/Intel/oneAPI/compiler/latest/windows
)
# Find DPC++ compiler.
# Since the compiler name is possibly conflicting with the system-wide
# CLang start with looking for either dpcpp or clang binary in the given
# list of search paths only. If that fails, try to look for a system-wide
# dpcpp binary.
find_program(SYCL_COMPILER
NAMES
icpx
dpcpp
clang++
HINTS
${_sycl_SEARCH_DIRS}
PATH_SUFFIXES
bin
NO_CMAKE_FIND_ROOT_PATH
NAMES_PER_DIR
)
# NOTE: No clang++ here so that we do not pick up a system-wide CLang
# compiler.
if(NOT SYCL_COMPILER)
find_program(SYCL_COMPILER
NAMES
icpx
dpcpp
HINTS
${_sycl_SEARCH_DIRS}
PATH_SUFFIXES
bin
)
endif()
find_library(SYCL_LIBRARY
NAMES
sycl10
sycl9
sycl8
sycl7
sycl6
sycl
HINTS
${_sycl_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
if(WIN32)
find_library(SYCL_LIBRARY_DEBUG
NAMES
sycl10d
sycl9d
sycl8d
sycl7d
sycl6d
sycld
HINTS
${_sycl_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
endif()
find_path(SYCL_INCLUDE_DIR
NAMES
sycl/sycl.hpp
HINTS
${_sycl_SEARCH_DIRS}
PATH_SUFFIXES
include
)
if(EXISTS "${SYCL_INCLUDE_DIR}/sycl/version.hpp")
file(STRINGS "${SYCL_INCLUDE_DIR}/sycl/version.hpp" _libsycl_major_version REGEX "^#define __LIBSYCL_MAJOR_VERSION[ \t].*$")
string(REGEX MATCHALL "[0-9]+" _libsycl_major_version ${_libsycl_major_version})
file(STRINGS "${SYCL_INCLUDE_DIR}/sycl/version.hpp" _libsycl_minor_version REGEX "^#define __LIBSYCL_MINOR_VERSION[ \t].*$")
string(REGEX MATCHALL "[0-9]+" _libsycl_minor_version ${_libsycl_minor_version})
file(STRINGS "${SYCL_INCLUDE_DIR}/sycl/version.hpp" _libsycl_patch_version REGEX "^#define __LIBSYCL_PATCH_VERSION[ \t].*$")
string(REGEX MATCHALL "[0-9]+" _libsycl_patch_version ${_libsycl_patch_version})
set(SYCL_VERSION "${_libsycl_major_version}.${_libsycl_minor_version}.${_libsycl_patch_version}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SYCL
REQUIRED_VARS SYCL_LIBRARY SYCL_INCLUDE_DIR
VERSION_VAR SYCL_VERSION
)
if(SYCL_FOUND)
set(SYCL_INCLUDE_DIR ${SYCL_INCLUDE_DIR} ${SYCL_INCLUDE_DIR}/sycl)
if(WIN32 AND SYCL_LIBRARY_DEBUG)
set(SYCL_LIBRARIES optimized ${SYCL_LIBRARY} debug ${SYCL_LIBRARY_DEBUG})
else()
set(SYCL_LIBRARIES ${SYCL_LIBRARY})
endif()
else()
set(SYCL_FOUND FALSE)
endif()
mark_as_advanced(
SYCL_COMPILER
SYCL_INCLUDE_DIR
SYCL_LIBRARY
)
unset(_sycl_SEARCH_DIRS)

View File

@@ -0,0 +1,62 @@
# SPDX-FileCopyrightText: 2023 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find ShaderC libraries
# Find the ShaderC includes and libraries
# This module defines
# SHADERC_INCLUDE_DIRS, where to find ShaderC headers, Set when
# SHADERC_INCLUDE_DIR is found.
# SHADERC_LIBRARIES, libraries to link against to use ShaderC.
# SHADERC_ROOT_DIR, The base directory to search for ShaderC.
# This can also be an environment variable.
# SHADERC_FOUND, If false, do not try to use ShaderC.
#
# If `SHADERC_ROOT_DIR` was defined in the environment, use it.
if(DEFINED SHADERC_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{SHADERC_ROOT_DIR})
set(SHADERC_ROOT_DIR $ENV{SHADERC_ROOT_DIR})
else()
set(SHADERC_ROOT_DIR "")
endif()
set(_shaderc_SEARCH_DIRS
${SHADERC_ROOT_DIR}
)
find_path(SHADERC_INCLUDE_DIR
NAMES
shaderc/shaderc.h
HINTS
${_shaderc_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(SHADERC_LIBRARY
NAMES
shaderc_combined
HINTS
${_shaderc_SEARCH_DIRS}
PATH_SUFFIXES
lib
)
# handle the QUIETLY and REQUIRED arguments and set SHADERC_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ShaderC DEFAULT_MSG SHADERC_LIBRARY SHADERC_INCLUDE_DIR)
if(SHADERC_FOUND)
set(SHADERC_LIBRARIES ${SHADERC_LIBRARY})
set(SHADERC_INCLUDE_DIRS ${SHADERC_INCLUDE_DIR})
endif()
mark_as_advanced(
SHADERC_INCLUDE_DIR
SHADERC_LIBRARY
)
unset(_shaderc_SEARCH_DIRS)

View File

@@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find SndFile library
# Find the native SndFile includes and library
# This module defines
# LIBSNDFILE_INCLUDE_DIRS, where to find sndfile.h, Set when
# LIBSNDFILE_INCLUDE_DIR is found.
# LIBSNDFILE_LIBRARIES, libraries to link against to use SndFile.
# LIBSNDFILE_ROOT_DIR, The base directory to search for SndFile.
# This can also be an environment variable.
# SNDFILE_FOUND, If false, do not try to use SndFile.
#
# also defined, but not for general use are
# LIBSNDFILE_LIBRARY, where to find the SndFile library.
# If `LIBSNDFILE_ROOT_DIR` was defined in the environment, use it.
if(DEFINED LIBSNDFILE_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{LIBSNDFILE_ROOT_DIR})
set(LIBSNDFILE_ROOT_DIR $ENV{LIBSNDFILE_ROOT_DIR})
else()
set(LIBSNDFILE_ROOT_DIR "")
endif()
set(_sndfile_SEARCH_DIRS
${LIBSNDFILE_ROOT_DIR}
)
find_path(LIBSNDFILE_INCLUDE_DIR sndfile.h
HINTS
${_sndfile_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(LIBSNDFILE_LIBRARY
NAMES
sndfile
HINTS
${_sndfile_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SndFile DEFAULT_MSG
LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR)
if(SNDFILE_FOUND)
set(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBRARY})
set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIR})
endif()
mark_as_advanced(
LIBSNDFILE_INCLUDE_DIR
LIBSNDFILE_LIBRARY
)
unset(_sndfile_SEARCH_DIRS)

View File

@@ -0,0 +1,65 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Spacenav library
# Find the native Spacenav includes and library
# This module defines
# SPACENAV_INCLUDE_DIRS, where to find spnav.h, Set when
# SPACENAV_INCLUDE_DIR is found.
# SPACENAV_LIBRARIES, libraries to link against to use Spacenav.
# SPACENAV_ROOT_DIR, The base directory to search for Spacenav.
# This can also be an environment variable.
# SPACENAV_FOUND, If false, do not try to use Spacenav.
#
# also defined, but not for general use are
# SPACENAV_LIBRARY, where to find the Spacenav library.
# If `SPACENAV_ROOT_DIR` was defined in the environment, use it.
if(DEFINED SPACENAV_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{SPACENAV_ROOT_DIR})
set(SPACENAV_ROOT_DIR $ENV{SPACENAV_ROOT_DIR})
else()
set(SPACENAV_ROOT_DIR "")
endif()
set(_spacenav_SEARCH_DIRS
${SPACENAV_ROOT_DIR}
)
find_path(SPACENAV_INCLUDE_DIR
NAMES
spnav.h
HINTS
${_spacenav_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(SPACENAV_LIBRARY
NAMES
spnav
HINTS
${_spacenav_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set SPACENAV_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Spacenav DEFAULT_MSG
SPACENAV_LIBRARY SPACENAV_INCLUDE_DIR)
if(SPACENAV_FOUND)
set(SPACENAV_LIBRARIES ${SPACENAV_LIBRARY})
set(SPACENAV_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIR})
endif()
mark_as_advanced(
SPACENAV_INCLUDE_DIR
SPACENAV_LIBRARY
)
unset(_spacenav_SEARCH_DIRS)

View File

@@ -0,0 +1,83 @@
# SPDX-FileCopyrightText: 2019 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Universal Scene Description (USD) library
# Find the native USD includes and libraries
# This module defines
# USD_INCLUDE_DIRS, where to find USD headers, Set when
# USD_INCLUDE_DIR is found.
# USD_LIBRARIES, libraries to link against to use USD.
# USD_ROOT_DIR, The base directory to search for USD.
# This can also be an environment variable.
# USD_FOUND, If false, do not try to use USD.
#
# If `USD_ROOT_DIR` was defined in the environment, use it.
if(DEFINED USD_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{USD_ROOT_DIR})
set(USD_ROOT_DIR $ENV{USD_ROOT_DIR})
else()
set(USD_ROOT_DIR "")
endif()
set(_usd_SEARCH_DIRS
${USD_ROOT_DIR}
/opt/lib/usd
)
find_path(USD_INCLUDE_DIR
NAMES
pxr/usd/usd/api.h
HINTS
${_usd_SEARCH_DIRS}
PATH_SUFFIXES
include
DOC "Universal Scene Description (USD) header files"
)
if(NOT DEFINED PXR_LIB_PREFIX)
set(PXR_LIB_PREFIX "")
endif()
# Since USD 21.11 the libraries are prefixed with "usd_", i.e.
# "libusd_m.a" became "libusd_usd_m.a".
# See https://github.com/PixarAnimationStudios/USD/blob/release/CHANGELOG.md#2111---2021-11-01
find_library(USD_LIBRARY
NAMES
usd_usd_m usd_usd_ms usd_m usd_ms
${PXR_LIB_PREFIX}usd
NAMES_PER_DIR
HINTS
${_usd_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib lib/static
DOC "Universal Scene Description (USD) monolithic library"
)
if(NOT USD_LIBRARY)
set(USD_FOUND FALSE)
else()
# handle the QUIETLY and REQUIRED arguments and set USD_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(USD DEFAULT_MSG USD_LIBRARY USD_INCLUDE_DIR)
if(USD_FOUND)
get_filename_component(USD_LIBRARY_DIR ${USD_LIBRARY} DIRECTORY)
set(USD_INCLUDE_DIRS ${USD_INCLUDE_DIR})
set(USD_LIBRARIES ${USD_LIBRARY})
if(EXISTS ${USD_INCLUDE_DIR}/pxr/base/tf/pyModule.h)
set(USD_PYTHON_SUPPORT ON)
endif()
endif()
endif()
mark_as_advanced(
USD_INCLUDE_DIR
USD_LIBRARY_DIR
USD_LIBRARY
)
unset(_usd_SEARCH_DIRS)

View File

@@ -0,0 +1,62 @@
# SPDX-FileCopyrightText: 2023 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Vulkan libraries
# Find the Vulkan includes and libraries
# This module defines
# VULKAN_INCLUDE_DIRS, where to find Vulkan headers, Set when
# VULKAN_INCLUDE_DIR is found.
# VULKAN_LIBRARIES, libraries to link against to use Vulkan.
# VULKAN_ROOT_DIR, The base directory to search for Vulkan.
# This can also be an environment variable.
# VULKAN_FOUND, If false, do not try to use Vulkan.
#
# If `VULKAN_ROOT_DIR` was defined in the environment, use it.
if(DEFINED VULKAN_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{VULKAN_ROOT_DIR})
set(VULKAN_ROOT_DIR $ENV{VULKAN_ROOT_DIR})
else()
set(VULKAN_ROOT_DIR "")
endif()
set(_vulkan_SEARCH_DIRS
${VULKAN_ROOT_DIR}
)
find_path(VULKAN_INCLUDE_DIR
NAMES
vulkan/vulkan.h
HINTS
${_vulkan_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(VULKAN_LIBRARY
NAMES
vulkan
HINTS
${_vulkan_SEARCH_DIRS}
PATH_SUFFIXES
lib
)
# handle the QUIETLY and REQUIRED arguments and set VULKAN_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Vulkan DEFAULT_MSG VULKAN_LIBRARY VULKAN_INCLUDE_DIR)
if(VULKAN_FOUND)
set(VULKAN_LIBRARIES ${VULKAN_LIBRARY})
set(VULKAN_INCLUDE_DIRS ${VULKAN_INCLUDE_DIR})
endif()
mark_as_advanced(
VULKAN_INCLUDE_DIR
VULKAN_LIBRARY
)
unset(_vulkan_SEARCH_DIRS)

View File

@@ -0,0 +1,95 @@
# SPDX-FileCopyrightText: 2022 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find WebP library
# Find the native WebP includes and library
# This module defines
# WEBP_INCLUDE_DIRS, where to find WebP headers, Set when WebP is found.
# WEBP_LIBRARIES, libraries to link against to use WebP.
# WEBP_ROOT_DIR, The base directory to search for WebP.
# This can also be an environment variable.
# WEBP_FOUND, If false, do not try to use WebP.
#
# also defined, but not for general use are
# WEBP_LIBRARY, where to find the WEBP library.
# If `WEBP_ROOT_DIR` was defined in the environment, use it.
if(DEFINED WEBP_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{WEBP_ROOT_DIR})
set(WEBP_ROOT_DIR $ENV{WEBP_ROOT_DIR})
else()
set(WEBP_ROOT_DIR "")
endif()
set(_webp_SEARCH_DIRS
${WEBP_ROOT_DIR}
/opt/lib/webp
)
find_path(WEBP_INCLUDE_DIR
NAMES
webp/types.h
HINTS
${_webp_SEARCH_DIRS}
PATH_SUFFIXES
include
)
set(_webp_FIND_COMPONENTS
webp
webpmux
webpdemux
sharpyuv # New in 1.3
)
set(_webp_LIBRARIES "")
foreach(COMPONENT ${_webp_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
find_library(WEBP_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
NAMES_PER_DIR
HINTS
${_webp_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib lib/static
)
if(WEBP_${UPPERCOMPONENT}_LIBRARY)
list(APPEND _webp_LIBRARIES "${WEBP_${UPPERCOMPONENT}_LIBRARY}")
endif()
endforeach()
if(NOT WEBP_WEBP_LIBRARY)
set(WEBP_FOUND FALSE)
else()
# handle the QUIETLY and REQUIRED arguments and set WEBP_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WebP DEFAULT_MSG _webp_LIBRARIES WEBP_INCLUDE_DIR)
if(WEBP_FOUND)
get_filename_component(WEBP_LIBRARY_DIR ${WEBP_WEBP_LIBRARY} DIRECTORY)
set(WEBP_INCLUDE_DIRS ${WEBP_INCLUDE_DIR})
set(WEBP_LIBRARIES ${_webp_LIBRARIES})
else()
set(WEBP_FOUND FALSE)
endif()
endif()
mark_as_advanced(
WEBP_INCLUDE_DIR
WEBP_LIBRARY_DIR
# Generated names.
WEBP_WEBPDEMUX_LIBRARY
WEBP_WEBPMUX_LIBRARY
WEBP_WEBP_LIBRARY
WEBP_SHARPYUV_LIBRARY
)
unset(_webp_FIND_COMPONENTS)
unset(_webp_LIBRARIES)
unset(_webp_SEARCH_DIRS)

View File

@@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2011 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find XML2 library
# Find the native XML2 includes and library
# This module defines
# XML2_INCLUDE_DIRS, where to find xml2.h, Set when
# XML2_INCLUDE_DIR is found.
# XML2_LIBRARIES, libraries to link against to use XML2.
# XML2_ROOT_DIR, The base directory to search for XML2.
# This can also be an environment variable.
# XML2_FOUND, If false, do not try to use XML2.
#
# also defined, but not for general use are
# XML2_LIBRARY, where to find the XML2 library.
# If `XML2_ROOT_DIR` was defined in the environment, use it.
if(DEFINED XML2_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{XML2_ROOT_DIR})
set(XML2_ROOT_DIR $ENV{XML2_ROOT_DIR})
else()
set(XML2_ROOT_DIR "")
endif()
set(_xml2_SEARCH_DIRS
${XML2_ROOT_DIR}
)
find_path(XML2_INCLUDE_DIR libxml2/libxml/xpath.h
HINTS
${_xml2_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(XML2_LIBRARY
NAMES
xml2
HINTS
${_xml2_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set XML2_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XML2 DEFAULT_MSG
XML2_LIBRARY XML2_INCLUDE_DIR)
if(XML2_FOUND)
set(XML2_LIBRARIES ${XML2_LIBRARY})
set(XML2_INCLUDE_DIRS ${XML2_INCLUDE_DIR})
endif()
mark_as_advanced(
XML2_INCLUDE_DIR
XML2_LIBRARY
)
unset(_xml2_SEARCH_DIRS)

View File

@@ -0,0 +1,74 @@
# SPDX-FileCopyrightText: 2020-2022 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find OpenXR-SDK libraries
# Find the native OpenXR-SDK includes and libraries
#
# Note that there is a distinction between the OpenXR standard and the SDK. The
# latter provides utilities to use the standard but is not part of it. Most
# importantly, it contains C headers and a loader library, which manages
# dynamic linking to OpenXR runtimes like Monado, Windows Mixed Reality or
# Oculus. See the repository for more details:
# https://github.com/KhronosGroup/OpenXR-SDK
#
# This module defines
# XR_OPENXR_SDK_INCLUDE_DIRS, where to find OpenXR-SDK headers, Set when
# XR_OPENXR_SDK_INCLUDE_DIR is found.
# XR_OPENXR_SDK_LIBRARIES, libraries to link against to use OpenXR.
# XR_OPENXR_SDK_ROOT_DIR, the base directory to search for OpenXR-SDK.
# This can also be an environment variable.
# XR_OPENXR_SDK_FOUND, if false, do not try to use OpenXR-SDK.
#
# also defined, but not for general use are
# XR_OPENXR_SDK_LOADER_LIBRARY, where to find the OpenXR-SDK loader library.
# If `XR_OPENXR_SDK_ROOT_DIR` was defined in the environment, use it.
if(DEFINED XR_OPENXR_SDK_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{XR_OPENXR_SDK_ROOT_DIR})
set(XR_OPENXR_SDK_ROOT_DIR $ENV{XR_OPENXR_SDK_ROOT_DIR})
else()
set(XR_OPENXR_SDK_ROOT_DIR "")
endif()
set(_xr_openxr_sdk_SEARCH_DIRS
${XR_OPENXR_SDK_ROOT_DIR}
/opt/lib/xr-openxr-sdk
)
find_path(XR_OPENXR_SDK_INCLUDE_DIR
NAMES
openxr/openxr.h
HINTS
${_xr_openxr_sdk_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(XR_OPENXR_SDK_LOADER_LIBRARY
NAMES
openxr_loader
HINTS
${_xr_openxr_sdk_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set XR_OPENXR_SDK_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XR_OpenXR_SDK DEFAULT_MSG
XR_OPENXR_SDK_LOADER_LIBRARY XR_OPENXR_SDK_INCLUDE_DIR)
if(XR_OPENXR_SDK_FOUND)
set(XR_OPENXR_SDK_LIBRARIES ${XR_OPENXR_SDK_LOADER_LIBRARY})
set(XR_OPENXR_SDK_INCLUDE_DIRS ${XR_OPENXR_SDK_INCLUDE_DIR})
endif()
mark_as_advanced(
XR_OPENXR_SDK_INCLUDE_DIR
XR_OPENXR_SDK_LOADER_LIBRARY
)
unset(_xr_openxr_sdk_SEARCH_DIRS)

View File

@@ -0,0 +1,65 @@
# SPDX-FileCopyrightText: 2019 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find Zstd library
# Find the native Zstd includes and library
# This module defines
# ZSTD_INCLUDE_DIRS, where to find zstd.h, Set when
# ZSTD_INCLUDE_DIR is found.
# ZSTD_LIBRARIES, libraries to link against to use Zstd.
# ZSTD_ROOT_DIR, The base directory to search for Zstd.
# This can also be an environment variable.
# ZSTD_FOUND, If false, do not try to use Zstd.
#
# also defined, but not for general use are
# ZSTD_LIBRARY, where to find the Zstd library.
# If `ZSTD_ROOT_DIR` was defined in the environment, use it.
if(DEFINED ZSTD_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{ZSTD_ROOT_DIR})
set(ZSTD_ROOT_DIR $ENV{ZSTD_ROOT_DIR})
else()
set(ZSTD_ROOT_DIR "")
endif()
set(_zstd_SEARCH_DIRS
${ZSTD_ROOT_DIR}
)
find_path(ZSTD_INCLUDE_DIR
NAMES
zstd.h
HINTS
${_zstd_SEARCH_DIRS}
PATH_SUFFIXES
include
)
find_library(ZSTD_LIBRARY
NAMES
zstd
HINTS
${_zstd_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
# handle the QUIETLY and REQUIRED arguments and set ZSTD_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Zstd DEFAULT_MSG
ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
if(ZSTD_FOUND)
set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
endif()
mark_as_advanced(
ZSTD_INCLUDE_DIR
ZSTD_LIBRARY
)
unset(_zstd_SEARCH_DIRS)

View File

@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: 2020 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
# - Find sse2neon library
# Find the native sse2neon includes and library
# This module defines
# SSE2NEON_INCLUDE_DIRS, where to find sse2neon.h, Set when
# SSE2NEON_INCLUDE_DIR is found.
# SSE2NEON_ROOT_DIR, The base directory to search for sse2neon.
# This can also be an environment variable.
# SSE2NEON_FOUND, If false, do not try to use sse2neon.
# If `SSE2NEON_ROOT_DIR` was defined in the environment, use it.
if(DEFINED SSE2NEON_ROOT_DIR)
# Pass.
elseif(DEFINED ENV{SSE2NEON_ROOT_DIR})
set(SSE2NEON_ROOT_DIR $ENV{SSE2NEON_ROOT_DIR})
else()
set(SSE2NEON_ROOT_DIR "")
endif()
set(_sse2neon_SEARCH_DIRS
${SSE2NEON_ROOT_DIR}
)
find_path(SSE2NEON_INCLUDE_DIR
NAMES
sse2neon.h
HINTS
${_sse2neon_SEARCH_DIRS}
PATH_SUFFIXES
include
)
# handle the QUIETLY and REQUIRED arguments and set SSE2NEON_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(sse2neon DEFAULT_MSG
SSE2NEON_INCLUDE_DIR)
if(SSE2NEON_FOUND)
set(SSE2NEON_INCLUDE_DIRS ${SSE2NEON_INCLUDE_DIR})
endif()
mark_as_advanced(
SSE2NEON_INCLUDE_DIR
)
unset(_sse2neon_SEARCH_DIRS)

View File

@@ -0,0 +1,412 @@
# SPDX-FileCopyrightText: 2020-2022 Blender Authors
#
# SPDX-License-Identifier: BSD-3-Clause
#[=======================================================================[.rst:
GoogleTest
----------
.. versionadded:: 3.9
This module defines functions to help use the Google Test infrastructure. Two
mechanisms for adding tests are provided. :command:`gtest_add_tests` has been
around for some time, originally via ``find_package(GTest)``.
:command:`gtest_discover_tests` was introduced in CMake 3.10.
The (older) :command:`gtest_add_tests` scans source files to identify tests.
This is usually effective, with some caveats, including in cross-compiling
environments, and makes setting additional properties on tests more convenient.
However, its handling of parameterized tests is less comprehensive, and it
requires re-running CMake to detect changes to the list of tests.
The (newer) :command:`gtest_discover_tests` discovers tests by asking the
compiled test executable to enumerate its tests. This is more robust and
provides better handling of parameterized tests, and does not require CMake
to be re-run when tests change. However, it may not work in a cross-compiling
environment, and setting test properties is less convenient.
More details can be found in the documentation of the respective functions.
Both commands are intended to replace use of :command:`add_test` to register
tests, and will create a separate CTest test for each Google Test test case.
Note that this is in some cases less efficient, as common set-up and tear-down
logic cannot be shared by multiple test cases executing in the same instance.
However, it provides more fine-grained pass/fail information to CTest, which is
usually considered as more beneficial. By default, the CTest test name is the
same as the Google Test name (i.e. ``suite.testcase``); see also
``TEST_PREFIX`` and ``TEST_SUFFIX``.
.. command:: gtest_add_tests
Automatically add tests with CTest by scanning source code for Google Test
macros::
gtest_add_tests(TARGET target
[SOURCES src1...]
[EXTRA_ARGS arg1...]
[WORKING_DIRECTORY dir]
[TEST_PREFIX prefix]
[TEST_SUFFIX suffix]
[SKIP_DEPENDENCY]
[TEST_LIST outVar]
)
``gtest_add_tests`` attempts to identify tests by scanning source files.
Although this is generally effective, it uses only a basic regular expression
match, which can be defeated by atypical test declarations, and is unable to
fully "split" parameterized tests. Additionally, it requires that CMake be
re-run to discover any newly added, removed or renamed tests (by default,
this means that CMake is re-run when any test source file is changed, but see
``SKIP_DEPENDENCY``). However, it has the advantage of declaring tests at
CMake time, which somewhat simplifies setting additional properties on tests,
and always works in a cross-compiling environment.
The options are:
``TARGET target``
Specifies the Google Test executable, which must be a known CMake
executable target. CMake will substitute the location of the built
executable when running the test.
``SOURCES src1...``
When provided, only the listed files will be scanned for test cases. If
this option is not given, the :prop_tgt:`SOURCES` property of the
specified ``target`` will be used to obtain the list of sources.
``EXTRA_ARGS arg1...``
Any extra arguments to pass on the command line to each test case.
``WORKING_DIRECTORY dir``
Specifies the directory in which to run the discovered test cases. If this
option is not provided, the current binary directory is used.
``TEST_PREFIX prefix``
Specifies a ``prefix`` to be prepended to the name of each discovered test
case. This can be useful when the same source files are being used in
multiple calls to ``gtest_add_test()`` but with different ``EXTRA_ARGS``.
``TEST_SUFFIX suffix``
Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
be specified.
``SKIP_DEPENDENCY``
Normally, the function creates a dependency which will cause CMake to be
re-run if any of the sources being scanned are changed. This is to ensure
that the list of discovered tests is updated. If this behavior is not
desired (as may be the case while actually writing the test cases), this
option can be used to prevent the dependency from being added.
``TEST_LIST outVar``
The variable named by ``outVar`` will be populated in the calling scope
with the list of discovered test cases. This allows the caller to do
things like manipulate test properties of the discovered tests.
.. code-block:: cmake
include(GoogleTest)
add_executable(FooTest FooUnitTest.cxx)
gtest_add_tests(TARGET FooTest
TEST_SUFFIX .noArgs
TEST_LIST noArgsTests
)
gtest_add_tests(TARGET FooTest
EXTRA_ARGS --someArg someValue
TEST_SUFFIX .withArgs
TEST_LIST withArgsTests
)
set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
set_tests_properties(${withArgsTests} PROPERTIES TIMEOUT 20)
For backward compatibility, the following form is also supported::
gtest_add_tests(exe args files...)
``exe``
The path to the test executable or the name of a CMake target.
``args``
A ;-list of extra arguments to be passed to executable. The entire
list must be passed as a single argument. Enclose it in quotes,
or pass ``""`` for no arguments.
``files...``
A list of source files to search for tests and test fixtures.
Alternatively, use ``AUTO`` to specify that ``exe`` is the name
of a CMake executable target whose sources should be scanned.
.. code-block:: cmake
include(GoogleTest)
set(FooTestArgs --foo 1 --bar 2)
add_executable(FooTest FooUnitTest.cxx)
gtest_add_tests(FooTest "${FooTestArgs}" AUTO)
.. command:: gtest_discover_tests
Automatically add tests with CTest by querying the compiled test executable
for available tests::
gtest_discover_tests(target
[EXTRA_ARGS arg1...]
[WORKING_DIRECTORY dir]
[TEST_PREFIX prefix]
[TEST_SUFFIX suffix]
[NO_PRETTY_TYPES] [NO_PRETTY_VALUES]
[PROPERTIES name1 value1...]
[TEST_LIST var]
[DISCOVERY_TIMEOUT seconds]
[XML_OUTPUT_DIR dir]
[DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
)
``gtest_discover_tests()`` sets up a post-build command on the test executable
that generates the list of tests by parsing the output from running the test
with the ``--gtest_list_tests`` argument. Compared to the source parsing
approach of :command:`gtest_add_tests`, this ensures that the full list of
tests, including instantiations of parameterized tests, is obtained. Since
test discovery occurs at build time, it is not necessary to re-run CMake when
the list of tests changes.
However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set
in order to function in a cross-compiling environment.
Additionally, setting properties on tests is somewhat less convenient, since
the tests are not available at CMake time. Additional test properties may be
assigned to the set of tests as a whole using the ``PROPERTIES`` option. If
more fine-grained test control is needed, custom content may be provided
through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES`
directory property. The set of discovered tests is made accessible to such a
script via the ``<target>_TESTS`` variable.
The options are:
``target``
Specifies the Google Test executable, which must be a known CMake
executable target. CMake will substitute the location of the built
executable when running the test.
``EXTRA_ARGS arg1...``
Any extra arguments to pass on the command line to each test case.
``WORKING_DIRECTORY dir``
Specifies the directory in which to run the discovered test cases. If this
option is not provided, the current binary directory is used.
``TEST_PREFIX prefix``
Specifies a ``prefix`` to be prepended to the name of each discovered test
case. This can be useful when the same test executable is being used in
multiple calls to ``gtest_discover_tests()`` but with different
``EXTRA_ARGS``.
``TEST_SUFFIX suffix``
Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
be specified.
``NO_PRETTY_TYPES``
By default, the type index of type-parameterized tests is replaced by the
actual type name in the CTest test name. If this behavior is undesirable
(e.g. because the type names are unwieldy), this option will suppress this
behavior.
``NO_PRETTY_VALUES``
By default, the value index of value-parameterized tests is replaced by the
actual value in the CTest test name. If this behavior is undesirable
(e.g. because the value strings are unwieldy), this option will suppress
this behavior.
``PROPERTIES name1 value1...``
Specifies additional properties to be set on all tests discovered by this
invocation of ``gtest_discover_tests()``.
``TEST_LIST var``
Make the list of tests available in the variable ``var``, rather than the
default ``<target>_TESTS``. This can be useful when the same test
executable is being used in multiple calls to ``gtest_discover_tests()``.
Note that this variable is only available in CTest.
``DISCOVERY_TIMEOUT num``
Specifies how long (in seconds) CMake will wait for the test to enumerate
available tests. If the test takes longer than this, discovery (and your
build) will fail. Most test executables will enumerate their tests very
quickly, but under some exceptional circumstances, a test may require a
longer timeout. The default is 5. See also the ``TIMEOUT`` option of
:command:`execute_process`.
.. note::
In CMake versions 3.10.1 and 3.10.2, this option was called ``TIMEOUT``.
This clashed with the ``TIMEOUT`` test property, which is one of the
common properties that would be set with the ``PROPERTIES`` keyword,
usually leading to legal but unintended behavior. The keyword was
changed to ``DISCOVERY_TIMEOUT`` in CMake 3.10.3 to address this
problem. The ambiguous behavior of the ``TIMEOUT`` keyword in 3.10.1
and 3.10.2 has not been preserved.
``XML_OUTPUT_DIR dir``
If specified, the parameter is passed along with ``--gtest_output=xml:``
to test executable. The actual file name is the same as the test target,
including prefix and suffix. This should be used instead of
``EXTRA_ARGS --gtest_output=xml`` to avoid race conditions writing the
XML result output when using parallel test execution.
``DISCOVERY_MODE``
Provides greater control over when ``gtest_discover_tests()`` performs test
discovery. By default, ``POST_BUILD`` sets up a post-build command
to perform test discovery at build time. In certain scenarios, like
cross-compiling, this ``POST_BUILD`` behavior is not desirable.
By contrast, ``PRE_TEST`` delays test discovery until just prior to test
execution. This way test discovery occurs in the target environment
where the test has a better chance at finding appropriate runtime
dependencies.
``DISCOVERY_MODE`` defaults to the value of the
``CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not
passed when calling ``gtest_discover_tests()``. This provides a mechanism
for globally selecting a preferred test discovery behavior without having
to modify each call site.
#]=======================================================================]
# Save project's policies
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
# -----------------------------------------------------------------------------
function(gtest_add_tests)
if(ARGC LESS 1)
message(FATAL_ERROR "No arguments supplied to gtest_add_tests()")
endif()
set(options
SKIP_DEPENDENCY
)
set(oneValueArgs
TARGET
WORKING_DIRECTORY
TEST_PREFIX
TEST_SUFFIX
TEST_LIST
)
set(multiValueArgs
SOURCES
EXTRA_ARGS
)
set(allKeywords ${options} ${oneValueArgs} ${multiValueArgs})
unset(sources)
if("${ARGV0}" IN_LIST allKeywords)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(autoAddSources YES)
else()
# Non-keyword syntax, convert to keyword form
if(ARGC LESS 3)
message(FATAL_ERROR "gtest_add_tests() without keyword options requires at least 3 arguments")
endif()
set(ARGS_TARGET "${ARGV0}")
set(ARGS_EXTRA_ARGS "${ARGV1}")
if(NOT "${ARGV2}" STREQUAL "AUTO")
set(ARGS_SOURCES "${ARGV}")
list(REMOVE_AT ARGS_SOURCES 0 1)
endif()
endif()
# The non-keyword syntax allows the first argument to be an arbitrary
# executable rather than a target if source files are also provided. In all
# other cases, both forms require a target.
if(NOT TARGET "${ARGS_TARGET}" AND NOT ARGS_SOURCES)
message(FATAL_ERROR "${ARGS_TARGET} does not define an existing CMake target")
endif()
if(NOT ARGS_WORKING_DIRECTORY)
unset(workDir)
else()
set(workDir WORKING_DIRECTORY "${ARGS_WORKING_DIRECTORY}")
endif()
if(NOT ARGS_SOURCES)
get_property(ARGS_SOURCES TARGET ${ARGS_TARGET} PROPERTY SOURCES)
endif()
unset(testList)
set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*")
set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
# This will get a filter for each test suite.
set(test_filters "")
foreach(source IN LISTS ARGS_SOURCES)
if(NOT ARGS_SKIP_DEPENDENCY)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
endif()
file(READ "${source}" contents)
string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests "${contents}")
foreach(hit ${found_tests})
string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
# Parameterized tests have a different signature for the filter
if("x${test_type}" STREQUAL "xTEST_P")
string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2/*" gtest_test_name ${hit})
elseif("x${test_type}" STREQUAL "xTEST_F" OR "x${test_type}" STREQUAL "xTEST")
string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" gtest_test_name ${hit})
elseif("x${test_type}" STREQUAL "xTYPED_TEST")
string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" gtest_test_name ${hit})
else()
message(WARNING "Could not parse GTest ${hit} for adding to CTest.")
continue()
endif()
# Make sure tests disabled in GTest get disabled in CTest
if(gtest_test_name MATCHES "(^|\\.)DISABLED_")
# Add the disabled test if CMake is new enough
# Note that this check is to allow backwards compatibility so this
# module can be copied locally in projects to use with older CMake
# versions
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.8.20170401)
string(REGEX REPLACE
"(^|\\.)DISABLED_" "\\1"
orig_test_name "${gtest_test_name}"
)
set(ctest_test_name
${ARGS_TEST_PREFIX}${orig_test_name}${ARGS_TEST_SUFFIX}
)
add_test(NAME ${ctest_test_name}
${workDir}
COMMAND ${ARGS_TARGET}
--gtest_also_run_disabled_tests
--gtest_filter=${gtest_test_name}
${ARGS_EXTRA_ARGS}
)
set_tests_properties(${ctest_test_name} PROPERTIES DISABLED TRUE)
list(APPEND testList ${ctest_test_name})
endif()
else()
# BLENDER: collect tests named "suite.testcase" as list of "suite.*" filters.
string(REGEX REPLACE "\\..*$" "" gtest_suite_name ${gtest_test_name})
list(APPEND test_filters "${gtest_suite_name}.*")
endif()
endforeach()
endforeach()
# Join all found GTest suite names into one big filter.
list(REMOVE_DUPLICATES test_filters)
list(JOIN test_filters ":" gtest_filter)
add_test(NAME ${ARGS_TEST_PREFIX}
${workDir}
COMMAND ${ARGS_TARGET}
--gtest_filter=${gtest_filter}
${ARGS_EXTRA_ARGS}
)
list(APPEND testList ${ARGS_TEST_PREFIX})
if(ARGS_TEST_LIST)
set(${ARGS_TEST_LIST} ${testList} PARENT_SCOPE)
endif()
endfunction()
# BLENDER: remove the discovery function gtest_discover_tests(). It's not used,
# as it generates too many test invocations.
# Restore project's policies
cmake_policy(POP)

View File

@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: 2011-2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# VLMC RPM Finder
# Authors: Rohit Yadav <rohityadav89@gmail.com>
if(NOT DEFINED RPMBUILD)
find_program(RPMBUILD
NAMES rpmbuild
PATHS "/usr/bin")
mark_as_advanced(RPMBUILD)
if(RPMBUILD)
message(STATUS "RPM Build Found: ${RPMBUILD}")
else()
message(STATUS "RPM Build Not Found (rpmbuild). RPM generation will not be available")
endif()
endif()
if(RPMBUILD)
set(RPMBUILD_FOUND TRUE)
else()
set(RPMBUILD_FOUND FALSE)
endif()

View File

@@ -0,0 +1,210 @@
# SPDX-FileCopyrightText: 2011-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# This is called by cmake as an external process from
# ./source/creator/CMakeLists.txt to write ./source/creator/buildinfo.h
# Caller must define:
# SOURCE_DIR
# Optional overrides:
# BUILD_DATE
# BUILD_TIME
# Extract working copy information for SOURCE_DIR into MY_XXX variables
# with a default in case anything fails, for example when using git-svn
set(MY_WC_HASH "unknown")
set(MY_WC_BRANCH "unknown")
set(MY_WC_COMMIT_TIMESTAMP 0)
# Guess if this is a git working copy and then look up the revision
if(EXISTS ${SOURCE_DIR}/.git)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(MY_WC_BRANCH STREQUAL "HEAD")
# Detached HEAD, check whether commit hash is reachable
# in the main branch
execute_process(
COMMAND git rev-parse --short=12 HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git branch --list main blender-v* --contains ${MY_WC_HASH}
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE _git_contains_check
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT _git_contains_check STREQUAL "")
set(MY_WC_BRANCH "main")
else()
execute_process(
COMMAND git show-ref --tags -d
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE _git_tag_hashes
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE _git_head_hash
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Safe to use as a regex since git hashes only contain hex characters.
if(_git_tag_hashes MATCHES "${_git_head_hash}")
set(MY_WC_BRANCH "main")
else()
execute_process(
COMMAND git branch --contains ${MY_WC_HASH}
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE _git_contains_branches
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX REPLACE "^\\*[ \t]+" "" _git_contains_branches "${_git_contains_branches}")
string(REGEX REPLACE "[\r\n]+" ";" _git_contains_branches "${_git_contains_branches}")
string(REGEX REPLACE ";[ \t]+" ";" _git_contains_branches "${_git_contains_branches}")
foreach(_branch ${_git_contains_branches})
if(NOT "${_branch}" MATCHES "\\(HEAD.*")
set(MY_WC_BRANCH "${_branch}")
break()
endif()
endforeach()
unset(_branch)
unset(_git_contains_branches)
endif()
unset(_git_tag_hashes)
unset(_git_head_hash)
endif()
unset(_git_contains_check)
else()
execute_process(
COMMAND git log HEAD..@{u}
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE _git_below_check
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(NOT _git_below_check STREQUAL "")
# If there are commits between HEAD and upstream this means
# that we're reset-ed to older revision. Use its hash then.
execute_process(
COMMAND git rev-parse --short=12 HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
execute_process(
COMMAND git rev-parse --short=12 @{u}
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(MY_WC_HASH STREQUAL "")
# Local branch, not set to upstream.
# Well, let's use HEAD for now
execute_process(
COMMAND git rev-parse --short=12 HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
unset(_git_below_check)
endif()
execute_process(
COMMAND git log -1 --format=%ct
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_COMMIT_TIMESTAMP
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# May fail in rare cases
if(MY_WC_COMMIT_TIMESTAMP STREQUAL "")
set(MY_WC_COMMIT_TIMESTAMP 0)
endif()
# Update GIT index before getting dirty files
execute_process(
COMMAND git update-index -q --refresh
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git diff-index --name-only HEAD --
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE _git_changed_files
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT _git_changed_files STREQUAL "")
string(APPEND MY_WC_BRANCH " (modified)")
else()
# Un-pushed commits are also considered local modifications.
execute_process(
COMMAND git log @{u}..
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE _git_unpushed_log
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(NOT _git_unpushed_log STREQUAL "")
string(APPEND MY_WC_BRANCH " (modified)")
endif()
unset(_git_unpushed_log)
endif()
unset(_git_changed_files)
endif()
# BUILD_PLATFORM is taken from CMake
# but BUILD_DATE and BUILD_TIME are platform dependent
if(NOT BUILD_DATE)
string(TIMESTAMP BUILD_DATE "%Y-%m-%d" UTC)
endif()
if(NOT BUILD_TIME)
string(TIMESTAMP BUILD_TIME "%H:%M:%S" UTC)
endif()
# Write a file with the BUILD_HASH define
file(WRITE buildinfo.h.txt
"#define BUILD_HASH \"${MY_WC_HASH}\"\n"
"#define BUILD_COMMIT_TIMESTAMP ${MY_WC_COMMIT_TIMESTAMP}\n"
"#define BUILD_BRANCH \"${MY_WC_BRANCH}\"\n"
"#define BUILD_DATE \"${BUILD_DATE}\"\n"
"#define BUILD_TIME \"${BUILD_TIME}\"\n"
"#include \"buildinfo_static.h\"\n"
)
# cleanup
unset(MY_WC_HASH)
unset(MY_WC_COMMIT_TIMESTAMP)
unset(MY_WC_BRANCH)
unset(BUILD_DATE)
unset(BUILD_TIME)
# Copy the file to the final header only if the version changes
# and avoid needless rebuilds
# TODO: verify this comment is true, as BUILD_TIME probably changes
execute_process(
COMMAND ${CMAKE_COMMAND}
-E copy_if_different
buildinfo.h.txt buildinfo.h
)

View File

@@ -0,0 +1,8 @@
/* CMake expanded values that won't change between CMake execution (unlike date/time).
* This is included by `buildinfo.h` generated by `buildinfo.cmake`. */
#define BUILD_PLATFORM "@BUILD_PLATFORM@"
#define BUILD_TYPE "@BUILD_TYPE@"
#define BUILD_CFLAGS "@BUILD_CFLAGS@"
#define BUILD_CXXFLAGS "@BUILD_CXXFLAGS@"
#define BUILD_LINKFLAGS "@BUILD_LINKFLAGS@"
#define BUILD_SYSTEM "@BUILD_SYSTEM@"

View File

@@ -0,0 +1,98 @@
# SPDX-FileCopyrightText: 2018-2023 Blender Authors
#
# SPDX-License-Identifier: Apache-2.0
# Simple utility that prints all `WITH_*` options in a `CMakeLists.txt`.
# Called by `make help_features`.
__all__ = (
"main",
)
import re
import sys
from typing import (
Optional,
)
def count_backslashes_before_pos(file_data: str, pos: int) -> int:
slash_count = 0
pos -= 1
while pos >= 0:
if file_data[pos] != '\\':
break
pos -= 1
slash_count += 1
return slash_count
def extract_cmake_string_at_pos(file_data: str, pos_beg: int) -> Optional[str]:
assert file_data[pos_beg - 1] == '"'
pos = pos_beg
# Dummy assignment.
pos_end = pos_beg
while True:
pos_next = file_data.find('"', pos)
if pos_next == -1:
raise Exception("Un-terminated string (parse error?)")
count_slashes = count_backslashes_before_pos(file_data, pos_next)
if (count_slashes % 2) == 0:
pos_end = pos_next
# Found the closing quote.
break
# The quote was back-slash escaped, step over it.
pos = pos_next + 1
file_data[pos_next]
assert file_data[pos_end] == '"'
if pos_beg == pos_end:
return None
# See: https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#escape-sequences
text = file_data[pos_beg: pos_end].replace(
# Handle back-slash literals.
"\\\\", "\\",
).replace(
# Handle tabs.
"\\t", "\t",
).replace(
# Handle escaped quotes.
"\\\"", "\"",
).replace(
# Handle tabs.
"\\;", ";",
).replace(
# Handle trailing newlines.
"\\\n", "",
)
return text
def main() -> int:
cmakelists_file = sys.argv[-1]
options = []
with open(cmakelists_file, 'r', encoding="utf-8") as fh:
file_data = fh.read()
for m in re.finditer(r"^\s*option\s*\(\s*(WITH_[a-zA-Z0-9_]+)\s+(\")", file_data, re.MULTILINE):
option_name = m.group(1)
option_descr = extract_cmake_string_at_pos(file_data, m.span(2)[1])
if option_descr is None:
# Possibly a parsing error, at least show something.
option_descr = "(UNDOCUMENTED)"
options.append("{:s}: {:s}".format(option_name, option_descr))
print('\n'.join(options))
return 0
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,30 @@
# SPDX-FileCopyrightText: 2019-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Configuration for developers, with faster builds, error checking and tests.
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/blender_developer.cmake ../blender
#
set(WITH_ASSERT_ABORT ON CACHE BOOL "" FORCE)
set(WITH_ASSERT_RELEASE ON CACHE BOOL "" FORCE)
set(WITH_BUILDINFO OFF CACHE BOOL "" FORCE)
# Sadly ASAN is more often broken than working with MSVC do not enable it in the
# developer profile for now.
if(NOT WIN32)
set(WITH_COMPILER_ASAN ON CACHE BOOL "" FORCE)
set(WITH_STRSIZE_DEBUG ON CACHE BOOL "" FORCE)
endif()
set(WITH_CYCLES_NATIVE_ONLY ON CACHE BOOL "" FORCE)
set(WITH_DOC_MANPAGE OFF CACHE BOOL "" FORCE)
set(WITH_GTESTS ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS OFF CACHE BOOL "" FORCE)
set(WITH_PYTHON_SAFETY ON CACHE BOOL "" FORCE)
if(WIN32)
set(WITH_WINDOWS_BUNDLE_CRT OFF CACHE BOOL "" FORCE)
endif()
# For Ninja & Makefile: Generate compile_commands.json. Used by Clang tools (that many common IDEs
# rely on) to obtain include paths, compile flags, etc. from the build system.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "" FORCE)

View File

@@ -0,0 +1,87 @@
# SPDX-FileCopyrightText: 2014-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Turn everything ON that's expected for an official release builds.
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/blender_full.cmake ../blender
#
set(WITH_ALEMBIC ON CACHE BOOL "" FORCE)
set(WITH_AUDASPACE ON CACHE BOOL "" FORCE)
set(WITH_BUILDINFO ON CACHE BOOL "" FORCE)
set(WITH_BULLET ON CACHE BOOL "" FORCE)
set(WITH_CODEC_FFMPEG ON CACHE BOOL "" FORCE)
set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_PATH_GUIDING ON CACHE BOOL "" FORCE)
set(WITH_DRACO ON CACHE BOOL "" FORCE)
set(WITH_MESHOPTIMIZER ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)
set(WITH_GMP ON CACHE BOOL "" FORCE)
set(WITH_HARU ON CACHE BOOL "" FORCE)
set(WITH_IK_ITASC ON CACHE BOOL "" FORCE)
set(WITH_IK_SOLVER ON CACHE BOOL "" FORCE)
set(WITH_IMAGE_CINEON ON CACHE BOOL "" FORCE)
set(WITH_IMAGE_OPENJPEG ON CACHE BOOL "" FORCE)
set(WITH_IMAGE_WEBP ON CACHE BOOL "" FORCE)
set(WITH_INPUT_NDOF ON CACHE BOOL "" FORCE)
set(WITH_INPUT_IME ON CACHE BOOL "" FORCE)
set(WITH_INTERNATIONAL ON CACHE BOOL "" FORCE)
set(WITH_IO_FBX ON CACHE BOOL "" FORCE)
set(WITH_IO_GREASE_PENCIL ON CACHE BOOL "" FORCE)
set(WITH_IO_PLY ON CACHE BOOL "" FORCE)
set(WITH_IO_STL ON CACHE BOOL "" FORCE)
set(WITH_IO_WAVEFRONT_OBJ ON CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
set(WITH_MANIFOLD ON CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID ON CACHE BOOL "" FORCE)
set(WITH_MOD_OCEANSIM ON CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH ON CACHE BOOL "" FORCE)
set(WITH_UV_SLIM ON CACHE BOOL "" FORCE)
set(WITH_NANOVDB ON CACHE BOOL "" FORCE)
set(WITH_OPENAL ON CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEDENOISE ON CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB_BLOSC ON CACHE BOOL "" FORCE)
set(WITH_POTRACE ON CACHE BOOL "" FORCE)
set(WITH_PUGIXML ON CACHE BOOL "" FORCE)
set(WITH_PYTHON_INSTALL ON CACHE BOOL "" FORCE)
set(WITH_QUADRIFLOW ON CACHE BOOL "" FORCE)
set(WITH_RUBBERBAND ON CACHE BOOL "" FORCE)
set(WITH_SDL_AUDIO OFF CACHE BOOL "" FORCE)
set(WITH_TBB ON CACHE BOOL "" FORCE)
set(WITH_USD ON CACHE BOOL "" FORCE)
set(WITH_MATERIALX ON CACHE BOOL "" FORCE)
set(WITH_HYDRA ON CACHE BOOL "" FORCE)
set(WITH_XR_OPENXR ON CACHE BOOL "" FORCE)
# platform dependent options
if(APPLE)
set(WITH_COREAUDIO ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_METAL ON CACHE BOOL "" FORCE)
set(WITH_BLENDER_THUMBNAILER ON CACHE BOOL "" FORCE)
endif()
if(WIN32)
set(WITH_WASAPI ON CACHE BOOL "" FORCE)
endif()
if(UNIX AND NOT APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_DOC_MANPAGE ON CACHE BOOL "" FORCE)
set(WITH_GHOST_XDND ON CACHE BOOL "" FORCE)
set(WITH_PULSEAUDIO ON CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
endif()
if(NOT APPLE)
# Can't use CMAKE_SYSTEM_PROCESSOR here as it's not set yet,
# so fall back to checking the env for vcvarsall's VSCMD_ARG_TGT_ARCH
if(NOT (WIN32 AND "$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "arm64"))
set(WITH_TBB_MALLOC_PROXY ON CACHE BOOL "" FORCE)
endif()
endif()

View File

@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: 2011-2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# headless configuration, useful in for servers or renderfarms
# builds without a windowing system (X11/Windows/Cocoa).
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/blender_headless.cmake ../blender
#
set(WITH_HEADLESS ON CACHE BOOL "" FORCE)
# disable audio, it's possible some devs may want this but for now disable
# so the python module doesn't hold the audio device and loads quickly.
set(WITH_AUDASPACE OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_FFMPEG OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
set(WITH_COREAUDIO OFF CACHE BOOL "" FORCE)
set(WITH_JACK OFF CACHE BOOL "" FORCE)
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_PULSEAUDIO OFF CACHE BOOL "" FORCE)
set(WITH_SDL_AUDIO OFF CACHE BOOL "" FORCE)
set(WITH_WASAPI OFF CACHE BOOL "" FORCE)
# other features which are not especially useful as a python module
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)
set(WITH_INPUT_NDOF OFF CACHE BOOL "" FORCE)

View File

@@ -0,0 +1,86 @@
# SPDX-FileCopyrightText: 2011-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# turn everything OFF except for python which defaults to ON
# and is needed for the UI
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/blender_lite.cmake ../blender
#
set(WITH_ALEMBIC OFF CACHE BOOL "" FORCE)
set(WITH_AUDASPACE OFF CACHE BOOL "" FORCE)
set(WITH_BLENDER_THUMBNAILER OFF CACHE BOOL "" FORCE)
set(WITH_BOOST OFF CACHE BOOL "" FORCE)
set(WITH_BUILDINFO OFF CACHE BOOL "" FORCE)
set(WITH_BULLET OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_FFMPEG OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
set(WITH_DRACO OFF CACHE BOOL "" FORCE)
set(WITH_MESHOPTIMIZER OFF CACHE BOOL "" FORCE)
set(WITH_FFTW3 OFF CACHE BOOL "" FORCE)
set(WITH_FREESTYLE OFF CACHE BOOL "" FORCE)
set(WITH_GMP OFF CACHE BOOL "" FORCE)
set(WITH_HARU OFF CACHE BOOL "" FORCE)
set(WITH_HYDRA OFF CACHE BOOL "" FORCE)
set(WITH_IK_ITASC OFF CACHE BOOL "" FORCE)
set(WITH_IK_SOLVER OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_CINEON OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_OPENJPEG OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_WEBP OFF CACHE BOOL "" FORCE)
set(WITH_INPUT_IME OFF CACHE BOOL "" FORCE)
set(WITH_INPUT_NDOF OFF CACHE BOOL "" FORCE)
set(WITH_INTERNATIONAL OFF CACHE BOOL "" FORCE)
set(WITH_IO_PLY OFF CACHE BOOL "" FORCE)
set(WITH_IO_STL OFF CACHE BOOL "" FORCE)
set(WITH_IO_WAVEFRONT_OBJ OFF CACHE BOOL "" FORCE)
set(WITH_IO_GREASE_PENCIL OFF CACHE BOOL "" FORCE)
set(WITH_IO_FBX OFF CACHE BOOL "" FORCE)
set(WITH_JACK OFF CACHE BOOL "" FORCE)
set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
set(WITH_LLVM OFF CACHE BOOL "" FORCE)
set(WITH_MANIFOLD OFF CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID OFF CACHE BOOL "" FORCE)
set(WITH_MOD_OCEANSIM OFF CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH OFF CACHE BOOL "" FORCE)
set(WITH_UV_SLIM OFF CACHE BOOL "" FORCE)
set(WITH_NANOVDB OFF CACHE BOOL "" FORCE)
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEDENOISE OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
set(WITH_OPENVDB OFF CACHE BOOL "" FORCE)
set(WITH_POTRACE OFF CACHE BOOL "" FORCE)
set(WITH_PUGIXML OFF CACHE BOOL "" FORCE)
set(WITH_PULSEAUDIO OFF CACHE BOOL "" FORCE)
set(WITH_PIPEWIRE OFF CACHE BOOL "" FORCE)
set(WITH_QUADRIFLOW OFF CACHE BOOL "" FORCE)
set(WITH_RUBBERBAND OFF CACHE BOOL "" FORCE)
set(WITH_SDL_AUDIO OFF CACHE BOOL "" FORCE)
set(WITH_TBB_MALLOC_PROXY OFF CACHE BOOL "" FORCE)
set(WITH_USD OFF CACHE BOOL "" FORCE)
set(WITH_MATERIALX OFF CACHE BOOL "" FORCE)
set(WITH_XR_OPENXR OFF CACHE BOOL "" FORCE)
set(WITH_ASSERT_RELEASE ON CACHE BOOL "" FORCE)
if(UNIX AND NOT APPLE)
set(WITH_GHOST_WAYLAND ON CACHE BOOL "" FORCE)
set(WITH_GHOST_X11 OFF CACHE BOOL "" FORCE)
# Keep X11 options so the build is still "lite" if X11 is enabled.
set(WITH_GHOST_XDND OFF CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT OFF CACHE BOOL "" FORCE)
elseif(WIN32)
set(WITH_WASAPI OFF CACHE BOOL "" FORCE)
elseif(APPLE)
set(WITH_COREAUDIO OFF CACHE BOOL "" FORCE)
endif()
# These should not have any impact but are disabled so they don't
# appear to be enabled in the list of items (which are mostly OFF).
set(WITH_CYCLES_DEVICE_OPTIX OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_EMBREE OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_PATH_GUIDING OFF CACHE BOOL "" FORCE)
set(WITH_OPENVDB_BLOSC OFF CACHE BOOL "" FORCE)

View File

@@ -0,0 +1,112 @@
# SPDX-FileCopyrightText: 2014-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Turn everything ON that's expected for an official release builds.
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/blender_release.cmake ../blender
#
# NOTE: the build-bot supports configuration overrides for some of these settings.
# This means the daily-builds may not match this configuration *exactly*,
# see: `build_files/buildbot/config/*.cmake`.
set(WITH_ALEMBIC ON CACHE BOOL "" FORCE)
set(WITH_ASSERT_ABORT OFF CACHE BOOL "" FORCE)
set(WITH_AUDASPACE ON CACHE BOOL "" FORCE)
set(WITH_BUILDINFO ON CACHE BOOL "" FORCE)
set(WITH_BULLET ON CACHE BOOL "" FORCE)
set(WITH_CODEC_FFMPEG ON CACHE BOOL "" FORCE)
set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_PATH_GUIDING ON CACHE BOOL "" FORCE)
set(WITH_DRACO ON CACHE BOOL "" FORCE)
set(WITH_MESHOPTIMIZER ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)
set(WITH_GMP ON CACHE BOOL "" FORCE)
set(WITH_HARU ON CACHE BOOL "" FORCE)
set(WITH_IK_ITASC ON CACHE BOOL "" FORCE)
set(WITH_IK_SOLVER ON CACHE BOOL "" FORCE)
set(WITH_IMAGE_CINEON ON CACHE BOOL "" FORCE)
set(WITH_IMAGE_OPENJPEG ON CACHE BOOL "" FORCE)
set(WITH_IMAGE_WEBP ON CACHE BOOL "" FORCE)
set(WITH_INPUT_NDOF ON CACHE BOOL "" FORCE)
set(WITH_INPUT_IME ON CACHE BOOL "" FORCE)
set(WITH_INTERNATIONAL ON CACHE BOOL "" FORCE)
set(WITH_IO_FBX ON CACHE BOOL "" FORCE)
set(WITH_IO_GREASE_PENCIL ON CACHE BOOL "" FORCE)
set(WITH_IO_PLY ON CACHE BOOL "" FORCE)
set(WITH_IO_STL ON CACHE BOOL "" FORCE)
set(WITH_IO_WAVEFRONT_OBJ ON CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
set(WITH_MANIFOLD ON CACHE BOOL "" FORCE)
set(WITH_MOD_FLUID ON CACHE BOOL "" FORCE)
set(WITH_MOD_OCEANSIM ON CACHE BOOL "" FORCE)
set(WITH_MOD_REMESH ON CACHE BOOL "" FORCE)
set(WITH_UV_SLIM ON CACHE BOOL "" FORCE)
set(WITH_NANOVDB ON CACHE BOOL "" FORCE)
set(WITH_OPENAL ON CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEDENOISE ON CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB ON CACHE BOOL "" FORCE)
set(WITH_OPENVDB_BLOSC ON CACHE BOOL "" FORCE)
set(WITH_POTRACE ON CACHE BOOL "" FORCE)
set(WITH_PUGIXML ON CACHE BOOL "" FORCE)
set(WITH_PYTHON_INSTALL ON CACHE BOOL "" FORCE)
set(WITH_QUADRIFLOW ON CACHE BOOL "" FORCE)
set(WITH_RUBBERBAND ON CACHE BOOL "" FORCE)
set(WITH_SDL_AUDIO OFF CACHE BOOL "" FORCE)
set(WITH_TBB ON CACHE BOOL "" FORCE)
set(WITH_USD ON CACHE BOOL "" FORCE)
set(WITH_MATERIALX ON CACHE BOOL "" FORCE)
set(WITH_HYDRA ON CACHE BOOL "" FORCE)
set(WITH_XR_OPENXR ON CACHE BOOL "" FORCE)
# platform dependent options
if(APPLE)
set(WITH_COREAUDIO ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_METAL ON CACHE BOOL "" FORCE)
set(WITH_BLENDER_THUMBNAILER ON CACHE BOOL "" FORCE)
endif()
if(WIN32)
set(WITH_WASAPI ON CACHE BOOL "" FORCE)
endif()
if(UNIX AND NOT APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_DOC_MANPAGE ON CACHE BOOL "" FORCE)
set(WITH_GHOST_XDND ON CACHE BOOL "" FORCE)
set(WITH_PULSEAUDIO ON CACHE BOOL "" FORCE)
set(WITH_X11_XINPUT ON CACHE BOOL "" FORCE)
set(WITH_JACK_DYNLOAD ON CACHE BOOL "" FORCE)
set(WITH_PULSEAUDIO_DYNLOAD ON CACHE BOOL "" FORCE)
# TODO don't disable pipewire on release builds once it has gotten more testing
set(WITH_PIPEWIRE OFF CACHE BOOL "" FORCE)
set(WITH_PIPEWIRE_DYNLOAD ON CACHE BOOL "" FORCE)
endif()
if(NOT APPLE)
set(_is_win32_arm64_target OFF)
if(WIN32)
if(DEFINED ENV{VSCMD_ARG_TGT_ARCH})
if("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "arm64")
# Can't use `CMAKE_SYSTEM_PROCESSOR` here as it's not set yet,
# so fall back to checking the environment for vcvarsall's `VSCMD_ARG_TGT_ARCH`.
set(_is_win32_arm64_target ON)
endif()
endif()
endif()
if(NOT _is_win32_arm64_target)
set(WITH_TBB_MALLOC_PROXY ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_HIPRT ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_OPTIX ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_CUDA_BINARIES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_HIP_BINARIES ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_DEVICE_ONEAPI ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_ONEAPI_BINARIES ON CACHE BOOL "" FORCE)
endif()
unset(_is_win32_arm64_target)
endif()

View File

@@ -0,0 +1,90 @@
# SPDX-FileCopyrightText: 2011-2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# defaults for building blender as a python module 'bpy'
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/bpy_module.cmake ../blender
#
set(WITH_PYTHON_MODULE ON CACHE BOOL "" FORCE)
# -----------------------------------------------------------------------------
# Installation Configuration.
#
# NOTE: `WITH_INSTALL_PORTABLE` always defaults to ON when building as a Python module and
# isn't set here as it makes changing the setting impractical.
# Python-developers could prefer either ON/OFF depending on their usage:
#
# - When using the system's Python, disabling will install into their `site-packages`,
# allowing them to run Python from any directory and `import bpy`.
# - When using Blender's bundled Python in `./../lib/` it will install there
# which isn't especially useful as it requires running Python from this directory too.
#
# So default `WITH_INSTALL_PORTABLE` to ON, and developers who don't use Python from `./../lib/`
# can disable it if they wish to install into their systems Python.
# There is no point in copying python into Python.
set(WITH_PYTHON_INSTALL OFF CACHE BOOL "" FORCE)
if(WIN32)
set(WITH_WINDOWS_BUNDLE_CRT OFF CACHE BOOL "" FORCE)
endif()
# -----------------------------------------------------------------------------
# Library Compatibility.
# NOTE: JEMALLOC caused problems with `dlopen()`,
# disabling for WITH_TBB_MALLOC_PROXY too, although we could investigate enabling it.
set(WITH_TBB_MALLOC_PROXY OFF CACHE BOOL "" FORCE)
# -----------------------------------------------------------------------------
# Application Support.
# Not useful to include with the Python module.
# Although a way to extract this from Python could be handle,
# this would be better exposed directly via the Python API.
set(WITH_BLENDER_THUMBNAILER OFF CACHE BOOL "" FORCE)
# -----------------------------------------------------------------------------
# Audio Support.
# Enable audio support without audio-device support
# so the sequencer can be used properly from Python, see: #125007.
set(WITH_AUDASPACE ON CACHE BOOL "" FORCE)
# Disable audio, it's possible some developers may want this but for now disable
# so the Python module doesn't hold the audio device and loads quickly.
set(WITH_JACK OFF CACHE BOOL "" FORCE)
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_SDL_AUDIO OFF CACHE BOOL "" FORCE)
if(UNIX AND NOT APPLE)
set(WITH_PULSEAUDIO OFF CACHE BOOL "" FORCE)
endif()
if(WIN32)
set(WITH_WASAPI OFF CACHE BOOL "" FORCE)
endif()
if(APPLE)
set(WITH_COREAUDIO OFF CACHE BOOL "" FORCE)
endif()
# -----------------------------------------------------------------------------
# Input Device Support.
# Other features which are not especially useful as a python module.
set(WITH_INPUT_NDOF OFF CACHE BOOL "" FORCE)
if(WIN32 OR APPLE)
set(WITH_INPUT_IME OFF CACHE BOOL "" FORCE)
endif()
# -----------------------------------------------------------------------------
# Language Support.
set(WITH_INTERNATIONAL OFF CACHE BOOL "" FORCE)

View File

@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2014-2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# only compile Cycles standalone, without Blender
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/cycles_standalone.cmake ../blender
#
# disable Blender
set(WITH_BLENDER OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES_BLENDER OFF CACHE BOOL "" FORCE)
# build Cycles
set(WITH_CYCLES_STANDALONE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES_STANDALONE_GUI ON CACHE BOOL "" FORCE)

View File

@@ -0,0 +1,43 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2010-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# This shell script checks out and compiles blender, tested on ubuntu 10.04
# assumes you have dependencies installed already
# See this page for more info:
# https://developer.blender.org/docs/handbook/building_blender/linux/
# grab blender
mkdir ~/blender-git
cd ~/blender-git
git clone https://projects.blender.org/blender/blender.git
cd blender
git submodule update --init --recursive
git submodule foreach git checkout main
git submodule foreach git pull --rebase origin main
# create build dir
mkdir ~/blender-git/build-cmake
cd ~/blender-git/build-cmake
# cmake without copying files for fast rebuilds
# the files from git will be used in place
cmake ../blender
# make blender, will take some time
make -j$(nproc)
# link the binary to Blender's source directory to run quickly
ln -s ~/blender-git/build-cmake/bin/blender ~/blender-git/blender/blender.bin
# useful info
echo ""
echo "* Useful Commands *"
echo " Run Blender: ~/blender-git/blender/blender.bin"
echo " Update Blender: git pull --rebase; git submodule foreach git pull --rebase origin main"
echo " Reconfigure Blender: cd ~/blender-git/build-cmake ; cmake ."
echo " Build Blender: cd ~/blender-git/build-cmake ; make"
echo ""

View File

@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2025 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(GENERATE_DATAMODELS_SCRIPT "${CMAKE_SOURCE_DIR}/tools/utils/make_generate_datamodels.py")
add_custom_target(generate_datamodels
COMMAND ${PYTHON_EXECUTABLE} ${GENERATE_DATAMODELS_SCRIPT} ${CMAKE_SOURCE_DIR}
DEPENDS ${GENERATE_DATAMODELS_SCRIPT}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating datamodels"
VERBATIM
)

View File

@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# This file is used to test the system for headers & symbols.
# Variables should use the `HAVE_` prefix.
# Defines should use the same name as the CMAKE variable.
include(CheckSymbolExists)
# Used for: `intern/guardedalloc/intern/mallocn_intern.hh`.
# Function `malloc_stats` is only available on GLIBC,
# so check that before defining `HAVE_MALLOC_STATS`.
check_symbol_exists(malloc_stats "malloc.h" HAVE_MALLOC_STATS_H)
# Used for: `source/creator/creator_signals.c`.
# The function `feenableexcept` is not present non-GLIBC systems,
# hence we need to check if it's available in the `fenv.h` file.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
check_symbol_exists(feenableexcept "fenv.h" HAVE_FEENABLEEXCEPT)
endif()
if(NOT DEFINED HAVE_FEENABLEEXCEPT)
set(HAVE_FEENABLEEXCEPT 0)
endif()
# Used for: `source/blender/blenlib/intern/system.c`.
# `execinfo` is not available on non-GLIBC systems (at least not on MUSL-LIBC),
# so check the presence of the header before including it and using it for back-trace.
if(NOT MSVC)
include(CheckIncludeFiles)
check_include_files("execinfo.h" HAVE_EXECINFO_H)
if(HAVE_EXECINFO_H)
add_definitions(-DHAVE_EXECINFO_H)
endif()
endif()
if(NOT DEFINED HAVE_EXECINFO_H)
set(HAVE_EXECINFO_H 0)
endif()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
# SPDX-FileCopyrightText: 2011-2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
string(TIMESTAMP CURRENT_YEAR "%Y")
set(PROJECT_DESCRIPTION "Blender is the free and open source 3D creation suite software.")
set(PROJECT_COPYRIGHT "Copyright (C) 2001-${CURRENT_YEAR} Blender Authors")
set(PROJECT_CONTACT "foundation@blender.org")
set(PROJECT_VENDOR "Blender Foundation")
set(MAJOR_VERSION ${BLENDER_VERSION_MAJOR})
set(MINOR_VERSION ${BLENDER_VERSION_MINOR})
set(PATCH_VERSION ${BLENDER_VERSION_PATCH})
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
set(CPACK_PACKAGE_DESCRIPTION ${PROJECT_DESCRIPTION})
set(CPACK_PACKAGE_VENDOR ${PROJECT_VENDOR})
set(CPACK_PACKAGE_CONTACT ${PROJECT_CONTACT})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
set(CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}")
# Get the build revision, note that this can get out-of-sync, so for packaging run cmake first.
set(MY_WC_HASH "unknown")
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/)
find_package(Git)
if(GIT_FOUND)
# message(STATUS "Found Git: ${GIT_EXECUTABLE}")
execute_process(
COMMAND git rev-parse --short=12 HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
endif()
set(BUILD_REV ${MY_WC_HASH})
unset(MY_WC_HASH)
# Force Package Name
execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE CPACK_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
if(MSVC)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(PACKAGE_ARCH windows64)
else()
set(PACKAGE_ARCH windows32)
endif()
else()
set(PACKAGE_ARCH ${CMAKE_SYSTEM_PROCESSOR})
endif()
if(CPACK_OVERRIDE_PACKAGENAME)
set(CPACK_PACKAGE_FILE_NAME ${CPACK_OVERRIDE_PACKAGENAME}-${PACKAGE_ARCH})
else()
set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME_LOWER}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-git${CPACK_DATE}.${BUILD_REV}-${PACKAGE_ARCH})
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# RPM packages
include(build_files/cmake/RpmBuild.cmake)
if(RPMBUILD_FOUND)
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_RELEASE "git${CPACK_DATE}.${BUILD_REV}")
set(CPACK_SET_DESTDIR "true")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_RELOCATABLE "false")
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2+ and Apache 2.0")
set(CPACK_RPM_PACKAGE_GROUP "Amusements/Multimedia")
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/build_files/package_spec/rpm/blender.spec.in")
endif()
endif()
# Mac Bundle
if(APPLE)
set(CPACK_GENERATOR "DragNDrop")
# Libraries are bundled directly
set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE)
endif()
if(WIN32)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Blender Foundation/Blender ${MAJOR_VERSION}.${MINOR_VERSION}")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "Blender Foundation/Blender ${MAJOR_VERSION}.${MINOR_VERSION}")
set(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.ico)
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
# Even though we no longer display this, we still need to set it otherwise it'll throw an error
# during the msi build.
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/release/license/spdx/GPL-3.0-or-later.txt)
set(CPACK_WIX_PRODUCT_ICON ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.ico)
set(BLENDER_NAMESPACE_GUID "507F933F-5898-404A-9A05-18282FD491A6")
string(UUID CPACK_WIX_UPGRADE_GUID
NAMESPACE ${BLENDER_NAMESPACE_GUID}
NAME ${CPACK_PACKAGE_INSTALL_DIRECTORY}
TYPE SHA1 UPPER
)
set(CPACK_WIX_TEMPLATE ${CMAKE_SOURCE_DIR}/release/windows/installer_wix/WIX.template)
set(CPACK_WIX_UI_BANNER ${CMAKE_SOURCE_DIR}/release/windows/installer_wix/WIX_UI_BANNER.bmp)
set(CPACK_WIX_UI_DIALOG ${CMAKE_SOURCE_DIR}/release/windows/installer_wix/WIX_UI_DIALOG.png)
set(CPACK_WIX_EXTRA_SOURCES ${CMAKE_SOURCE_DIR}/release/windows/installer_wix/WixUI_Blender.wxs)
set(CPACK_WIX_UI_REF "WixUI_Blender")
set(CPACK_WIX_LIGHT_EXTRA_FLAGS -dcl:medium)
endif()
set(CPACK_PACKAGE_EXECUTABLES "blender-launcher" "Blender ${MAJOR_VERSION}.${MINOR_VERSION}")
set(CPACK_CREATE_DESKTOP_LINKS "blender-launcher" "Blender ${MAJOR_VERSION}.${MINOR_VERSION}")
include(CPack)
# Target for build_archive.py script, to automatically pass along
# version, revision, platform, build directory
function(add_package_archive packagename extension)
set(build_archive python ${CMAKE_SOURCE_DIR}/build_files/package_spec/build_archive.py)
set(package_output ${CMAKE_BINARY_DIR}/release/${packagename}.${extension})
add_custom_target(package_archive DEPENDS ${package_output})
add_custom_command(
OUTPUT ${package_output}
COMMAND ${build_archive} ${packagename} ${extension} bin release
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endfunction()
if(APPLE)
add_package_archive(
"${PROJECT_NAME}-${BLENDER_VERSION}-${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}"
"zip"
)
elseif(UNIX)
# platform name could be tweaked, to include glibc, and ensure processor is correct (i386 vs i686)
string(TOLOWER ${CMAKE_SYSTEM_NAME} PACKAGE_SYSTEM_NAME)
add_package_archive(
"${PROJECT_NAME}-${BLENDER_VERSION}-${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}"
"tar.xz"
)
endif()
unset(MAJOR_VERSION)
unset(MINOR_VERSION)
unset(PATCH_VERSION)
unset(BUILD_REV)

View File

@@ -0,0 +1,516 @@
# SPDX-FileCopyrightText: 2024 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Common modern targets for the blender dependencies
#
# The optional dependencies in the bf::dependencies::optional namespace
# will always exist, but will only be populated if the dep is actually
# enabled. Doing it this way, prevents us from having to sprinkle
# if(WITH_SOMEDEP) all over cmake, and you can just add
# `bf::dependencies::optional::somedep` to the LIB section without
# having to worry if it's enabled or not at the consumer site.
# -----------------------------------------------------------------------------
# Configure TBB
add_library(bf_deps_optional_tbb INTERFACE)
add_library(bf::dependencies::optional::tbb ALIAS bf_deps_optional_tbb)
if(WITH_TBB)
target_compile_definitions(bf_deps_optional_tbb INTERFACE WITH_TBB)
target_include_directories(bf_deps_optional_tbb SYSTEM INTERFACE ${TBB_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_tbb INTERFACE ${TBB_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Manifold
add_library(bf_deps_optional_manifold INTERFACE)
add_library(bf::dependencies::optional::manifold ALIAS bf_deps_optional_manifold)
if(WITH_MANIFOLD)
if(WIN32)
target_compile_definitions(bf_deps_optional_manifold INTERFACE WITH_MANIFOLD)
target_include_directories(bf_deps_optional_manifold SYSTEM INTERFACE ${MANIFOLD_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_manifold INTERFACE ${MANIFOLD_LIBRARIES} bf::dependencies::optional::tbb)
else()
if(TARGET manifold::manifold)
target_compile_definitions(bf_deps_optional_manifold INTERFACE WITH_MANIFOLD)
target_link_libraries(bf_deps_optional_manifold INTERFACE manifold::manifold)
endif()
endif()
endif()
# -----------------------------------------------------------------------------
# Configure OpenVDB
add_library(bf_deps_optional_openvdb INTERFACE)
add_library(bf::dependencies::optional::openvdb ALIAS bf_deps_optional_openvdb)
if(WITH_OPENVDB)
target_compile_definitions(bf_deps_optional_openvdb INTERFACE WITH_OPENVDB)
if(WITH_OPENVDB_BLOSC)
target_compile_definitions(bf_deps_optional_openvdb INTERFACE WITH_OPENVDB_BLOSC)
endif()
if(WITH_OPENVDB_3_ABI_COMPATIBLE)
target_compile_definitions(bf_deps_optional_openvdb INTERFACE OPENVDB_3_ABI_COMPATIBLE)
endif()
target_include_directories(bf_deps_optional_openvdb SYSTEM INTERFACE ${OPENVDB_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_openvdb
INTERFACE
${OPENVDB_LIBRARIES}
bf::dependencies::optional::tbb
)
endif()
# -----------------------------------------------------------------------------
# Configure Ceres
add_library(bf_deps_optional_ceres INTERFACE)
add_library(bf::dependencies::optional::ceres ALIAS bf_deps_optional_ceres)
if(TARGET Ceres::ceres)
target_compile_definitions(bf_deps_optional_ceres INTERFACE WITH_CERES)
target_link_libraries(bf_deps_optional_ceres INTERFACE Ceres::ceres)
endif()
# -----------------------------------------------------------------------------
# Configure Eigen
add_library(bf_deps_eigen INTERFACE)
add_library(bf::dependencies::eigen ALIAS bf_deps_eigen)
target_link_libraries(bf_deps_eigen INTERFACE Eigen3::Eigen)
if(WITH_TBB)
target_compile_definitions(bf_deps_eigen INTERFACE EIGEN_HAS_TBB)
target_include_directories(bf_deps_eigen SYSTEM INTERFACE ${TBB_INCLUDE_DIRS})
target_link_libraries(bf_deps_eigen INTERFACE ${TBB_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure OpenColorIO
add_library(bf::dependencies::opencolorio ALIAS OpenColorIO::OpenColorIO)
# -----------------------------------------------------------------------------
# Configure Zlib
add_library(bf_deps_zlib INTERFACE)
add_library(bf::dependencies::zlib ALIAS bf_deps_zlib)
target_include_directories(bf_deps_zlib SYSTEM INTERFACE ${ZLIB_INCLUDE_DIRS})
target_link_libraries(bf_deps_zlib INTERFACE ${ZLIB_LIBRARIES})
# -----------------------------------------------------------------------------
# Configure ZSTD
add_library(bf_deps_zstd INTERFACE)
add_library(bf::dependencies::zstd ALIAS bf_deps_zstd)
target_include_directories(bf_deps_zstd SYSTEM INTERFACE ${ZSTD_INCLUDE_DIRS})
target_link_libraries(bf_deps_zstd INTERFACE ${ZSTD_LIBRARIES})
# -----------------------------------------------------------------------------
# Configure Freetype
add_library(bf_deps_freetype INTERFACE)
add_library(bf::dependencies::freetype ALIAS bf_deps_freetype)
target_include_directories(bf_deps_freetype SYSTEM INTERFACE ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(bf_deps_freetype INTERFACE ${FREETYPE_LIBRARIES} ${BROTLI_LIBRARIES})
# -----------------------------------------------------------------------------
# Configure JPEG
add_library(bf_deps_jpeg INTERFACE)
add_library(bf::dependencies::jpeg ALIAS bf_deps_jpeg)
target_include_directories(bf_deps_jpeg SYSTEM INTERFACE ${JPEG_INCLUDE_DIR})
target_link_libraries(bf_deps_jpeg INTERFACE ${JPEG_LIBRARIES})
# -----------------------------------------------------------------------------
# Configure PNG
add_library(bf_deps_png INTERFACE)
add_library(bf::dependencies::png ALIAS bf_deps_png)
target_include_directories(bf_deps_png SYSTEM INTERFACE ${PNG_INCLUDE_DIRS})
target_link_libraries(bf_deps_png INTERFACE ${PNG_LIBRARIES})
# -----------------------------------------------------------------------------
# Configure OpenImageIO
add_library(bf::dependencies::openimageio ALIAS OpenImageIO::OpenImageIO)
get_target_property(OPENIMAGEIO_TOOL OpenImageIO::oiiotool LOCATION)
# -----------------------------------------------------------------------------
# Configure USD
add_library(bf_deps_optional_usd INTERFACE)
add_library(bf::dependencies::optional::usd ALIAS bf_deps_optional_usd)
if(WITH_USD)
target_compile_definitions(bf_deps_optional_usd INTERFACE WITH_USD)
target_include_directories(bf_deps_optional_usd SYSTEM INTERFACE ${USD_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_usd INTERFACE ${USD_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Alembic
add_library(bf_deps_optional_alembic INTERFACE)
add_library(bf::dependencies::optional::alembic ALIAS bf_deps_optional_alembic)
if(WITH_ALEMBIC)
target_compile_definitions(bf_deps_optional_alembic INTERFACE WITH_ALEMBIC)
target_include_directories(bf_deps_optional_alembic SYSTEM INTERFACE ${ALEMBIC_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_alembic INTERFACE ${ALEMBIC_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure OpenSubdiv
add_library(bf_deps_optional_opensubdiv INTERFACE)
add_library(bf::dependencies::optional::opensubdiv ALIAS bf_deps_optional_opensubdiv)
if(WITH_OPENSUBDIV)
target_compile_definitions(bf_deps_optional_opensubdiv INTERFACE WITH_OPENSUBDIV)
target_include_directories(bf_deps_optional_opensubdiv SYSTEM INTERFACE ${OPENSUBDIV_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_opensubdiv INTERFACE ${OPENSUBDIV_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure OpenEXR
add_library(bf::dependencies::openexr ALIAS OpenEXR::OpenEXR)
# -----------------------------------------------------------------------------
# Configure WebP
add_library(bf_deps_optional_webp INTERFACE)
add_library(bf::dependencies::optional::webp ALIAS bf_deps_optional_webp)
if(WITH_IMAGE_WEBP)
target_compile_definitions(bf_deps_optional_webp INTERFACE WITH_IMAGE_WEBP)
target_include_directories(bf_deps_optional_webp SYSTEM INTERFACE ${WEBP_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_webp INTERFACE ${WEBP_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure OpenJPEG
add_library(bf_deps_optional_openjpeg INTERFACE)
add_library(bf::dependencies::optional::openjpeg ALIAS bf_deps_optional_openjpeg)
if(WITH_IMAGE_OPENJPEG)
target_compile_definitions(bf_deps_optional_openjpeg INTERFACE WITH_IMAGE_OPENJPEG)
target_compile_definitions(bf_deps_optional_openjpeg INTERFACE ${OPENJPEG_DEFINES})
target_include_directories(bf_deps_optional_openjpeg SYSTEM INTERFACE ${OPENJPEG_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_openjpeg INTERFACE ${OPENJPEG_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure SDL
add_library(bf_deps_optional_sdl INTERFACE)
add_library(bf::dependencies::optional::sdl ALIAS bf_deps_optional_sdl)
if(WITH_SDL)
target_link_libraries(bf_deps_optional_sdl INTERFACE SDL3::SDL3)
endif()
# -----------------------------------------------------------------------------
# Configure FFmpeg
add_library(bf_deps_optional_ffmpeg INTERFACE)
add_library(bf::dependencies::optional::ffmpeg ALIAS bf_deps_optional_ffmpeg)
if(WITH_CODEC_FFMPEG)
target_compile_definitions(bf_deps_optional_ffmpeg INTERFACE WITH_FFMPEG)
target_include_directories(bf_deps_optional_ffmpeg SYSTEM INTERFACE ${FFMPEG_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_ffmpeg INTERFACE ${FFMPEG_LIBRARIES})
if(WITH_IMAGE_OPENJPEG)
target_link_libraries(bf_deps_optional_ffmpeg INTERFACE ${OPENJPEG_LIBRARIES})
endif()
endif()
# -----------------------------------------------------------------------------
# Configure Python
add_library(bf_deps_optional_python INTERFACE)
add_library(bf::dependencies::optional::python ALIAS bf_deps_optional_python)
if(WITH_PYTHON)
target_compile_definitions(bf_deps_optional_python INTERFACE WITH_PYTHON)
target_include_directories(bf_deps_optional_python SYSTEM INTERFACE ${PYTHON_INCLUDE_DIR})
target_link_libraries(bf_deps_optional_python INTERFACE ${PYTHON_LINKFLAGS})
if(WITH_PYTHON_MODULE)
target_compile_definitions(bf_deps_optional_python INTERFACE WITH_PYTHON_MODULE)
else()
target_link_libraries(bf_deps_optional_python INTERFACE ${PYTHON_LIBRARIES})
endif()
endif()
# -----------------------------------------------------------------------------
# Configure GMP
add_library(bf_deps_optional_gmp INTERFACE)
add_library(bf::dependencies::optional::gmp ALIAS bf_deps_optional_gmp)
if(WITH_GMP)
target_compile_definitions(bf_deps_optional_gmp INTERFACE WITH_GMP)
target_include_directories(bf_deps_optional_gmp SYSTEM INTERFACE ${GMP_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_gmp INTERFACE ${GMP_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure PugiXML
add_library(bf_deps_optional_pugixml INTERFACE)
add_library(bf::dependencies::optional::pugixml ALIAS bf_deps_optional_pugixml)
if(WITH_PUGIXML)
target_compile_definitions(bf_deps_optional_pugixml INTERFACE WITH_PUGIXML)
target_include_directories(bf_deps_optional_pugixml SYSTEM INTERFACE ${PUGIXML_INCLUDE_DIR})
target_link_libraries(bf_deps_optional_pugixml INTERFACE ${PUGIXML_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Haru
add_library(bf_deps_optional_haru INTERFACE)
add_library(bf::dependencies::optional::haru ALIAS bf_deps_optional_haru)
if(WITH_HARU)
target_compile_definitions(bf_deps_optional_haru INTERFACE WITH_HARU)
target_include_directories(bf_deps_optional_haru SYSTEM INTERFACE ${HARU_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_haru INTERFACE ${HARU_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Vulkan
add_library(bf_deps_optional_vulkan INTERFACE)
add_library(bf::dependencies::optional::vulkan ALIAS bf_deps_optional_vulkan)
if(WITH_VULKAN_BACKEND)
target_include_directories(bf_deps_optional_vulkan SYSTEM INTERFACE ${VULKAN_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_vulkan INTERFACE ${VULKAN_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure ShaderC
add_library(bf_deps_optional_shaderc INTERFACE)
add_library(bf::dependencies::optional::shaderc ALIAS bf_deps_optional_shaderc)
if(WITH_VULKAN_BACKEND)
target_compile_definitions(bf_deps_optional_shaderc INTERFACE WITH_SHADERC)
target_include_directories(bf_deps_optional_shaderc SYSTEM INTERFACE ${SHADERC_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_shaderc INTERFACE ${SHADERC_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Embree
add_library(bf_deps_optional_embree INTERFACE)
add_library(bf::dependencies::optional::embree ALIAS bf_deps_optional_embree)
if(WITH_CYCLES_EMBREE)
target_include_directories(bf_deps_optional_embree SYSTEM INTERFACE ${EMBREE_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_embree INTERFACE ${EMBREE_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure OpenPGL
add_library(bf_deps_optional_openpgl INTERFACE)
add_library(bf::dependencies::optional::openpgl ALIAS bf_deps_optional_openpgl)
if(WITH_CYCLES_PATH_GUIDING)
target_include_directories(bf_deps_optional_openpgl SYSTEM INTERFACE ${OPENPGL_INCLUDE_DIR})
target_link_libraries(bf_deps_optional_openpgl INTERFACE ${OPENPGL_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure NanoVDB
add_library(bf_deps_optional_nanovdb INTERFACE)
add_library(bf::dependencies::optional::nanovdb ALIAS bf_deps_optional_nanovdb)
if(WITH_NANOVDB)
target_include_directories(bf_deps_optional_nanovdb SYSTEM INTERFACE ${NANOVDB_INCLUDE_DIR})
endif()
# -----------------------------------------------------------------------------
# Configure Epoxy
add_library(bf_deps_epoxy INTERFACE)
add_library(bf::dependencies::epoxy ALIAS bf_deps_epoxy)
target_include_directories(bf_deps_epoxy SYSTEM INTERFACE ${EPOXY_INCLUDE_DIRS})
target_link_libraries(bf_deps_epoxy INTERFACE ${EPOXY_LIBRARIES})
# -----------------------------------------------------------------------------
# Configure Gflags
add_library(bf_deps_gflags INTERFACE)
add_library(bf::dependencies::gflags ALIAS bf_deps_gflags)
if(WITH_LIBMV OR WITH_GTESTS)
target_compile_definitions(bf_deps_gflags INTERFACE ${GFLAGS_DEFINES})
target_include_directories(bf_deps_gflags SYSTEM INTERFACE ${GFLAGS_INCLUDE_DIRS})
target_link_libraries(bf_deps_gflags INTERFACE ${GFLAGS_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Glog
add_library(bf_deps_glog INTERFACE)
add_library(bf::dependencies::glog ALIAS bf_deps_glog)
if(WITH_LIBMV OR WITH_GTESTS)
target_compile_definitions(bf_deps_glog INTERFACE ${GLOG_DEFINES})
target_include_directories(bf_deps_glog SYSTEM INTERFACE ${GLOG_INCLUDE_DIRS})
target_link_libraries(bf_deps_glog INTERFACE ${GLOG_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure OpenImageDenoise
add_library(bf_deps_optional_openimagedenoise INTERFACE)
add_library(bf::dependencies::optional::openimagedenoise ALIAS bf_deps_optional_openimagedenoise)
if(WITH_OPENIMAGEDENOISE)
target_compile_definitions(bf_deps_optional_openimagedenoise INTERFACE WITH_OPENIMAGEDENOISE)
target_compile_definitions(bf_deps_optional_openimagedenoise INTERFACE OIDN_STATIC_LIB)
target_include_directories(bf_deps_optional_openimagedenoise SYSTEM INTERFACE ${OPENIMAGEDENOISE_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_openimagedenoise INTERFACE ${OPENIMAGEDENOISE_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure FFTW3
add_library(bf_deps_optional_fftw3 INTERFACE)
add_library(bf::dependencies::optional::fftw3 ALIAS bf_deps_optional_fftw3)
if(WITH_FFTW3)
target_compile_definitions(bf_deps_optional_fftw3 INTERFACE WITH_FFTW3)
target_include_directories(bf_deps_optional_fftw3 SYSTEM INTERFACE ${FFTW3_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_fftw3 INTERFACE ${FFTW3_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Bullet
add_library(bf_deps_optional_bullet INTERFACE)
add_library(bf::dependencies::optional::bullet ALIAS bf_deps_optional_bullet)
if(WITH_BULLET)
target_compile_definitions(bf_deps_optional_bullet INTERFACE WITH_BULLET)
target_include_directories(bf_deps_optional_bullet SYSTEM INTERFACE ${BULLET_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_bullet INTERFACE ${BULLET_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Audaspace
add_library(bf_deps_optional_audaspace INTERFACE)
add_library(bf::dependencies::optional::audaspace ALIAS bf_deps_optional_audaspace)
if(WITH_AUDASPACE)
target_compile_definitions(bf_deps_optional_audaspace INTERFACE WITH_AUDASPACE)
if(WITH_RUBBERBAND)
target_compile_definitions(bf_deps_optional_audaspace INTERFACE WITH_RUBBERBAND)
endif()
target_include_directories(bf_deps_optional_audaspace SYSTEM INTERFACE ${AUDASPACE_C_INCLUDE_DIRS} ${AUDASPACE_PY_INCLUDE_DIRS})
if(WITH_SYSTEM_AUDASPACE)
target_link_libraries(bf_deps_optional_audaspace INTERFACE ${AUDASPACE_LIBRARIES} ${AUDASPACE_PY_LIBRARIES})
else()
target_link_libraries(bf_deps_optional_audaspace INTERFACE audaspace audaspace-py)
endif()
endif()
# -----------------------------------------------------------------------------
# Configure Potrace
add_library(bf_deps_optional_potrace INTERFACE)
add_library(bf::dependencies::optional::potrace ALIAS bf_deps_optional_potrace)
if(WITH_POTRACE)
target_compile_definitions(bf_deps_optional_potrace INTERFACE WITH_POTRACE)
target_include_directories(bf_deps_optional_potrace SYSTEM INTERFACE ${POTRACE_INCLUDE_DIRS})
target_link_libraries(bf_deps_optional_potrace INTERFACE ${POTRACE_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure Pthreads
#
add_library(bf_deps_pthreads INTERFACE)
add_library(bf::dependencies::pthreads ALIAS bf_deps_pthreads)
# Include directories on non-Windows are handled globally.
if(WIN32 AND NOT UNIX)
target_include_directories(bf_deps_pthreads SYSTEM INTERFACE ${PTHREADS_INC})
endif()
if(DEFINED PTHREADS_LIBRARIES)
target_link_libraries(bf_deps_pthreads INTERFACE ${PTHREADS_LIBRARIES})
endif()
# -----------------------------------------------------------------------------
# Configure libfmt
#
add_library(bf::dependencies::fmt ALIAS fmt::fmt)
# -----------------------------------------------------------------------------
# Configure OSL
if(WITH_CYCLES_OSL)
add_library(bf_deps_optional_osl INTERFACE)
target_link_libraries(bf_deps_optional_osl INTERFACE OSL::oslcomp OSL::oslquery OSL::oslnoise)
# Link oslexec with the -force_load flag on macOS.
if(APPLE)
target_link_libraries(bf_deps_optional_osl INTERFACE -force_load OSL::oslexec)
else()
target_link_libraries(bf_deps_optional_osl INTERFACE OSL::oslexec)
endif()
add_library(bf::dependencies::optional::osl ALIAS bf_deps_optional_osl)
get_target_property(OSL_COMPILER OSL::oslc LOCATION)
else()
add_library(bf_deps_optional_osl INTERFACE)
add_library(bf::dependencies::optional::osl ALIAS bf_deps_optional_osl)
endif()
# -----------------------------------------------------------------------------
# Configure Draco
add_library(bf_deps_optional_draco INTERFACE)
add_library(bf::dependencies::optional::draco ALIAS bf_deps_optional_draco)
if(TARGET draco::draco)
target_compile_definitions(bf_deps_optional_draco INTERFACE WITH_DRACO)
target_link_libraries(bf_deps_optional_draco INTERFACE draco::draco)
endif()
# -----------------------------------------------------------------------------
# Configure meshoptimizer
add_library(bf_deps_optional_meshoptimizer INTERFACE)
add_library(bf::dependencies::optional::meshoptimizer ALIAS bf_deps_optional_meshoptimizer)
if(TARGET meshoptimizer::meshoptimizer)
target_compile_definitions(bf_deps_optional_meshoptimizer INTERFACE WITH_MESHOPTIMIZER)
target_link_libraries(bf_deps_optional_meshoptimizer INTERFACE meshoptimizer::meshoptimizer)
endif()
# -----------------------------------------------------------------------------
# Configure TracyClient
add_library(bf_deps_optional_tracy_client INTERFACE)
add_library(bf::dependencies::optional::tracy_client ALIAS bf_deps_optional_tracy_client)
if(WITH_TRACY)
target_compile_definitions(bf_deps_optional_tracy_client INTERFACE WITH_TRACY)
target_link_libraries(bf_deps_optional_tracy_client INTERFACE Tracy::TracyClient)
endif()

View File

@@ -0,0 +1,508 @@
# SPDX-FileCopyrightText: 2016 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Libraries configuration for Apple.
function(find_package_wrapper)
# do nothing, just satisfy the function
endfunction()
function(print_found_status
lib_name
lib_path
)
if(FIRST_RUN)
if(lib_path)
message(STATUS "Found ${lib_name}: ${lib_path}")
else()
message(WARNING "Could NOT find ${lib_name}")
endif()
endif()
endfunction()
# ------------------------------------------------------------------------
# Find system provided libraries.
# Find system ZLIB
set(ZLIB_ROOT /usr)
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)
list(APPEND ZLIB_LIBRARIES ${BZIP2_LIBRARIES})
if(WITH_OPENAL)
find_package(OpenAL REQUIRED)
endif()
if(WITH_JACK)
find_library(JACK_FRAMEWORK
NAMES jackmp
)
if(JACK_FRAMEWORK)
set(JACK_INCLUDE_DIRS ${JACK_FRAMEWORK}/headers)
else()
set_and_warn_library_found("JACK" JACK_FRAMEWORK WITH_JACK)
endif()
endif()
if(NOT DEFINED LIBDIR)
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
set(LIBDIR ${CMAKE_SOURCE_DIR}/lib/macos_x64)
else()
set(LIBDIR ${CMAKE_SOURCE_DIR}/lib/macos_${CMAKE_OSX_ARCHITECTURES})
endif()
endif()
if(NOT EXISTS "${LIBDIR}/.git")
message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'")
endif()
if(FIRST_RUN)
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
endif()
# Avoid searching for headers since this would otherwise override our lib
# directory as well as PYTHON_ROOT_DIR.
set(CMAKE_FIND_FRAMEWORK NEVER)
# Optionally use system Python if PYTHON_ROOT_DIR is specified.
if(WITH_PYTHON)
if(WITH_PYTHON_MODULE AND PYTHON_ROOT_DIR)
find_package(PythonLibsUnix REQUIRED)
endif()
else()
# Python executable is needed as part of the build-process,
# note that building without Python is quite unusual.
find_program(PYTHON_EXECUTABLE "python3")
endif()
# Prefer lib directory paths
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
set(CMAKE_PREFIX_PATH ${LIB_SUBDIRS})
# -------------------------------------------------------------------------
# Find precompiled libraries, and avoid system or user-installed ones.
if(EXISTS ${LIBDIR})
include(platform_old_libs_update)
without_system_libs_begin()
endif()
if(WITH_ALEMBIC)
find_package(Alembic)
endif()
if(WITH_USD)
find_package(USD REQUIRED)
endif()
add_bundled_libraries(usd/lib)
if(WITH_MATERIALX)
find_package(MaterialX)
set_and_warn_library_found("MaterialX" MaterialX_FOUND WITH_MATERIALX)
endif()
add_bundled_libraries(materialx/lib)
if(WITH_OPENSUBDIV)
find_package(OpenSubdiv)
endif()
add_bundled_libraries(opensubdiv/lib)
if(WITH_CODEC_SNDFILE)
find_package(SndFile)
find_library(_sndfile_FLAC_LIBRARY NAMES flac HINTS ${LIBDIR}/sndfile/lib)
find_library(_sndfile_OGG_LIBRARY NAMES ogg HINTS ${LIBDIR}/ffmpeg/lib)
find_library(_sndfile_VORBIS_LIBRARY NAMES vorbis HINTS ${LIBDIR}/ffmpeg/lib)
find_library(_sndfile_VORBISENC_LIBRARY NAMES vorbisenc HINTS ${LIBDIR}/ffmpeg/lib)
list(APPEND LIBSNDFILE_LIBRARIES
${_sndfile_FLAC_LIBRARY}
${_sndfile_OGG_LIBRARY}
${_sndfile_VORBIS_LIBRARY}
${_sndfile_VORBISENC_LIBRARY}
)
print_found_status("SndFile libraries" "${LIBSNDFILE_LIBRARIES}")
unset(_sndfile_FLAC_LIBRARY)
unset(_sndfile_OGG_LIBRARY)
unset(_sndfile_VORBIS_LIBRARY)
unset(_sndfile_VORBISENC_LIBRARY)
endif()
if(WITH_PYTHON)
if(NOT (WITH_PYTHON_MODULE AND PYTHON_ROOT_DIR))
find_package(PythonLibsUnix REQUIRED)
endif()
endif()
if(WITH_FFTW3)
find_package(Fftw3)
endif()
# FreeType compiled with Brotli compression for woff2.
find_package(Freetype REQUIRED)
set(BROTLI_LIBRARIES
${LIBDIR}/brotli/lib/libbrotlicommon-static.a
${LIBDIR}/brotli/lib/libbrotlidec-static.a
)
if(WITH_HARFBUZZ)
find_package(Harfbuzz)
endif()
if(WITH_FRIBIDI)
find_package(Fribidi)
endif()
# Header dependency of required OpenImageIO.
find_package(OpenEXR REQUIRED)
add_bundled_libraries(openexr/lib)
add_bundled_libraries(imath/lib)
string(APPEND PLATFORM_CFLAGS " -pipe -funsigned-char -fno-strict-aliasing -ffp-contract=off")
set(PLATFORM_LINKFLAGS "\
-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa \
-framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework Metal \
-framework QuartzCore"
)
if(WITH_CODEC_FFMPEG)
set(FFMPEG_ROOT_DIR ${LIBDIR}/ffmpeg)
set(FFMPEG_FIND_COMPONENTS
avcodec avdevice avfilter avformat avutil
mp3lame ogg opus swresample swscale
theora theoradec theoraenc vorbis vorbisenc
vorbisfile vpx x264)
# Frameworks required by libavfilter, using legacy macOS CGL
string(APPEND PLATFORM_LINKFLAGS " -framework CoreImage -framework OpenGL")
if(EXISTS ${LIBDIR}/ffmpeg/lib/libaom.a)
list(APPEND FFMPEG_FIND_COMPONENTS aom)
endif()
if(EXISTS ${LIBDIR}/ffmpeg/lib/libx265.a)
list(APPEND FFMPEG_FIND_COMPONENTS x265)
endif()
if(EXISTS ${LIBDIR}/ffmpeg/lib/libxvidcore.a)
list(APPEND FFMPEG_FIND_COMPONENTS xvidcore)
endif()
find_package(FFmpeg)
endif()
if(WITH_IMAGE_OPENJPEG OR WITH_CODEC_FFMPEG)
# use openjpeg from libdir that is linked into ffmpeg
find_package(OpenJPEG)
endif()
find_library(SYSTEMSTUBS_LIBRARY
NAMES
SystemStubs
PATHS
)
mark_as_advanced(SYSTEMSTUBS_LIBRARY)
if(SYSTEMSTUBS_LIBRARY)
list(APPEND PLATFORM_LINKLIBS SystemStubs)
endif()
if(WITH_OPENIMAGEDENOISE)
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
# OpenImageDenoise uses BNNS from the Accelerate framework.
string(APPEND PLATFORM_LINKFLAGS " -framework Accelerate")
endif()
endif()
if(WITH_JACK)
string(APPEND PLATFORM_LINKFLAGS " -F/Library/Frameworks -weak_framework jackmp")
endif()
if(WITH_VULKAN_BACKEND)
find_package(ShaderC REQUIRED)
find_package(Vulkan REQUIRED)
endif()
if(WITH_SDL)
find_package(SDL3 REQUIRED CONFIG)
endif()
add_bundled_libraries(sdl/lib)
set(EPOXY_ROOT_DIR ${LIBDIR}/epoxy)
find_package(Epoxy REQUIRED)
set(PNG_ROOT ${LIBDIR}/png)
find_package(PNG REQUIRED)
set(JPEG_ROOT ${LIBDIR}/jpeg)
find_package(JPEG REQUIRED)
set(fmt_ROOT ${LIBDIR}/fmt)
find_package(fmt REQUIRED)
if(WITH_IMAGE_WEBP)
set(WEBP_ROOT_DIR ${LIBDIR}/webp)
find_package(WebP REQUIRED)
endif()
if(WITH_CODEC_FFMPEG)
string(APPEND PLATFORM_LINKFLAGS " -liconv") # ffmpeg needs it !
endif()
if(WITH_PUGIXML)
find_package(PugiXML REQUIRED)
endif()
find_package(OpenImageIO REQUIRED)
add_bundled_libraries(openimageio/lib)
find_package(OpenColorIO 2.0.0 REQUIRED CONFIG)
add_bundled_libraries(opencolorio/lib)
if(WITH_OPENVDB)
find_package(OpenVDB)
find_library(BLOSC_LIBRARIES NAMES blosc HINTS ${LIBDIR}/openvdb/lib)
if(BLOSC_LIBRARIES)
list(APPEND OPENVDB_LIBRARIES ${BLOSC_LIBRARIES})
else()
unset(BLOSC_LIBRARIES CACHE)
endif()
if(OPENVDB_FOUND)
set(OPENVDB_DEFINITIONS "")
endif()
endif()
add_bundled_libraries(openvdb/lib)
if(WITH_NANOVDB)
find_package(NanoVDB)
endif()
test_neon_support()
if(SUPPORTS_NEON_BUILD)
find_package(sse2neon REQUIRED)
endif()
if(WITH_LLVM)
find_package(LLVM)
if(NOT LLVM_FOUND)
message(FATAL_ERROR "LLVM not found.")
endif()
if(WITH_CLANG)
find_package(Clang)
if(NOT CLANG_FOUND)
message(FATAL_ERROR "Clang not found.")
endif()
endif()
endif()
if(WITH_CYCLES AND WITH_CYCLES_OSL)
find_package(OSL 1.13.4 REQUIRED)
endif()
add_bundled_libraries(osl/lib)
# OSL dependency
add_bundled_libraries(openjph/lib)
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
find_package(Embree 4.0.0 REQUIRED)
endif()
add_bundled_libraries(embree/lib)
if(WITH_OPENIMAGEDENOISE)
find_package(OpenImageDenoise REQUIRED)
add_bundled_libraries(openimagedenoise/lib)
endif()
if(WITH_TBB)
find_package(TBB 2021.13.0 REQUIRED)
if(TBB_FOUND)
get_target_property(TBB_LIBRARIES TBB::tbb LOCATION)
get_target_property(TBB_INCLUDE_DIRS TBB::tbb INTERFACE_INCLUDE_DIRECTORIES)
endif()
set_and_warn_library_found("TBB" TBB_FOUND WITH_TBB)
endif()
add_bundled_libraries(tbb/lib)
if(WITH_POTRACE)
find_package(Potrace REQUIRED)
endif()
if(WITH_XR_OPENXR)
find_package(XR_OpenXR_SDK REQUIRED)
endif()
if(WITH_GMP)
find_package(GMP REQUIRED)
endif()
if(WITH_HARU)
find_package(Haru REQUIRED)
endif()
if(WITH_MANIFOLD)
find_package(manifold REQUIRED)
endif()
if(WITH_RUBBERBAND)
find_package(Rubberband REQUIRED)
endif()
if(WITH_CYCLES AND WITH_CYCLES_PATH_GUIDING)
find_package(openpgl QUIET)
if(openpgl_FOUND)
get_target_property(OPENPGL_LIBRARIES openpgl::openpgl LOCATION)
get_target_property(OPENPGL_INCLUDE_DIR openpgl::openpgl INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "Found OpenPGL: ${OPENPGL_LIBRARIES}")
else()
set(WITH_CYCLES_PATH_GUIDING OFF)
message(STATUS "OpenPGL not found, disabling WITH_CYCLES_PATH_GUIDING")
endif()
endif()
find_package(Eigen3 REQUIRED CONFIG)
if(WITH_LIBMV)
find_package(Ceres REQUIRED CONFIG)
endif()
add_bundled_libraries(ceres/lib)
set(ZSTD_ROOT_DIR ${LIBDIR}/zstd)
find_package(Zstd REQUIRED)
if(WITH_DRACO)
find_package(draco REQUIRED CONFIG)
endif()
add_bundled_libraries(draco/lib)
if(WITH_MESHOPTIMIZER)
find_package(meshoptimizer REQUIRED CONFIG)
endif()
add_bundled_libraries(meshoptimizer/lib)
if(WITH_TRACY)
set(Tracy_ROOT_DIR ${LIBDIR}/tracy)
find_package(Tracy REQUIRED CONFIG)
endif()
if(EXISTS ${LIBDIR})
without_system_libs_end()
endif()
# Restore to default.
set(CMAKE_FIND_FRAMEWORK FIRST)
# ---------------------------------------------------------------------
# Set compiler and linker flags.
set(EXETYPE MACOSX_BUNDLE)
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
string(APPEND CMAKE_C_FLAGS_RELEASE " -ftree-vectorize -fvariable-expansion-in-unroller")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -ftree-vectorize -fvariable-expansion-in-unroller")
endif()
else()
set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic")
endif()
# Clang has too low template depth of 128 for libmv.
string(APPEND CMAKE_CXX_FLAGS " -ftemplate-depth=1024")
# Avoid conflicts with Luxrender, and other plug-ins that may use the same
# libraries as Blender with a different version or build options.
set(PLATFORM_SYMBOLS_MAP ${CMAKE_SOURCE_DIR}/source/creator/symbols_apple.map)
set(PLATFORM_LINKFLAGS_SYMBOL_HIDING "-Wl,-unexported_symbols_list,'${PLATFORM_SYMBOLS_MAP}'")
if(${XCODE_VERSION} VERSION_EQUAL 15.0)
# V4.5 specific workaround: Enforce the legacy Xcode linker to avoid incorrect
# assembly generation caused by known bugs in the modern linker shipped with
# Xcode 15.0. See issue #148792 for details.
string(APPEND PLATFORM_LINKFLAGS " -Wl,-ld_classic")
elseif(${XCODE_VERSION} VERSION_GREATER_EQUAL 15.0)
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64" AND WITH_LEGACY_MACOS_X64_LINKER)
# Silence "no platform load command found in <static library>, assuming: macOS".
#
# NOTE: Using ld_classic costs minutes of extra linking time.
string(APPEND PLATFORM_LINKFLAGS " -Wl,-ld_classic")
else()
# Silence "ld: warning: ignoring duplicate libraries".
#
# The warning is introduced with Xcode 15 and is triggered when the same library
# is passed to the linker multiple times. This situation could happen with either
# cyclic libraries, or some transitive dependencies where CMake might decide to
# pass library to the linker multiple times to force it re-scan symbols. It is
# not necessary for Xcode linker to ensure all symbols from library are used and
# it is corrected in CMake 3.29:
# https://gitlab.kitware.com/cmake/cmake/-/issues/25297
string(APPEND PLATFORM_LINKFLAGS " -Xlinker -no_warn_duplicate_libraries")
# Silence: ld: warning: reducing alignment of section __DATA,__common from 0x8000
# to 0x4000 because it exceeds segment maximum alignment
# The flag to silence this warning is only available on Xcode 26.4 and above.
if(${XCODE_VERSION} VERSION_GREATER_EQUAL 26.4)
string(APPEND PLATFORM_LINKFLAGS " -Xlinker -no_warn_reduced_section_align")
endif()
endif()
endif()
# Make stack size more similar to Embree, required for Embree.
string(APPEND PLATFORM_LINKFLAGS_EXECUTABLE " -Wl,-stack_size,0x100000")
# Suppress ranlib "has no symbols" warnings (workaround for #48250).
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
# llvm-ranlib doesn't support this flag. Xcode's libtool does.
if(NOT ${CMAKE_RANLIB} MATCHES ".*llvm-ranlib$")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
endif()
if(WITH_COMPILER_CCACHE)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode")
find_program(CCACHE_PROGRAM ccache)
mark_as_advanced(CCACHE_PROGRAM)
if(CCACHE_PROGRAM)
# Makefiles and ninja
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE STRING "" FORCE)
mark_as_advanced(
CMAKE_C_COMPILER_LAUNCHER
CMAKE_CXX_COMPILER_LAUNCHER
)
else()
message(WARNING "Ccache NOT found, disabling WITH_COMPILER_CCACHE")
set(WITH_COMPILER_CCACHE OFF)
endif()
endif()
endif()
if(WITH_COMPILER_ASAN)
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${COMPILER_ASAN_LIBRARY})
endif()
if(PLATFORM_BUNDLED_LIBRARIES)
# For the installed Python module and installed Blender executable, we set the
# rpath to the location where install step will copy the shared libraries.
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
if(WITH_PYTHON_MODULE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/lib")
else()
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/../Resources/lib")
endif()
# For binaries that are built but not installed (like makesdna or tests), we add
# the original directory of all shared libraries to the rpath. This is needed because
# these can be in different folders, and because the build and install folder may be
# different.
set(CMAKE_SKIP_BUILD_RPATH FALSE)
list(APPEND CMAKE_BUILD_RPATH ${PLATFORM_BUNDLED_LIBRARY_DIRS})
# Environment variables to run precompiled executables that needed libraries.
list(JOIN PLATFORM_BUNDLED_LIBRARY_DIRS ":" _library_paths)
# Intentionally double "$$" which expands into "$" when instantiated.
set(PLATFORM_ENV_BUILD "DYLD_LIBRARY_PATH=\"${_library_paths}:$$DYLD_LIBRARY_PATH\"")
set(PLATFORM_ENV_INSTALL "DYLD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/Blender.app/Contents/Resources/lib/:$$DYLD_LIBRARY_PATH")
unset(_library_paths)
endif()
# Same as `CFBundleIdentifier` in Info.plist.
set(CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.blenderfoundation.blender")

View File

@@ -0,0 +1,200 @@
# SPDX-FileCopyrightText: 2016 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Xcode and system configuration for Apple.
# Detect processor architecture.
if(NOT CMAKE_OSX_ARCHITECTURES)
execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Detected native architecture ${ARCHITECTURE}.")
set(CMAKE_OSX_ARCHITECTURES ${ARCHITECTURE} CACHE STRING
"Choose the architecture you want to build Blender for: arm64 or x86_64"
FORCE)
endif()
# Detect developer directory. Depending on configuration this may be either
# an Xcode or Command Line Tools installation.
execute_process(
COMMAND xcode-select --print-path
OUTPUT_VARIABLE XCODE_DEVELOPER_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Detect Xcode version. It is provided by the Xcode generator but not
# Unix Makefiles or Ninja.
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
# Note that `xcodebuild -version` gives output in two lines: first line will include
# Xcode version, second one will include build number. We are only interested in the
# first line. Here is an example of the output:
# Xcode 11.4
# Build version 11E146
# The expected XCODE_VERSION in this case is 11.4.
execute_process(
COMMAND xcodebuild -version
OUTPUT_VARIABLE _xcode_vers_build_nr
RESULT_VARIABLE _xcode_vers_result
ERROR_QUIET)
if(_xcode_vers_result EQUAL 0)
# Convert output to a single line by replacing newlines with spaces.
# This is needed because regex replace can not operate through the newline character
# and applies substitutions for each individual lines.
string(REPLACE "\n" " " _xcode_vers_build_nr_single_line "${_xcode_vers_build_nr}")
string(REGEX REPLACE "(.*)Xcode ([0-9\\.]+).*" "\\2" XCODE_VERSION "${_xcode_vers_build_nr_single_line}")
unset(_xcode_vers_build_nr_single_line)
endif()
unset(_xcode_vers_build_nr)
unset(_xcode_vers_result)
endif()
if(XCODE_VERSION)
# Construct SDKs path ourselves, because xcode-select path could be ambiguous.
# Both /Applications/Xcode.app/Contents/Developer or /Applications/Xcode.app would be allowed.
set(XCODE_SDK_DIR ${XCODE_DEVELOPER_DIR}/Platforms/MacOSX.platform/Developer/SDKs)
# Detect SDK version to use
if(NOT DEFINED OSX_SYSTEM)
execute_process(
COMMAND xcodebuild -version -sdk macosx SDKVersion
OUTPUT_VARIABLE OSX_SYSTEM
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_DEVELOPER_DIR}")
message(STATUS "SDKs Directory: " ${XCODE_SDK_DIR})
else()
# If no Xcode version found, try detecting command line tools.
execute_process(
COMMAND pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
OUTPUT_VARIABLE _cltools_pkg_info
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE _cltools_pkg_info_result
ERROR_QUIET
)
if(_cltools_pkg_info_result EQUAL 0)
# Extract version.
string(REGEX REPLACE ".*version: ([0-9]+)\\.([0-9]+).*" "\\1.\\2" XCODE_VERSION "${_cltools_pkg_info}")
# SDK directory.
set(XCODE_SDK_DIR "${XCODE_DEVELOPER_DIR}/SDKs")
# Detect SDK version to use.
if(NOT DEFINED OSX_SYSTEM)
execute_process(
COMMAND xcrun --sdk macosx --show-sdk-version
OUTPUT_VARIABLE OSX_SYSTEM
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
message(STATUS "Detected OS X ${OSX_SYSTEM} and Command Line Tools ${XCODE_VERSION} at ${XCODE_DEVELOPER_DIR}")
message(STATUS "SDKs Directory: " ${XCODE_SDK_DIR})
else()
message(FATAL_ERROR "No Xcode or Command Line Tools detected")
endif()
unset(_cltools_pkg_info)
unset(_cltools_pkg_info_result)
endif()
# Require a relatively recent Xcode version.
if(${XCODE_VERSION} VERSION_LESS 16.0)
message(FATAL_ERROR "Only Xcode version 16.0 and newer is supported")
endif()
# Collect list of OSX system versions which will be used to detect path to corresponding SDK.
# Start with macOS SDK version reported by xcodebuild and include possible extra ones.
#
# The reason for need of extra ones is because it's possible that xcodebuild will report
# SDK version in the full manner (aka major.minor.patch), but the actual path will only
# include major.minor.
#
# This happens, for example, on macOS Catalina 10.15.4 and Xcode 11.4: xcodebuild on this
# system outputs "10.15.4", but the actual SDK path is MacOSX10.15.sdk.
#
# This should be safe from picking wrong SDK version because (a) xcodebuild reports full semantic
# SDK version, so such SDK does exist on the system. And if it doesn't exist with full version
# in the path, what SDK is in the major.minor folder then.
set(OSX_SDK_TEST_VERSIONS ${OSX_SYSTEM})
if(OSX_SYSTEM MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1.\\2" OSX_SYSTEM_NO_PATCH "${OSX_SYSTEM}")
list(APPEND OSX_SDK_TEST_VERSIONS ${OSX_SYSTEM_NO_PATCH})
unset(OSX_SYSTEM_NO_PATCH)
endif()
# Loop through all possible versions and pick the first one which resolves to a valid SDK path.
set(OSX_SDK_PATH "")
set(OSX_SDK_FOUND FALSE)
set(OSX_SDKROOT "")
foreach(OSX_SDK_VERSION ${OSX_SDK_TEST_VERSIONS})
set(CURRENT_OSX_SDK_PATH "${XCODE_SDK_DIR}/MacOSX${OSX_SDK_VERSION}.sdk")
if(EXISTS ${CURRENT_OSX_SDK_PATH})
set(OSX_SDK_PATH "${CURRENT_OSX_SDK_PATH}")
set(OSX_SDKROOT macosx${OSX_SDK_VERSION})
set(OSX_SDK_FOUND TRUE)
break()
endif()
endforeach()
unset(OSX_SDK_TEST_VERSIONS)
if(NOT OSX_SDK_FOUND)
message(FATAL_ERROR "Unable to find SDK for macOS version ${OSX_SYSTEM}")
endif()
message(STATUS "Detected OSX_SYSROOT: ${OSX_SDK_PATH}")
set(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "" FORCE)
unset(OSX_SDK_PATH)
unset(OSX_SDK_FOUND)
if(${CMAKE_GENERATOR} MATCHES "Xcode")
# to silence sdk not found warning, just overrides CMAKE_OSX_SYSROOT
set(CMAKE_XCODE_ATTRIBUTE_SDKROOT ${OSX_SDKROOT})
endif()
unset(OSX_SDKROOT)
# This is our minimum target, if you use higher sdk, weak linking happens
# Mainly required because of Metal drivers.
set(OSX_MIN_DEPLOYMENT_TARGET 11.2)
set(CMAKE_OSX_DEPLOYMENT_TARGET "${OSX_MIN_DEPLOYMENT_TARGET}" CACHE STRING "" FORCE)
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
# Force CMAKE_OSX_DEPLOYMENT_TARGET for makefiles, will not work else (CMake bug?)
string(APPEND CMAKE_C_FLAGS " -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
string(APPEND CMAKE_CXX_FLAGS " -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
if(WITH_COMPILER_CCACHE)
if(CMAKE_GENERATOR STREQUAL "Xcode")
find_program(CCACHE_PROGRAM ccache)
mark_as_advanced(CCACHE_PROGRAM)
if(CCACHE_PROGRAM)
get_filename_component(ccompiler "${CMAKE_C_COMPILER}" NAME)
get_filename_component(cxxcompiler "${CMAKE_CXX_COMPILER}" NAME)
# Ccache can figure out which compiler to use if it's invoked from
# a symlink with the name of the compiler.
# https://ccache.dev/manual/4.1.html#_run_modes
set(_fake_compiler_dir "${CMAKE_BINARY_DIR}/ccache")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_fake_compiler_dir})
set(_fake_C_COMPILER "${_fake_compiler_dir}/${ccompiler}")
set(_fake_CXX_COMPILER "${_fake_compiler_dir}/${cxxcompiler}")
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CCACHE_PROGRAM}" ${_fake_C_COMPILER})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CCACHE_PROGRAM}" ${_fake_CXX_COMPILER})
set(CMAKE_XCODE_ATTRIBUTE_CC ${_fake_C_COMPILER} CACHE STRING "" FORCE)
set(CMAKE_XCODE_ATTRIBUTE_CXX ${_fake_CXX_COMPILER} CACHE STRING "" FORCE)
set(CMAKE_XCODE_ATTRIBUTE_LD ${_fake_C_COMPILER} CACHE STRING "" FORCE)
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS ${_fake_CXX_COMPILER} CACHE STRING "" FORCE)
unset(_fake_compiler_dir)
unset(_fake_C_COMPILER)
unset(_fake_CXX_COMPILER)
else()
message(WARNING "Ccache NOT found, disabling WITH_COMPILER_CCACHE")
set(WITH_COMPILER_CCACHE OFF)
endif()
endif()
endif()

View File

@@ -0,0 +1,113 @@
# SPDX-FileCopyrightText: 2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Auto update existing CMake caches for new libraries.
# Assert that `LIBDIR` is defined.
if(NOT (DEFINED LIBDIR))
message(FATAL_ERROR "Logical error, expected 'LIBDIR' to be defined!")
endif()
# Clear cached variables whose name matches `pattern`.
function(unset_cache_variables pattern)
get_cmake_property(_cache_variables CACHE_VARIABLES)
foreach(_cache_variable ${_cache_variables})
if("${_cache_variable}" MATCHES "${pattern}")
unset(${_cache_variable} CACHE)
endif()
endforeach()
endfunction()
# Clear cached variables with values containing `contents`.
function(unset_cached_variables_containing contents msg)
get_cmake_property(_cache_variables CACHE_VARIABLES)
set(_found "")
set(_print_msg "")
foreach(_cache_variable ${_cache_variables})
# Skip "_" prefixed variables, these are used for internal book-keeping,
# not under user control.
string(FIND "${_cache_variable}" "_" _found)
if(NOT (_found EQUAL 0))
string(FIND "${${_cache_variable}}" "${contents}" _found)
if(NOT (_found EQUAL -1))
unset(${_cache_variable} CACHE)
set(_print_msg ON)
endif()
endif()
endforeach()
if(_print_msg)
message(STATUS "${msg}")
endif()
endfunction()
# Detect update in 4.1 to shared library OpenImageDenoise and OSL.
if(UNIX AND
DEFINED OPENIMAGEDENOISE_LIBRARY AND
OPENIMAGEDENOISE_LIBRARY MATCHES "libOpenImageDenoise.a$" AND
(EXISTS ${LIBDIR}/openimagedenoise/lib/libOpenImageDenoise.so OR
EXISTS ${LIBDIR}/openimagedenoise/lib/libOpenImageDenoise.dylib))
message(STATUS "Auto updating CMake configuration for dynamic OpenImageDenoise")
unset_cache_variables("^OPENIMAGEDENOISE")
endif()
if(UNIX AND
DEFINED OSL_OSLCOMP_LIBRARY AND
OSL_OSLCOMP_LIBRARY MATCHES "liboslcomp.a$" AND
(EXISTS ${LIBDIR}/osl/lib/liboslcomp.so OR
EXISTS ${LIBDIR}/osl/lib/liboslcomp.dylib))
message(STATUS "Auto updating CMake configuration for dynamic OpenShadingLanguage")
unset_cache_variables("^OSL_")
endif()
# Detect Python 3.10 to 3.11 upgrade for Blender 4.1.
if(UNIX AND
LIBDIR AND
EXISTS ${LIBDIR} AND
EXISTS ${LIBDIR}/python/bin/python3.11 AND
DEFINED PYTHON_VERSION AND
PYTHON_VERSION VERSION_LESS "3.11")
message(STATUS "Auto updating CMake configuration for Python 3.11")
unset_cache_variables("^PYTHON_")
endif()
# Detect update to 4.4 libs.
if(LIBDIR AND
EXISTS ${LIBDIR}/tbb/include/oneapi AND
((DEFINED Boost_INCLUDE_DIR) OR (SYCL_LIBRARY MATCHES "sycl7")))
message(STATUS "Auto updating CMake configuration for Blender 4.4 libraries")
unset_cache_variables("^BOOST")
unset_cache_variables("^Boost")
unset_cache_variables("^EMBREE")
unset_cache_variables("^IMATH")
unset_cache_variables("^MATERIALX")
unset_cache_variables("^NANOVDB")
unset_cache_variables("^OPENCOLORIO")
unset_cache_variables("^OPENEXR")
unset_cache_variables("^OPENIMAGEDENOISE")
unset_cache_variables("^OPENIMAGEIO")
unset_cache_variables("^OPENVDB")
unset_cache_variables("^OSL_")
unset_cache_variables("^PYTHON")
unset_cache_variables("^SYCL")
unset_cache_variables("^TBB")
unset_cache_variables("^USD")
endif()
# Detect update to 5.0 libs.
if(UNIX AND LIBDIR AND
EXISTS ${LIBDIR}/haru/lib/libhpdf.a AND
HARU_LIBRARY MATCHES "libhpdfs.a$")
message(STATUS "Auto updating CMake configuration for Blender 5.0 libraries")
unset_cache_variables("^HARU")
endif()
# Detect update to 5.2 libs
if(DEFINED CACHE{WITH_SDL})
message(STATUS "Auto updating CMake configuration for Blender 5.2 libraries")
# Following the SDL3 migration (PR !157521), WITH_SDL was renamed to WITH_SDL_AUDIO, and WITH_SDL became an uncached
# variable depending on the value of WITH_SDL_AUDIO, WITH_GHOST_SDL, etc... Migrate value and unset old cache variable.
set(WITH_SDL_AUDIO $CACHE{WITH_SDL} CACHE BOOL "" FORCE)
unset(WITH_SDL CACHE)
endif()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,167 @@
# Web platform policy for the browser engine target.
# This fragment is used by both the top-level Blender CMake configuration and
# the isolated web/engine target. It must not change the WITH_BLENDER choice;
# the top-level build needs Blender data libraries while the isolated target
# intentionally leaves them out.
if(NOT EMSCRIPTEN)
message(FATAL_ERROR "web.cmake requires the Emscripten toolchain")
endif()
set(WITH_WEB ON CACHE BOOL "Build the browser Blender engine" FORCE)
add_compile_definitions(WITH_WEB)
set(BLENDER_HOST_EXECUTABLE_PREFIX /usr/bin/node CACHE INTERNAL "Run Emscripten host tools with Node.js")
set(WITH_PYTHON OFF CACHE BOOL "" FORCE)
set(WITH_HEADLESS ON CACHE BOOL "" FORCE)
set(WITH_GHOST OFF CACHE BOOL "" FORCE)
set(WITH_GHOST_X11 OFF CACHE BOOL "" FORCE)
set(WITH_GHOST_WAYLAND OFF CACHE BOOL "" FORCE)
set(WITH_GHOST_SDL OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
set(WITH_ALEMBIC OFF CACHE BOOL "" FORCE)
set(WITH_HYDRA OFF CACHE BOOL "" FORCE)
set(WITH_MATERIALX OFF CACHE BOOL "" FORCE)
set(WITH_DRACO OFF CACHE BOOL "" FORCE)
set(WITH_MESHOPTIMIZER OFF CACHE BOOL "" FORCE)
set(WITH_OPENVDB OFF CACHE BOOL "" FORCE)
set(WITH_USD OFF CACHE BOOL "" FORCE)
set(WITH_CODEC_FFMPEG OFF CACHE BOOL "" FORCE)
set(WITH_VULKAN_BACKEND OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_OPENEXR OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_OPENJPEG OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_WEBP OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_TIFF OFF CACHE BOOL "" FORCE)
set(WITH_IMAGE_CINEON OFF CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR OFF CACHE BOOL "" FORCE)
set(WITH_OPENIMAGEDENOISE OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
set(WITH_QUADRIFLOW OFF CACHE BOOL "" FORCE)
set(WITH_UV_SLIM OFF CACHE BOOL "" FORCE)
set(WITH_IK_ITASC OFF CACHE BOOL "" FORCE)
set(WITH_IO_FBX OFF CACHE BOOL "" FORCE)
set(WITH_IO_GREASE_PENCIL OFF CACHE BOOL "" FORCE)
set(WITH_IO_PLY OFF CACHE BOOL "" FORCE)
set(WITH_IO_STL OFF CACHE BOOL "" FORCE)
set(WITH_IO_WAVEFRONT_OBJ OFF CACHE BOOL "" FORCE)
set(WITH_MANIFOLD OFF CACHE BOOL "" FORCE)
set(WITH_GMP ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 OFF CACHE BOOL "" FORCE)
set(WITH_PUGIXML OFF CACHE BOOL "" FORCE)
set(WITH_HARU OFF CACHE BOOL "" FORCE)
set(WITH_OPENAL OFF CACHE BOOL "" FORCE)
set(WITH_TBB OFF CACHE BOOL "" FORCE)
set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
# Several data/editor libraries declare a compositor dependency even when the
# compositor source directory is intentionally omitted for the browser build.
# Keep the dependency graph valid without linking desktop GPU compositor code.
if(NOT TARGET bf_compositor)
add_library(bf_compositor INTERFACE)
endif()
# Build compression support from pinned source inside the repository. Native
# system libraries cannot be linked into a WebAssembly module, and relying on
# compiler-managed downloads would make clean/offline builds non-reproducible.
get_filename_component(WEB_BLENDER_SOURCE_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
# Build the Blender-pinned OpenSubdiv source as a CPU-only static dependency.
# Browser evaluation does not use OpenSubdiv's GPU backends, examples or tools.
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(NO_EXAMPLES ON CACHE BOOL "" FORCE)
set(NO_TUTORIALS ON CACHE BOOL "" FORCE)
set(NO_REGRESSION ON CACHE BOOL "" FORCE)
set(NO_PTEX ON CACHE BOOL "" FORCE)
set(NO_DOC ON CACHE BOOL "" FORCE)
set(NO_OMP ON CACHE BOOL "" FORCE)
set(NO_TBB ON CACHE BOOL "" FORCE)
set(NO_CUDA ON CACHE BOOL "" FORCE)
set(NO_OPENCL ON CACHE BOOL "" FORCE)
set(NO_CLEW ON CACHE BOOL "" FORCE)
set(NO_OPENGL ON CACHE BOOL "" FORCE)
set(NO_METAL ON CACHE BOOL "" FORCE)
set(NO_DX ON CACHE BOOL "" FORCE)
set(NO_TESTS ON CACHE BOOL "" FORCE)
set(NO_GLTESTS ON CACHE BOOL "" FORCE)
set(NO_GLFW ON CACHE BOOL "" FORCE)
add_subdirectory(
"${WEB_BLENDER_SOURCE_ROOT}/extern/opensubdiv-source"
"${CMAKE_BINARY_DIR}/extern/opensubdiv-web"
EXCLUDE_FROM_ALL
)
set(OPENSUBDIV_INCLUDE_DIRS "${WEB_BLENDER_SOURCE_ROOT}/extern/opensubdiv-source")
set(OPENSUBDIV_LIBRARIES osd_static_cpu)
# GMP is cross-compiled once with Emscripten from the vendored 6.3.0 source.
# Keep both C++ and C archives explicit because Blender's exact Boolean solver
# uses mpq_class from libgmpxx on top of libgmp.
set(GMP_INCLUDE_DIRS "${WEB_BLENDER_SOURCE_ROOT}/extern/gmp-wasm/include")
set(GMP_LIBRARIES
"${WEB_BLENDER_SOURCE_ROOT}/extern/gmp-wasm/lib/libgmpxx.a"
"${WEB_BLENDER_SOURCE_ROOT}/extern/gmp-wasm/lib/libgmp.a"
)
set(ZLIB_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(
"${WEB_BLENDER_SOURCE_ROOT}/extern/zlib"
"${CMAKE_BINARY_DIR}/extern/zlib-web"
EXCLUDE_FROM_ALL
)
set(ZLIB_INCLUDE_DIRS
"${WEB_BLENDER_SOURCE_ROOT}/extern/zlib"
"${CMAKE_BINARY_DIR}/extern/zlib-web"
)
set(ZLIB_LIBRARIES zlibstatic)
set(ZSTD_BUILD_PROGRAMS OFF CACHE BOOL "" FORCE)
set(ZSTD_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ZSTD_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(ZSTD_BUILD_STATIC ON CACHE BOOL "" FORCE)
set(ZSTD_MULTITHREAD_SUPPORT OFF CACHE BOOL "" FORCE)
add_subdirectory(
"${WEB_BLENDER_SOURCE_ROOT}/extern/zstd/build/cmake"
"${CMAKE_BINARY_DIR}/extern/zstd-web"
EXCLUDE_FROM_ALL
)
set(ZSTD_INCLUDE_DIRS "${WEB_BLENDER_SOURCE_ROOT}/extern/zstd/lib")
set(ZSTD_LIBRARIES libzstd_static)
# These targets are mandatory in Blender's common dependency target file even
# when the corresponding feature is disabled. Emscripten's first-party web
# build deliberately supplies empty interface targets so the data-only subset
# can configure without desktop/image libraries.
foreach(web_target IN ITEMS
Eigen3::Eigen
OpenColorIO::OpenColorIO
OpenImageIO::OpenImageIO
OpenEXR::OpenEXR
fmt::fmt)
if(NOT TARGET ${web_target})
add_library(${web_target} INTERFACE IMPORTED GLOBAL)
endif()
endforeach()
set(WEB_FMT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/../../../extern/fmt/include")
if(TARGET fmt::fmt AND EXISTS "${WEB_FMT_INCLUDE}/fmt")
set_property(TARGET fmt::fmt PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${WEB_FMT_INCLUDE}")
set_property(TARGET fmt::fmt PROPERTY INTERFACE_COMPILE_DEFINITIONS FMT_HEADER_ONLY)
endif()
set(WEB_EIGEN_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/../../../extern/eigen3")
if(TARGET Eigen3::Eigen AND EXISTS "${WEB_EIGEN_INCLUDE}/Eigen")
set_property(TARGET Eigen3::Eigen PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${WEB_EIGEN_INCLUDE}")
endif()
if(NOT TARGET OpenImageIO::oiiotool)
add_executable(OpenImageIO::oiiotool IMPORTED GLOBAL)
set_property(TARGET OpenImageIO::oiiotool PROPERTY
IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/web-placeholder-oiiotool")
endif()
set(CMAKE_EXECUTABLE_SUFFIX ".js")
add_compile_options(-fexceptions)
add_compile_options(-fsigned-char)
add_compile_options(-Wno-c++11-narrowing)
add_link_options(
-sENVIRONMENT=web,worker
-sMODULARIZE=1
-sEXPORT_ES6=1
-sALLOW_MEMORY_GROWTH=1
-sFILESYSTEM=1
)

View File

@@ -0,0 +1,410 @@
# SPDX-FileCopyrightText: 2006-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
function(get_blender_test_install_dir VARIABLE_NAME)
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(GENERATOR_IS_MULTI_CONFIG)
string(REPLACE "\${BUILD_TYPE}" "$<CONFIG>" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
else()
string(REPLACE "\${BUILD_TYPE}" "" TEST_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
endif()
set(${VARIABLE_NAME} "${TEST_INSTALL_DIR}" PARENT_SCOPE)
endfunction()
# Add the necessary LSAN/ASAN options to the given list of environment variables.
# Typically used after adding a test, before calling
# `set_tests_properties(${testname} PROPERTIES ENVIRONMENT "${_envvar_list}")`,
# to ensure that it will run with the correct sanitizer settings.
#
# \param envvars_list: A list of extra environment variables to define for that test.
# Note that this does no check for (re-)definition of a same variable.
function(blender_test_set_envvars testname envvar_list)
if(PLATFORM_ENV_INSTALL)
list(APPEND envvar_list "${PLATFORM_ENV_INSTALL}")
endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
if(WITH_COMPILER_ASAN)
set(_lsan_options "LSAN_OPTIONS=print_suppressions=false:suppressions=${CMAKE_SOURCE_DIR}/tools/config/analysis/lsan.supp")
# FIXME: That `allocator_may_return_null=true` ASAN option is only needed for the
# `guardedalloc` test, would be nice to allow tests definition to pass extra envvars better.
set(_asan_options "ASAN_OPTIONS=allocator_may_return_null=true")
if(DEFINED ENV{LSAN_OPTIONS})
set(_lsan_options "${_lsan_options}:$ENV{LSAN_OPTIONS}")
endif()
if(DEFINED ENV{ASAN_OPTIONS})
set(_asan_options "${_asan_options}:$ENV{ASAN_OPTIONS}")
endif()
list(APPEND envvar_list "${_lsan_options}" "${_asan_options}")
endif()
endif()
if(WITH_COMPILER_CODE_COVERAGE AND CMAKE_C_COMPILER_ID MATCHES "Clang")
list(APPEND envvar_list "LLVM_PROFILE_FILE=${COMPILER_CODE_COVERAGE_DATA_DIR}/raw/blender_%p.profraw")
endif()
# Can only be called once per test to define its custom environment variables.
set_tests_properties(${testname} PROPERTIES ENVIRONMENT "${envvar_list}")
endfunction()
function(blender_src_gtest_ex)
if(WITH_GTESTS)
set(options "")
set(oneValueArgs NAME)
set(multiValueArgs SRC EXTRA_LIBS COMMAND_ARGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
unset(options)
unset(oneValueArgs)
unset(multiValueArgs)
set(TARGET_NAME ${ARG_NAME}_test)
get_property(_current_include_directories
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY INCLUDE_DIRECTORIES)
set(TEST_INC
${_current_include_directories}
${CMAKE_SOURCE_DIR}/tests/gtests
)
set(TEST_INC_SYS
${CMAKE_SOURCE_DIR}/extern/gtest/include
${CMAKE_SOURCE_DIR}/extern/gmock/include
)
unset(_current_include_directories)
if(WIN32 AND NOT WITH_WINDOWS_EXTERNAL_MANIFEST)
set(MANIFEST "${CMAKE_BINARY_DIR}/tests.exe.manifest")
else()
set(MANIFEST "")
endif()
add_executable(${TARGET_NAME} ${ARG_SRC} ${MANIFEST})
setup_platform_linker_flags(${TARGET_NAME})
target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}")
target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}")
blender_link_libraries(${TARGET_NAME} "${ARG_EXTRA_LIBS};${PLATFORM_LINKLIBS}")
if(WITH_TBB)
# Force TBB libraries to be in front of MKL (part of OpenImageDenoise), so
# that it is initialized before MKL and static library initialization order
# issues are avoided.
target_link_libraries(${TARGET_NAME} PRIVATE ${TBB_LIBRARIES})
if(WITH_OPENIMAGEDENOISE)
target_link_libraries(${TARGET_NAME} PRIVATE ${OPENIMAGEDENOISE_LIBRARIES})
endif()
endif()
target_link_libraries(${TARGET_NAME} PRIVATE
bf_testing_main
bf_intern_eigen
bf_intern_guardedalloc
extern_gtest
extern_gmock
# Needed for GLOG.
bf::dependencies::glog
bf::dependencies::gflags
bf::dependencies::pthreads
bf::dependencies::optional::tbb
bf::dependencies::optional::gmp)
if(UNIX AND NOT APPLE)
target_link_libraries(${TARGET_NAME} PRIVATE bf_intern_libc_compat)
endif()
get_blender_test_install_dir(TEST_INSTALL_DIR)
set_target_properties(${TARGET_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${TESTS_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TESTS_OUTPUT_DIR}")
if(WIN32)
set_target_properties(${TARGET_NAME} PROPERTIES VS_GLOBAL_VcpkgEnabled "false")
if(WITH_WINDOWS_EXTERNAL_MANIFEST)
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/tests.exe.manifest ${TESTS_OUTPUT_DIR}/${TARGET_NAME}.exe.manifest
)
endif()
endif()
endif()
endfunction()
function(blender_add_ctests)
if(ARGC LESS 1)
message(FATAL_ERROR "No arguments supplied to blender_add_ctests()")
endif()
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/tests/files/render")
return()
endif()
# Parse the arguments
set(oneValueArgs DISCOVER_TESTS TARGET SUITE_NAME)
set(multiValueArgs SOURCES)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Figure out the release dir, as some tests need files from there.
get_blender_test_install_dir(TEST_INSTALL_DIR)
if(APPLE)
set(_test_release_dir ${TEST_INSTALL_DIR}/Blender.app/Contents/Resources/${BLENDER_VERSION})
else()
if(WIN32 OR WITH_INSTALL_PORTABLE)
set(_test_release_dir ${TEST_INSTALL_DIR}/${BLENDER_VERSION})
else()
set(_test_release_dir ${TEST_INSTALL_DIR}/share/blender/${BLENDER_VERSION})
endif()
endif()
# Define a test case with our custom gtest_add_tests() command.
if(${ARGS_DISCOVER_TESTS})
include(GTest)
gtest_add_tests(
TARGET ${ARGS_TARGET}
SOURCES "${ARGS_SOURCES}"
TEST_PREFIX ${ARGS_SUITE_NAME}
WORKING_DIRECTORY "${TEST_INSTALL_DIR}"
EXTRA_ARGS
--test-assets-dir "${CMAKE_SOURCE_DIR}/tests/files"
--test-release-dir "${_test_release_dir}"
)
else()
add_test(
NAME ${ARGS_SUITE_NAME}
COMMAND ${ARGS_TARGET}
--test-assets-dir "${CMAKE_SOURCE_DIR}/tests/files"
--test-release-dir "${_test_release_dir}"
WORKING_DIRECTORY ${TEST_INSTALL_DIR}
)
endif()
blender_test_set_envvars("${ARGS_SUITE_NAME}" "")
unset(_test_release_dir)
endfunction()
# Add tests for a Blender library, to be called in tandem with blender_add_lib().
#
# If WITH_TESTS_SINGLE_BINARY is enabled, tests will be put into the blender_test
# executable, and a separate ctest will be generated for every gtest contained in it.
#
# If WITH_TESTS_SINGLE_BINARY is disabled, this works identically to
# blender_add_test_suite_executable.
#
# The function accepts an optional argument which denotes list of sources which
# is to be compiled-in with the suite sources for each of the suites when the
# WITH_TESTS_SINGLE_BINARY configuration is set to OFF.
function(blender_add_test_suite_lib
name
sources
includes
includes_sys
library_deps
)
# Sources which are common for all suites and do not need to yield their own
# test suite binaries when WITH_TESTS_SINGLE_BINARY is OFF.
set(common_sources ${ARGN})
if(WITH_TESTS_SINGLE_BINARY)
add_c_and_cxx_flags_custom_test(${name}_tests PARENT_SCOPE)
# Otherwise external projects will produce warnings that we cannot fix.
remove_strict_flags()
# This duplicates logic that's also in blender_src_gtest_ex.
# TODO(Sybren): deduplicate after the general approach in D7649 has been approved.
list(APPEND includes
${CMAKE_SOURCE_DIR}/tests/gtests
)
list(APPEND includes_sys
${CMAKE_SOURCE_DIR}/extern/gtest/include
${CMAKE_SOURCE_DIR}/extern/gmock/include
)
list(APPEND library_deps
bf::dependencies::gflags
bf::dependencies::glog
)
blender_add_lib__impl(${name}_tests
"${sources};${common_sources}" "${includes}" "${includes_sys}" "${library_deps}")
target_compile_definitions(${name}_tests PRIVATE ${GFLAGS_DEFINES})
target_compile_definitions(${name}_tests PRIVATE ${GLOG_DEFINES})
set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name}_tests)
blender_add_ctests(
TARGET blender_test
SUITE_NAME ${name}
SOURCES "${sources};${common_sources}"
DISCOVER_TESTS TRUE
)
else()
blender_add_test_suite_executable(
"${name}"
"${sources}"
"${includes}"
"${includes_sys}"
"${library_deps}"
"${common_sources}"
)
endif()
endfunction()
function(blender_add_test_executable_impl
name
sources
includes
includes_sys
library_deps
)
set(oneValueArgs ADD_CTESTS DISCOVER_TESTS)
set(multiValueArgs "")
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
unset(oneValueArgs)
unset(multiValueArgs)
add_c_and_cxx_flags_custom_test(${name} PARENT_SCOPE)
## Otherwise external projects will produce warnings that we cannot fix.
remove_strict_flags()
blender_src_gtest_ex(
NAME ${name}
SRC "${sources}"
EXTRA_LIBS "${library_deps}"
)
if(ARGS_ADD_CTESTS)
blender_add_ctests(
TARGET ${name}_test
SUITE_NAME ${name}
SOURCES "${sources}"
DISCOVER_TESTS ${ARGS_DISCOVER_TESTS}
)
endif()
blender_target_include_dirs(${name}_test ${includes})
blender_target_include_dirs_sys(${name}_test ${includes_sys})
blender_source_group("${name}_test" "${sources}")
endfunction()
# Add tests for a Blender library, to be called in tandem with blender_add_lib().
#
# If WITH_TESTS_SINGLE_BINARY is enabled, this will generate a single executable
# named ${name}_test, and generate a separate ctest for every gtest contained in it.
#
# If WITH_TESTS_SINGLE_BINARY is disabled, this will generate an executable
# named ${name}_${source}_test for every source file (with redundant prefixes and
# postfixes stripped).
#
# To be used for smaller isolated libraries, that do not have many dependencies.
# For libraries that do drag in many other Blender libraries and would create a
# very large executable, blender_add_test_suite_lib() should be used instead.
#
# The function accepts an optional argument which denotes list of sources which
# is to be compiled-in with the suite sources for each of the suites when the
# WITH_TESTS_SINGLE_BINARY configuration is set to OFF.
function(blender_add_test_suite_executable
name
sources
includes
includes_sys
library_deps
)
# Sources which are common for all suites and do not need to yield their own
# test suite binaries when WITH_TESTS_SINGLE_BINARY is OFF.
set(common_sources ${ARGN})
if(WITH_TESTS_SINGLE_BINARY)
blender_add_test_executable_impl(
"${name}"
"${sources};${common_sources}"
"${includes}"
"${includes_sys}"
"${library_deps}"
ADD_CTESTS TRUE
DISCOVER_TESTS TRUE
)
else()
foreach(source ${sources})
get_filename_component(_source_ext ${source} LAST_EXT)
if(NOT ${_source_ext} MATCHES "^\.h")
# Generate test name without redundant prefixes and postfixes.
get_filename_component(_test_name ${source} NAME_WE)
if(NOT ${_test_name} MATCHES "^${name}_")
set(_test_name "${name}_${_test_name}")
endif()
string(REGEX REPLACE "_test$" "" _test_name ${_test_name})
string(REGEX REPLACE "_tests$" "" _test_name ${_test_name})
blender_add_test_executable_impl(
"${_test_name}"
"${source};${common_sources}"
"${includes}"
"${includes_sys}"
"${library_deps}"
ADD_CTESTS TRUE
DISCOVER_TESTS FALSE
)
# Work-around run-time dynamic loader error
# symbol not found in flat namespace '_PyBaseObject_Type'
#
# Some tests are testing modules which are linked against Python, while some of unit
# tests might not use code path which uses Python functionality. In this case linker
# will optimize out all symbols from Python since it decides they are not used. This
# somehow conflicts with other libraries which are linked against the test binary and
# perform search of _PyBaseObject_Type on startup.
#
# Work-around by telling the linker that the python libraries should not be stripped.
if(APPLE AND NOT WITH_PYTHON_MODULE)
target_link_libraries("${_test_name}_test" PRIVATE "-Wl,-force_load,${PYTHON_LIBRARIES}")
endif()
if(WITH_BUILDINFO)
target_link_libraries("${_test_name}_test" PRIVATE buildinfoobj)
endif()
endif()
endforeach()
endif()
endfunction()
# Add test for a Blender library, to be called in tandem with blender_add_lib().
# Source files will be compiled into a single ${name}_test executable.
#
# To be used for smaller isolated libraries, that do not have many dependencies.
# For libraries that do drag in many other Blender libraries and would create a
# very large executable, blender_add_test_lib() should be used instead.
function(blender_add_test_executable
name
sources
includes
includes_sys
library_deps
)
blender_add_test_executable_impl(
"${name}"
"${sources}"
"${includes}"
"${includes_sys}"
"${library_deps}"
ADD_CTESTS TRUE
DISCOVER_TESTS FALSE
)
endfunction()
# Add performance test. This is like blender_add_test_executable, but no ctest
# is generated and the binary should be run manually.
function(blender_add_test_performance_executable
name
sources
includes
includes_sys
library_deps
)
blender_add_test_executable_impl(
"${name}"
"${sources}"
"${includes}"
"${includes_sys}"
"${library_deps}"
ADD_CTESTS FALSE
DISCOVER_TESTS FALSE
)
endfunction()