2023-08-16 00:20:26 +10:00
|
|
|
# SPDX-FileCopyrightText: 2016 Blender Authors
|
2023-06-14 22:49:59 +10:00
|
|
|
#
|
2022-02-11 09:07:11 +11:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2022-01-12 12:49:36 +01:00
|
|
|
# Libraries configuration for any *nix system including Linux and Unix (excluding APPLE).
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2017-07-31 19:04:18 +02:00
|
|
|
# Detect precompiled library directory
|
2023-01-19 17:07:24 +11:00
|
|
|
|
|
|
|
|
if(NOT WITH_LIBS_PRECOMPILED)
|
|
|
|
|
unset(LIBDIR)
|
|
|
|
|
else()
|
|
|
|
|
if(NOT DEFINED LIBDIR)
|
|
|
|
|
# Path to a locally compiled libraries.
|
|
|
|
|
set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
|
|
|
|
|
string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME)
|
|
|
|
|
set(LIBDIR_NATIVE_ABI ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
|
|
|
|
|
|
|
|
|
|
# Path to precompiled libraries with known glibc 2.28 ABI.
|
2024-07-12 12:01:29 +02:00
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
|
|
|
|
set(LIBDIR_GLIBC228_ABI ${CMAKE_SOURCE_DIR}/lib/linux_arm64)
|
|
|
|
|
else()
|
|
|
|
|
set(LIBDIR_GLIBC228_ABI ${CMAKE_SOURCE_DIR}/lib/linux_x64)
|
|
|
|
|
endif()
|
2023-01-19 17:07:24 +11:00
|
|
|
|
|
|
|
|
# Choose the best suitable libraries.
|
|
|
|
|
if(EXISTS ${LIBDIR_NATIVE_ABI})
|
|
|
|
|
set(LIBDIR ${LIBDIR_NATIVE_ABI})
|
2023-05-17 13:07:43 +10:00
|
|
|
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND TRUE)
|
2024-02-22 13:50:55 +01:00
|
|
|
elseif(EXISTS "${LIBDIR_GLIBC228_ABI}/.git")
|
2023-01-19 17:07:24 +11:00
|
|
|
set(LIBDIR ${LIBDIR_GLIBC228_ABI})
|
|
|
|
|
if(WITH_MEM_JEMALLOC)
|
|
|
|
|
# jemalloc provides malloc hooks.
|
2023-05-17 13:07:43 +10:00
|
|
|
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND FALSE)
|
2023-01-19 17:07:24 +11:00
|
|
|
else()
|
2023-05-17 13:07:43 +10:00
|
|
|
set(WITH_LIBC_MALLOC_HOOK_WORKAROUND TRUE)
|
2023-01-19 17:07:24 +11:00
|
|
|
endif()
|
2022-09-13 10:34:41 +02:00
|
|
|
endif()
|
2023-01-19 17:07:24 +11:00
|
|
|
|
|
|
|
|
# Avoid namespace pollustion.
|
|
|
|
|
unset(LIBDIR_NATIVE_ABI)
|
|
|
|
|
unset(LIBDIR_GLIBC228_ABI)
|
2019-10-09 17:14:00 +02:00
|
|
|
endif()
|
|
|
|
|
|
2024-03-04 12:40:49 +11:00
|
|
|
if(NOT DEFINED LIBDIR)
|
|
|
|
|
set(LIBDIR "") # Suppress undefined warnings, allow printing even if empty.
|
|
|
|
|
endif()
|
|
|
|
|
if((LIBDIR STREQUAL "") OR (NOT (EXISTS "${LIBDIR}")))
|
2024-03-01 19:20:34 +01:00
|
|
|
if(WITH_STRICT_BUILD_OPTIONS)
|
|
|
|
|
message(SEND_ERROR
|
2024-03-04 12:53:37 +11:00
|
|
|
"Unable to find LIBDIR: \"${LIBDIR}\". "
|
2024-03-01 19:20:34 +01:00
|
|
|
"WITH_LIBS_PRECOMPILED needs to be able to find the LIBDIR for the precompiled libraries."
|
|
|
|
|
)
|
|
|
|
|
else()
|
|
|
|
|
message(STATUS
|
2024-03-04 12:53:37 +11:00
|
|
|
"Unable to find LIBDIR: \"${LIBDIR}\". system libraries may be used "
|
2024-03-01 19:20:34 +01:00
|
|
|
"(disable WITH_LIBS_PRECOMPILED to suppress this message)."
|
|
|
|
|
)
|
|
|
|
|
endif()
|
2024-03-04 12:40:49 +11:00
|
|
|
unset(LIBDIR)
|
2024-03-01 19:20:34 +01:00
|
|
|
set(WITH_LIBS_PRECOMPILED OFF)
|
2023-01-19 17:07:24 +11:00
|
|
|
endif()
|
2018-08-29 16:15:54 +02:00
|
|
|
endif()
|
2017-07-31 19:04:18 +02:00
|
|
|
|
2024-02-20 16:11:00 +01:00
|
|
|
# Disable the CPU check if not portable or if we are not using the pre-compiled libs.
|
|
|
|
|
# This is because:
|
|
|
|
|
# 1. We don't install the CPU check library on a non portable build.
|
|
|
|
|
# 2. We assume that people know what systems they are targeting when they build a non
|
|
|
|
|
# portable build or when not using our precompiled libs.
|
|
|
|
|
set_and_warn_dependency(WITH_INSTALL_PORTABLE WITH_CPU_CHECK OFF)
|
|
|
|
|
set_and_warn_dependency(WITH_LIBS_PRECOMPILED WITH_CPU_CHECK OFF)
|
|
|
|
|
|
2022-01-26 15:20:32 +11:00
|
|
|
# Support restoring this value once pre-compiled libraries have been handled.
|
|
|
|
|
set(WITH_STATIC_LIBS_INIT ${WITH_STATIC_LIBS})
|
|
|
|
|
|
2023-01-19 17:07:24 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2023-10-07 18:20:30 +11:00
|
|
|
if(FIRST_RUN)
|
|
|
|
|
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
|
|
|
|
|
endif()
|
2019-10-09 17:14:00 +02:00
|
|
|
|
2017-07-31 19:04:18 +02:00
|
|
|
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
|
2022-06-29 12:58:04 +02:00
|
|
|
|
2020-09-10 14:54:21 +02:00
|
|
|
# Ignore Mesa software OpenGL libraries, they are not intended to be
|
|
|
|
|
# linked against but to optionally override at runtime.
|
|
|
|
|
list(REMOVE_ITEM LIB_SUBDIRS ${LIBDIR}/mesa)
|
2022-06-29 12:58:04 +02:00
|
|
|
|
|
|
|
|
# Ignore DPC++ as it contains its own copy of LLVM/CLang which we do
|
|
|
|
|
# not need to be ever discovered for the Blender linking.
|
|
|
|
|
list(REMOVE_ITEM LIB_SUBDIRS ${LIBDIR}/dpcpp)
|
|
|
|
|
|
2025-06-06 08:38:57 +02:00
|
|
|
# NOTE: Make sure "proper" compiled zlib comes first
|
2018-08-29 15:05:03 +02:00
|
|
|
set(CMAKE_PREFIX_PATH ${LIBDIR}/zlib ${LIB_SUBDIRS})
|
2022-04-19 18:09:05 +02:00
|
|
|
|
|
|
|
|
include(platform_old_libs_update)
|
|
|
|
|
|
2017-07-31 19:04:18 +02:00
|
|
|
set(WITH_STATIC_LIBS ON)
|
2020-01-22 22:38:26 -07:00
|
|
|
set(Boost_NO_BOOST_CMAKE ON)
|
2023-08-17 11:53:50 +10:00
|
|
|
set(Boost_ROOT ${LIBDIR}/boost)
|
2020-01-22 22:38:26 -07:00
|
|
|
set(BOOST_LIBRARYDIR ${LIBDIR}/boost/lib)
|
|
|
|
|
set(Boost_NO_SYSTEM_PATHS ON)
|
2020-05-05 12:39:02 +02:00
|
|
|
set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
|
2021-02-24 07:13:37 -07:00
|
|
|
set(CLANG_ROOT_DIR ${LIBDIR}/llvm)
|
2022-12-05 23:18:54 +01:00
|
|
|
set(MaterialX_DIR ${LIBDIR}/materialx/lib/cmake/MaterialX)
|
2019-03-02 02:53:09 +01:00
|
|
|
endif()
|
|
|
|
|
|
2017-07-31 19:04:18 +02:00
|
|
|
# Wrapper to prefer static libraries
|
2016-08-09 15:19:11 +02:00
|
|
|
macro(find_package_wrapper)
|
|
|
|
|
if(WITH_STATIC_LIBS)
|
|
|
|
|
find_package_static(${ARGV})
|
|
|
|
|
else()
|
|
|
|
|
find_package(${ARGV})
|
|
|
|
|
endif()
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2020-02-20 22:09:14 -07:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Precompiled Libraries
|
|
|
|
|
#
|
|
|
|
|
# These are libraries that may be precompiled. For this we disable searching in
|
|
|
|
|
# the system directories so that we don't accidentally use them instead.
|
|
|
|
|
|
2023-01-19 17:07:24 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2020-02-20 22:09:14 -07:00
|
|
|
without_system_libs_begin()
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
find_package_wrapper(JPEG REQUIRED)
|
|
|
|
|
find_package_wrapper(PNG REQUIRED)
|
|
|
|
|
find_package_wrapper(ZLIB REQUIRED)
|
Add support for Zstandard compression for .blend files
Compressing blendfiles can help save a lot of disk space, but the slowdown
while loading and saving is a major annoyance.
Currently Blender uses Zlib (aka gzip aka Deflate) for compression, but there
are now several more modern algorithms that outperform it in every way.
In this patch, I decided for Zstandard aka Zstd for several reasons:
- It is widely supported, both in other programs and libraries as well as in
general-purpose compression utilities on Unix
- It is extremely flexible - spanning several orders of magnitude of
compression speeds depending on the level setting.
- It is pretty much on the Pareto frontier for all of its configurations
(meaning that no other algorithm is both faster and more efficient).
One downside of course is that older versions of Blender will not be able to
read these files, but one can always just re-save them without compression or
decompress the file manually with an external tool.
The implementation here saves additional metadata into the compressed file in
order to allow for efficient seeking when loading. This is standard-compliant
and will be ignored by other tools that support Zstd.
If the metadata is not present (e.g. because you manually compressed a .blend
file with another tool), Blender will fall back to sequential reading.
Saving is multithreaded to improve performance. Loading is currently not
multithreaded since it's not easy to predict the access patterns of the
loading code when seeking is supported.
In the future, we might want to look into making this more predictable or
disabling seeking for the main .blend file, which would then allow for
multiple background threads that decompress data ahead of time.
The compression level was chosen to get sizes comparable to previous versions
at much higher speeds. In the future, this could be exposed as an option.
Reviewed By: campbellbarton, brecht, mont29
Differential Revision: https://developer.blender.org/D5799
2021-08-21 03:15:31 +02:00
|
|
|
find_package_wrapper(Zstd REQUIRED)
|
2022-08-15 14:58:04 +02:00
|
|
|
find_package_wrapper(Epoxy REQUIRED)
|
2022-01-24 15:25:05 +01:00
|
|
|
|
2023-04-12 05:22:26 +02:00
|
|
|
# XXX Linking errors with debian static tiff :/
|
|
|
|
|
# find_package_wrapper(TIFF REQUIRED)
|
|
|
|
|
find_package(TIFF)
|
2024-01-23 20:42:23 +11:00
|
|
|
# CMake 3.28.1 defines this, it doesn't seem to be used, hide by default in the UI.
|
2025-01-02 15:03:52 +11:00
|
|
|
# NOTE(@ideasman42): this doesn't seem to be important,
|
|
|
|
|
# on my system it's not-found even when the TIFF library is.
|
|
|
|
|
if(DEFINED Tiff_DIR)
|
|
|
|
|
mark_as_advanced(Tiff_DIR)
|
2024-01-23 20:42:23 +11:00
|
|
|
endif()
|
2023-04-12 05:22:26 +02:00
|
|
|
|
2022-11-22 11:28:37 +01:00
|
|
|
if(WITH_VULKAN_BACKEND)
|
2024-03-01 16:22:06 +11:00
|
|
|
if(DEFINED LIBDIR)
|
|
|
|
|
# If these are missing, something went wrong (outdated LIBDIR?).
|
|
|
|
|
if(NOT ((EXISTS "${LIBDIR}/vulkan") AND (EXISTS "${LIBDIR}/shaderc")))
|
|
|
|
|
message(FATAL_ERROR "${LIBDIR}/vulkan & ${LIBDIR}/shaderc are missing!")
|
|
|
|
|
endif()
|
2023-11-10 18:10:41 +01:00
|
|
|
if(NOT DEFINED VULKAN_ROOT_DIR)
|
|
|
|
|
set(VULKAN_ROOT_DIR ${LIBDIR}/vulkan)
|
|
|
|
|
endif()
|
|
|
|
|
if(NOT DEFINED SHADERC_ROOT_DIR)
|
|
|
|
|
set(SHADERC_ROOT_DIR ${LIBDIR}/shaderc)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
find_package_wrapper(Vulkan REQUIRED)
|
|
|
|
|
find_package_wrapper(ShaderC REQUIRED)
|
|
|
|
|
else()
|
|
|
|
|
# Use system libs
|
|
|
|
|
find_package(PkgConfig)
|
|
|
|
|
pkg_check_modules(VULKAN REQUIRED vulkan)
|
|
|
|
|
pkg_check_modules(SHADERC REQUIRED shaderc)
|
|
|
|
|
endif()
|
2022-11-22 11:28:37 +01:00
|
|
|
endif()
|
2023-10-06 15:24:21 +02:00
|
|
|
add_bundled_libraries(vulkan/lib)
|
2022-11-22 11:28:37 +01:00
|
|
|
|
2022-08-02 14:48:05 +02:00
|
|
|
function(check_freetype_for_brotli)
|
2023-10-06 17:56:18 +11:00
|
|
|
if((DEFINED HAVE_BROTLI AND HAVE_BROTLI) AND
|
|
|
|
|
(DEFINED HAVE_BROTLI_INC AND ("${HAVE_BROTLI_INC}" STREQUAL "${FREETYPE_INCLUDE_DIRS}")))
|
|
|
|
|
# Pass, the includes didn't change, use the cached value.
|
|
|
|
|
else()
|
2022-08-02 14:48:05 +02:00
|
|
|
unset(HAVE_BROTLI CACHE)
|
2023-10-06 17:56:18 +11:00
|
|
|
include(CheckSymbolExists)
|
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES ${FREETYPE_INCLUDE_DIRS})
|
|
|
|
|
check_symbol_exists(FT_CONFIG_OPTION_USE_BROTLI "freetype/config/ftconfig.h" HAVE_BROTLI)
|
|
|
|
|
unset(CMAKE_REQUIRED_INCLUDES)
|
|
|
|
|
if(NOT HAVE_BROTLI)
|
|
|
|
|
unset(HAVE_BROTLI CACHE)
|
|
|
|
|
message(FATAL_ERROR "Freetype needs to be compiled with brotli support!")
|
|
|
|
|
endif()
|
|
|
|
|
set(HAVE_BROTLI_INC "${FREETYPE_INCLUDE_DIRS}" CACHE INTERNAL "")
|
2022-08-02 14:48:05 +02:00
|
|
|
endif()
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2022-01-26 15:30:21 +11:00
|
|
|
if(NOT WITH_SYSTEM_FREETYPE)
|
|
|
|
|
# FreeType compiled with Brotli compression for woff2.
|
|
|
|
|
find_package_wrapper(Freetype REQUIRED)
|
2024-01-23 20:42:23 +11:00
|
|
|
# CMake 3.28.1 defines this, it doesn't seem to be used, hide by default in the UI.
|
|
|
|
|
if(DEFINED freetype_DIR)
|
|
|
|
|
mark_as_advanced(freetype_DIR)
|
|
|
|
|
endif()
|
|
|
|
|
|
2023-01-19 17:07:24 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2022-01-26 15:30:21 +11:00
|
|
|
find_package_wrapper(Brotli REQUIRED)
|
2022-01-26 20:47:03 +11:00
|
|
|
|
|
|
|
|
# NOTE: This is done on WIN32 & APPLE but fails on some Linux systems.
|
|
|
|
|
# See: https://devtalk.blender.org/t/22536
|
2022-01-28 13:59:08 +11:00
|
|
|
# So `BROTLI_LIBRARIES` need to be added directly after `FREETYPE_LIBRARIES`.
|
2022-01-26 20:47:03 +11:00
|
|
|
#
|
|
|
|
|
# list(APPEND FREETYPE_LIBRARIES
|
|
|
|
|
# ${BROTLI_LIBRARIES}
|
|
|
|
|
# )
|
2023-08-17 11:53:58 +10:00
|
|
|
else()
|
|
|
|
|
# Quiet warning as this variable will be used after `FREETYPE_LIBRARIES`.
|
|
|
|
|
set(BROTLI_LIBRARIES "")
|
2022-01-26 15:30:21 +11:00
|
|
|
endif()
|
2022-08-02 14:48:05 +02:00
|
|
|
check_freetype_for_brotli()
|
2022-01-25 16:18:53 +01:00
|
|
|
endif()
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2023-11-23 23:35:03 +01:00
|
|
|
if(WITH_HARFBUZZ)
|
|
|
|
|
find_package(Harfbuzz)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_FRIBIDI)
|
|
|
|
|
find_package(Fribidi)
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(WITH_PYTHON)
|
2022-09-14 14:06:41 +10:00
|
|
|
# This could be used, see: D14954 for details.
|
|
|
|
|
# `find_package(PythonLibs)`
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2022-09-14 14:06:41 +10:00
|
|
|
# Use our own instead, since without Python is such a rare case,
|
|
|
|
|
# require this package.
|
|
|
|
|
# XXX: Linking errors with Debian static Python (sigh).
|
|
|
|
|
# find_package_wrapper(PythonLibsUnix REQUIRED)
|
2016-08-09 15:19:11 +02:00
|
|
|
find_package(PythonLibsUnix REQUIRED)
|
2022-09-14 14:06:41 +10:00
|
|
|
|
|
|
|
|
if(WITH_PYTHON_MODULE AND NOT WITH_INSTALL_PORTABLE)
|
|
|
|
|
# Installing into `site-packages`, warn when installing into `./../lib/`
|
|
|
|
|
# which script authors almost certainly don't want.
|
2023-01-19 17:07:24 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2022-11-03 16:39:58 +11:00
|
|
|
path_is_prefix(LIBDIR PYTHON_SITE_PACKAGES _is_prefix)
|
2022-09-14 14:06:41 +10:00
|
|
|
if(_is_prefix)
|
|
|
|
|
message(WARNING "
|
|
|
|
|
Building Blender with the following configuration:
|
|
|
|
|
- WITH_PYTHON_MODULE=ON
|
|
|
|
|
- WITH_INSTALL_PORTABLE=OFF
|
|
|
|
|
- LIBDIR=\"${LIBDIR}\"
|
|
|
|
|
- PYTHON_SITE_PACKAGES=\"${PYTHON_SITE_PACKAGES}\"
|
|
|
|
|
In this case you may want to either:
|
|
|
|
|
- Use the system Python's site-packages, see:
|
|
|
|
|
python -c \"import site; print(site.getsitepackages()[0])\"
|
|
|
|
|
- Set WITH_INSTALL_PORTABLE=ON to create a stand-alone \"bpy\" module
|
|
|
|
|
which you will need to ensure is in Python's module search path.
|
|
|
|
|
Proceeding with PYTHON_SITE_PACKAGES install target, you have been warned!"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
unset(_is_prefix)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2023-08-10 11:57:30 +10:00
|
|
|
else()
|
|
|
|
|
# Python executable is needed as part of the build-process,
|
|
|
|
|
# note that building without Python is quite unusual.
|
|
|
|
|
find_program(PYTHON_EXECUTABLE "python3")
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_IMAGE_OPENEXR)
|
|
|
|
|
find_package_wrapper(OpenEXR) # our own module
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OpenEXR" OPENEXR_FOUND WITH_IMAGE_OPENEXR)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(openexr/lib)
|
|
|
|
|
add_bundled_libraries(imath/lib)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
|
|
|
|
if(WITH_IMAGE_OPENJPEG)
|
|
|
|
|
find_package_wrapper(OpenJPEG)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OpenJPEG" OPENJPEG_FOUND WITH_IMAGE_OPENJPEG)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_OPENAL)
|
|
|
|
|
find_package_wrapper(OpenAL)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OpenAL" OPENAL_FOUND WITH_OPENAL)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_SDL)
|
2024-09-13 22:44:35 +10:00
|
|
|
find_package_wrapper(SDL2)
|
|
|
|
|
if(SDL2_FOUND)
|
|
|
|
|
# Use same names for both versions of SDL until we move to 2.x.
|
|
|
|
|
set(SDL_INCLUDE_DIR "${SDL2_INCLUDE_DIR}")
|
|
|
|
|
set(SDL_LIBRARY "${SDL2_LIBRARY}")
|
|
|
|
|
set(SDL_FOUND "${SDL2_FOUND}")
|
2016-08-09 15:19:11 +02:00
|
|
|
else()
|
2024-09-13 22:44:35 +10:00
|
|
|
find_package_wrapper(SDL)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2024-09-13 22:44:35 +10:00
|
|
|
mark_as_advanced(
|
|
|
|
|
SDL_INCLUDE_DIR
|
|
|
|
|
SDL_LIBRARY
|
|
|
|
|
)
|
|
|
|
|
# unset(SDLMAIN_LIBRARY CACHE)
|
|
|
|
|
set_and_warn_library_found("SDL" SDL_FOUND WITH_SDL)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Codecs
|
|
|
|
|
if(WITH_CODEC_SNDFILE)
|
|
|
|
|
find_package_wrapper(SndFile)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("libsndfile" SNDFILE_FOUND WITH_CODEC_SNDFILE)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_CODEC_FFMPEG)
|
2023-01-19 17:07:24 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2022-01-12 18:21:43 +01:00
|
|
|
set(FFMPEG_ROOT_DIR ${LIBDIR}/ffmpeg)
|
2022-01-13 11:12:56 +01:00
|
|
|
# Override FFMPEG components to also include static library dependencies
|
|
|
|
|
# included with precompiled libraries, and to ensure correct link order.
|
2022-01-12 18:21:43 +01:00
|
|
|
set(FFMPEG_FIND_COMPONENTS
|
2022-01-13 11:12:56 +01:00
|
|
|
avformat avcodec avdevice avutil swresample swscale
|
|
|
|
|
sndfile
|
|
|
|
|
FLAC
|
|
|
|
|
mp3lame
|
|
|
|
|
opus
|
|
|
|
|
theora theoradec theoraenc
|
|
|
|
|
vorbis vorbisenc vorbisfile ogg
|
|
|
|
|
vpx
|
2024-06-15 14:15:53 +10:00
|
|
|
x264
|
|
|
|
|
)
|
2024-06-17 11:50:20 +02:00
|
|
|
if(EXISTS ${LIBDIR}/ffmpeg/lib/libx265.a)
|
|
|
|
|
list(APPEND FFMPEG_FIND_COMPONENTS x265)
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS ${LIBDIR}/ffmpeg/lib/libaom.a)
|
|
|
|
|
list(APPEND FFMPEG_FIND_COMPONENTS aom)
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS ${LIBDIR}/ffmpeg/lib/libxvidcore.a)
|
|
|
|
|
list(APPEND FFMPEG_FIND_COMPONENTS xvidcore)
|
2022-07-26 13:17:23 +02:00
|
|
|
endif()
|
2022-01-12 18:21:43 +01:00
|
|
|
elseif(FFMPEG)
|
|
|
|
|
# Old cache variable used for root dir, convert to new standard.
|
|
|
|
|
set(FFMPEG_ROOT_DIR ${FFMPEG})
|
2017-07-31 19:04:18 +02:00
|
|
|
endif()
|
2022-01-12 18:21:43 +01:00
|
|
|
find_package(FFmpeg)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("FFmpeg" FFMPEG_FOUND WITH_CODEC_FFMPEG)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_FFTW3)
|
|
|
|
|
find_package_wrapper(Fftw3)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("fftw3" FFTW3_FOUND WITH_FFTW3)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_MEM_JEMALLOC)
|
|
|
|
|
find_package_wrapper(JeMalloc)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("JeMalloc" JEMALLOC_FOUND WITH_MEM_JEMALLOC)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_INPUT_NDOF)
|
|
|
|
|
find_package_wrapper(Spacenav)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("SpaceNav" SPACENAV_FOUND WITH_INPUT_NDOF)
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(SPACENAV_FOUND)
|
|
|
|
|
# use generic names within blenders buildsystem.
|
|
|
|
|
set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS})
|
|
|
|
|
set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES})
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-12-07 18:31:36 +01:00
|
|
|
if(WITH_CYCLES AND WITH_CYCLES_OSL)
|
2024-03-01 16:22:06 +11:00
|
|
|
if(DEFINED LIBDIR)
|
|
|
|
|
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
|
|
|
|
|
if(EXISTS ${CYCLES_OSL} AND NOT OSL_ROOT)
|
|
|
|
|
set(OSL_ROOT ${CYCLES_OSL})
|
|
|
|
|
endif()
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2025-01-29 21:17:21 +01:00
|
|
|
find_package_wrapper(OSL 1.13.4)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OSL" OSL_FOUND WITH_CYCLES_OSL)
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(OSL_FOUND)
|
|
|
|
|
if(${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6")
|
|
|
|
|
# Note: --whole-archive is needed to force loading of all symbols in liboslexec,
|
|
|
|
|
# otherwise LLVM is missing the osl_allocate_closure_component function
|
|
|
|
|
set(OSL_LIBRARIES
|
|
|
|
|
${OSL_OSLCOMP_LIBRARY}
|
|
|
|
|
-Wl,--whole-archive ${OSL_OSLEXEC_LIBRARY}
|
|
|
|
|
-Wl,--no-whole-archive ${OSL_OSLQUERY_LIBRARY}
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2023-12-21 19:16:11 +01:00
|
|
|
add_bundled_libraries(osl/lib)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2024-06-12 19:19:12 +02:00
|
|
|
if(WITH_CYCLES AND DEFINED LIBDIR)
|
2022-06-29 12:58:04 +02:00
|
|
|
set(CYCLES_LEVEL_ZERO ${LIBDIR}/level-zero CACHE PATH "Path to Level Zero installation")
|
2023-07-10 12:02:15 +10:00
|
|
|
mark_as_advanced(CYCLES_LEVEL_ZERO)
|
2022-06-29 12:58:04 +02:00
|
|
|
if(EXISTS ${CYCLES_LEVEL_ZERO} AND NOT LEVEL_ZERO_ROOT_DIR)
|
|
|
|
|
set(LEVEL_ZERO_ROOT_DIR ${CYCLES_LEVEL_ZERO})
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-10-06 18:35:51 +02:00
|
|
|
set(CYCLES_SYCL ${LIBDIR}/dpcpp CACHE PATH "Path to oneAPI DPC++ compiler")
|
2023-07-10 12:02:15 +10:00
|
|
|
mark_as_advanced(CYCLES_SYCL)
|
2022-06-29 12:58:04 +02:00
|
|
|
if(EXISTS ${CYCLES_SYCL} AND NOT SYCL_ROOT_DIR)
|
|
|
|
|
set(SYCL_ROOT_DIR ${CYCLES_SYCL})
|
|
|
|
|
endif()
|
2023-05-09 18:29:28 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# add_bundled_libraries for SYCL, but custom since we need to filter the files.
|
|
|
|
|
if(DEFINED LIBDIR)
|
|
|
|
|
if(NOT DEFINED SYCL_ROOT_DIR)
|
|
|
|
|
set(SYCL_ROOT_DIR ${LIBDIR}/dpcpp)
|
|
|
|
|
endif()
|
2022-10-06 18:35:51 +02:00
|
|
|
file(GLOB _sycl_runtime_libraries
|
|
|
|
|
${SYCL_ROOT_DIR}/lib/libsycl.so
|
2022-10-19 12:31:17 +02:00
|
|
|
${SYCL_ROOT_DIR}/lib/libsycl.so.*
|
2022-11-25 15:43:40 +01:00
|
|
|
${SYCL_ROOT_DIR}/lib/libpi_*.so
|
2024-05-24 20:34:28 +02:00
|
|
|
${SYCL_ROOT_DIR}/lib/libur_*.so
|
2024-12-12 15:58:55 +01:00
|
|
|
${SYCL_ROOT_DIR}/lib/libur_*.so.*
|
2022-10-06 18:35:51 +02:00
|
|
|
)
|
2022-10-19 12:31:17 +02:00
|
|
|
list(FILTER _sycl_runtime_libraries EXCLUDE REGEX ".*\.py")
|
2022-10-06 18:35:51 +02:00
|
|
|
list(APPEND PLATFORM_BUNDLED_LIBRARIES ${_sycl_runtime_libraries})
|
|
|
|
|
unset(_sycl_runtime_libraries)
|
2022-06-29 12:58:04 +02:00
|
|
|
endif()
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(WITH_OPENVDB)
|
2022-12-05 23:18:54 +01:00
|
|
|
find_package(OpenVDB)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OpenVDB" OPENVDB_FOUND WITH_OPENVDB)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(openvdb/lib)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2020-10-02 17:40:28 +02:00
|
|
|
if(WITH_NANOVDB)
|
|
|
|
|
find_package_wrapper(NanoVDB)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("NanoVDB" NANOVDB_FOUND WITH_NANOVDB)
|
2020-10-02 17:40:28 +02:00
|
|
|
endif()
|
|
|
|
|
|
2021-03-01 19:15:29 +01:00
|
|
|
if(WITH_CPU_SIMD AND SUPPORT_NEON_BUILD)
|
2021-02-14 04:16:39 +01:00
|
|
|
find_package_wrapper(sse2neon)
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(WITH_ALEMBIC)
|
|
|
|
|
find_package_wrapper(Alembic)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("Alembic" ALEMBIC_FOUND WITH_ALEMBIC)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
|
USD: Introducing a simple USD Exporter
This commit introduces the first version of an exporter to Pixar's
Universal Scene Description (USD) format.
Reviewed By: sergey, LazyDodo
Differential Revision: https://developer.blender.org/D6287
- The USD libraries are built by `make deps`, but not yet built by
install_deps.sh.
- Only experimental support for instancing; by default all duplicated
objects are made real in the USD file. This is fine for exporting a
linked-in posed character, not so much for thousands of pebbles etc.
- The way materials and UV coordinates and Normals are exported is going
to change soon.
- This patch contains LazyDodo's fixes for building on Windows in D5359.
== Meshes ==
USD seems to support neither per-material nor per-face-group
double-sidedness, so we just use the flag from the first non-empty
material slot. If there is no material we default to double-sidedness.
Each UV map is stored on the mesh in a separate primvar. Materials can
refer to these UV maps, but this is not yet exported by Blender. The
primvar name is the same as the UV Map name. This is to allow the
standard name "st" for texture coordinates by naming the UV Map as such,
without having to guess which UV Map is the "standard" one.
Face-varying mesh normals are written to USD. When the mesh has custom
loop normals those are written. Otherwise the poly flag `ME_SMOOTH` is
inspected to determine the normals.
The UV maps and mesh normals take up a significant amount of space, so
exporting them is optional. They're still enabled by default, though.
For comparison: a shot of Spring (03_035_A) is 1.2 GiB when exported
with UVs and normals, and 262 MiB without. We probably have room for
optimisation of written UVs and normals.
The mesh subdivision scheme isn't using the default value 'Catmull
Clark', but uses 'None', indicating we're exporting a polygonal mesh.
This is necessary for USD to understand our normals; otherwise the mesh
is always rendered smooth. In the future we may want to expose this
choice of subdivision scheme to the user, or auto-detect it when we
actually support exporting pre-subdivision meshes.
A possible optimisation could be to inspect whether all polygons are
smooth or flat, and mark the USD mesh as such. This can be added when
needed.
== Animation ==
Mesh and transform animation are now written when passing
`animation=True` to the export operator. There is no inspection of
whether an object is actually animated or not; USD can handle
deduplication of static values for us.
The administration of which timecode to use for the export is left to
the file-format-specific concrete subclasses of
`AbstractHierarchyIterator`; the abstract iterator itself doesn't know
anything about the passage of time. This will allow subclasses for the
frame-based USD format and time-based Alembic format.
== Support for simple preview materials ==
Very simple versions of the materials are now exported, using only the
viewport diffuse RGB, metallic, and roughness.
When there are multiple materials, the mesh faces are stored as geometry
subset and each material is assigned to the appropriate subset. If there
is only one material this is skipped.
The first material if any) is always applied to the mesh itself
(regardless of the existence of geometry subsets), because the Hydra
viewport doesn't support materials on subsets. See
https://github.com/PixarAnimationStudios/USD/issues/542 for more info.
Note that the geometry subsets are not yet time-sampled, so it may break
when an animated mesh changes topology.
Materials are exported as a flat list under a top-level '/_materials'
namespace. This inhibits instancing of the objects using those
materials, so this is subject to change.
== Hair ==
Only the parent strands are exported, and only with a constant colour.
No UV coordinates, no information about the normals.
== Camera ==
Only perspective cameras are supported for now.
== Particles ==
Particles are only written when they are alive, which means that they
are always visible (there is currently no code that deals with marking
them as invisible outside their lifespan).
Particle-system-instanced objects are exported by suffixing the object
name with the particle's persistent ID, giving each particle XForm a
unique name.
== Instancing/referencing ==
This exporter has experimental support for instancing/referencing.
Dupli-object meshes are now written to USD as references to the original
mesh. This is still very limited in correctness, as there are issues
referencing to materials from a referenced mesh.
I am still committing this, as it gives us a place to start when
continuing the quest for proper instancing in USD.
== Lights ==
USD does not directly support spot lights, so those aren't exported yet.
It's possible to add this in the future via the UsdLuxShapingAPI. The
units used for the light intensity are also still a bit of a mystery.
== Fluid vertex velocities ==
Currently only fluid simulations (not meshes in general) have explicit
vertex velocities. This is the most important case for exporting
velocities, though, as the baked mesh changes topology all the time, and
thus computing the velocities at import time in a post-processing step
is hard.
== The Building Process ==
- USD is built as monolithic library, instead of 25 smaller libraries.
We were linking all of them as 'whole archive' anyway, so this doesn't
affect the final file size. It does, however, make life easier with
respect to linking order, and handling upstream changes.
- The JSON files required by USD are installed into datafiles/usd; they
are required on every platform. Set the `PXR_PATH_DEBUG` to any value
to have the USD library print the paths it uses to find those files.
- USD is patched so that it finds the aforementioned JSON files in a path
that we pass to it from Blender.
- USD is patched to have a `PXR_BUILD_USD_TOOLS` CMake option to disable
building the tools in its `bin` directory. This is sent as a pull
request at https://github.com/PixarAnimationStudios/USD/pull/1048
2019-12-13 10:27:40 +01:00
|
|
|
if(WITH_USD)
|
|
|
|
|
find_package_wrapper(USD)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("USD" USD_FOUND WITH_USD)
|
2023-09-26 18:05:36 +02:00
|
|
|
set_and_warn_library_found("Hydra" USD_FOUND WITH_HYDRA)
|
2022-12-05 23:18:54 +01:00
|
|
|
endif()
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(usd/lib)
|
2022-12-05 23:18:54 +01:00
|
|
|
|
|
|
|
|
if(WITH_MATERIALX)
|
|
|
|
|
find_package_wrapper(MaterialX)
|
|
|
|
|
set_and_warn_library_found("MaterialX" MaterialX_FOUND WITH_MATERIALX)
|
USD: Introducing a simple USD Exporter
This commit introduces the first version of an exporter to Pixar's
Universal Scene Description (USD) format.
Reviewed By: sergey, LazyDodo
Differential Revision: https://developer.blender.org/D6287
- The USD libraries are built by `make deps`, but not yet built by
install_deps.sh.
- Only experimental support for instancing; by default all duplicated
objects are made real in the USD file. This is fine for exporting a
linked-in posed character, not so much for thousands of pebbles etc.
- The way materials and UV coordinates and Normals are exported is going
to change soon.
- This patch contains LazyDodo's fixes for building on Windows in D5359.
== Meshes ==
USD seems to support neither per-material nor per-face-group
double-sidedness, so we just use the flag from the first non-empty
material slot. If there is no material we default to double-sidedness.
Each UV map is stored on the mesh in a separate primvar. Materials can
refer to these UV maps, but this is not yet exported by Blender. The
primvar name is the same as the UV Map name. This is to allow the
standard name "st" for texture coordinates by naming the UV Map as such,
without having to guess which UV Map is the "standard" one.
Face-varying mesh normals are written to USD. When the mesh has custom
loop normals those are written. Otherwise the poly flag `ME_SMOOTH` is
inspected to determine the normals.
The UV maps and mesh normals take up a significant amount of space, so
exporting them is optional. They're still enabled by default, though.
For comparison: a shot of Spring (03_035_A) is 1.2 GiB when exported
with UVs and normals, and 262 MiB without. We probably have room for
optimisation of written UVs and normals.
The mesh subdivision scheme isn't using the default value 'Catmull
Clark', but uses 'None', indicating we're exporting a polygonal mesh.
This is necessary for USD to understand our normals; otherwise the mesh
is always rendered smooth. In the future we may want to expose this
choice of subdivision scheme to the user, or auto-detect it when we
actually support exporting pre-subdivision meshes.
A possible optimisation could be to inspect whether all polygons are
smooth or flat, and mark the USD mesh as such. This can be added when
needed.
== Animation ==
Mesh and transform animation are now written when passing
`animation=True` to the export operator. There is no inspection of
whether an object is actually animated or not; USD can handle
deduplication of static values for us.
The administration of which timecode to use for the export is left to
the file-format-specific concrete subclasses of
`AbstractHierarchyIterator`; the abstract iterator itself doesn't know
anything about the passage of time. This will allow subclasses for the
frame-based USD format and time-based Alembic format.
== Support for simple preview materials ==
Very simple versions of the materials are now exported, using only the
viewport diffuse RGB, metallic, and roughness.
When there are multiple materials, the mesh faces are stored as geometry
subset and each material is assigned to the appropriate subset. If there
is only one material this is skipped.
The first material if any) is always applied to the mesh itself
(regardless of the existence of geometry subsets), because the Hydra
viewport doesn't support materials on subsets. See
https://github.com/PixarAnimationStudios/USD/issues/542 for more info.
Note that the geometry subsets are not yet time-sampled, so it may break
when an animated mesh changes topology.
Materials are exported as a flat list under a top-level '/_materials'
namespace. This inhibits instancing of the objects using those
materials, so this is subject to change.
== Hair ==
Only the parent strands are exported, and only with a constant colour.
No UV coordinates, no information about the normals.
== Camera ==
Only perspective cameras are supported for now.
== Particles ==
Particles are only written when they are alive, which means that they
are always visible (there is currently no code that deals with marking
them as invisible outside their lifespan).
Particle-system-instanced objects are exported by suffixing the object
name with the particle's persistent ID, giving each particle XForm a
unique name.
== Instancing/referencing ==
This exporter has experimental support for instancing/referencing.
Dupli-object meshes are now written to USD as references to the original
mesh. This is still very limited in correctness, as there are issues
referencing to materials from a referenced mesh.
I am still committing this, as it gives us a place to start when
continuing the quest for proper instancing in USD.
== Lights ==
USD does not directly support spot lights, so those aren't exported yet.
It's possible to add this in the future via the UsdLuxShapingAPI. The
units used for the light intensity are also still a bit of a mystery.
== Fluid vertex velocities ==
Currently only fluid simulations (not meshes in general) have explicit
vertex velocities. This is the most important case for exporting
velocities, though, as the baked mesh changes topology all the time, and
thus computing the velocities at import time in a post-processing step
is hard.
== The Building Process ==
- USD is built as monolithic library, instead of 25 smaller libraries.
We were linking all of them as 'whole archive' anyway, so this doesn't
affect the final file size. It does, however, make life easier with
respect to linking order, and handling upstream changes.
- The JSON files required by USD are installed into datafiles/usd; they
are required on every platform. Set the `PXR_PATH_DEBUG` to any value
to have the USD library print the paths it uses to find those files.
- USD is patched so that it finds the aforementioned JSON files in a path
that we pass to it from Blender.
- USD is patched to have a `PXR_BUILD_USD_TOOLS` CMake option to disable
building the tools in its `bin` directory. This is sent as a pull
request at https://github.com/PixarAnimationStudios/USD/pull/1048
2019-12-13 10:27:40 +01:00
|
|
|
endif()
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(materialx/lib)
|
USD: Introducing a simple USD Exporter
This commit introduces the first version of an exporter to Pixar's
Universal Scene Description (USD) format.
Reviewed By: sergey, LazyDodo
Differential Revision: https://developer.blender.org/D6287
- The USD libraries are built by `make deps`, but not yet built by
install_deps.sh.
- Only experimental support for instancing; by default all duplicated
objects are made real in the USD file. This is fine for exporting a
linked-in posed character, not so much for thousands of pebbles etc.
- The way materials and UV coordinates and Normals are exported is going
to change soon.
- This patch contains LazyDodo's fixes for building on Windows in D5359.
== Meshes ==
USD seems to support neither per-material nor per-face-group
double-sidedness, so we just use the flag from the first non-empty
material slot. If there is no material we default to double-sidedness.
Each UV map is stored on the mesh in a separate primvar. Materials can
refer to these UV maps, but this is not yet exported by Blender. The
primvar name is the same as the UV Map name. This is to allow the
standard name "st" for texture coordinates by naming the UV Map as such,
without having to guess which UV Map is the "standard" one.
Face-varying mesh normals are written to USD. When the mesh has custom
loop normals those are written. Otherwise the poly flag `ME_SMOOTH` is
inspected to determine the normals.
The UV maps and mesh normals take up a significant amount of space, so
exporting them is optional. They're still enabled by default, though.
For comparison: a shot of Spring (03_035_A) is 1.2 GiB when exported
with UVs and normals, and 262 MiB without. We probably have room for
optimisation of written UVs and normals.
The mesh subdivision scheme isn't using the default value 'Catmull
Clark', but uses 'None', indicating we're exporting a polygonal mesh.
This is necessary for USD to understand our normals; otherwise the mesh
is always rendered smooth. In the future we may want to expose this
choice of subdivision scheme to the user, or auto-detect it when we
actually support exporting pre-subdivision meshes.
A possible optimisation could be to inspect whether all polygons are
smooth or flat, and mark the USD mesh as such. This can be added when
needed.
== Animation ==
Mesh and transform animation are now written when passing
`animation=True` to the export operator. There is no inspection of
whether an object is actually animated or not; USD can handle
deduplication of static values for us.
The administration of which timecode to use for the export is left to
the file-format-specific concrete subclasses of
`AbstractHierarchyIterator`; the abstract iterator itself doesn't know
anything about the passage of time. This will allow subclasses for the
frame-based USD format and time-based Alembic format.
== Support for simple preview materials ==
Very simple versions of the materials are now exported, using only the
viewport diffuse RGB, metallic, and roughness.
When there are multiple materials, the mesh faces are stored as geometry
subset and each material is assigned to the appropriate subset. If there
is only one material this is skipped.
The first material if any) is always applied to the mesh itself
(regardless of the existence of geometry subsets), because the Hydra
viewport doesn't support materials on subsets. See
https://github.com/PixarAnimationStudios/USD/issues/542 for more info.
Note that the geometry subsets are not yet time-sampled, so it may break
when an animated mesh changes topology.
Materials are exported as a flat list under a top-level '/_materials'
namespace. This inhibits instancing of the objects using those
materials, so this is subject to change.
== Hair ==
Only the parent strands are exported, and only with a constant colour.
No UV coordinates, no information about the normals.
== Camera ==
Only perspective cameras are supported for now.
== Particles ==
Particles are only written when they are alive, which means that they
are always visible (there is currently no code that deals with marking
them as invisible outside their lifespan).
Particle-system-instanced objects are exported by suffixing the object
name with the particle's persistent ID, giving each particle XForm a
unique name.
== Instancing/referencing ==
This exporter has experimental support for instancing/referencing.
Dupli-object meshes are now written to USD as references to the original
mesh. This is still very limited in correctness, as there are issues
referencing to materials from a referenced mesh.
I am still committing this, as it gives us a place to start when
continuing the quest for proper instancing in USD.
== Lights ==
USD does not directly support spot lights, so those aren't exported yet.
It's possible to add this in the future via the UsdLuxShapingAPI. The
units used for the light intensity are also still a bit of a mystery.
== Fluid vertex velocities ==
Currently only fluid simulations (not meshes in general) have explicit
vertex velocities. This is the most important case for exporting
velocities, though, as the baked mesh changes topology all the time, and
thus computing the velocities at import time in a post-processing step
is hard.
== The Building Process ==
- USD is built as monolithic library, instead of 25 smaller libraries.
We were linking all of them as 'whole archive' anyway, so this doesn't
affect the final file size. It does, however, make life easier with
respect to linking order, and handling upstream changes.
- The JSON files required by USD are installed into datafiles/usd; they
are required on every platform. Set the `PXR_PATH_DEBUG` to any value
to have the USD library print the paths it uses to find those files.
- USD is patched so that it finds the aforementioned JSON files in a path
that we pass to it from Blender.
- USD is patched to have a `PXR_BUILD_USD_TOOLS` CMake option to disable
building the tools in its `bin` directory. This is sent as a pull
request at https://github.com/PixarAnimationStudios/USD/pull/1048
2019-12-13 10:27:40 +01:00
|
|
|
|
2025-02-06 14:53:16 +01:00
|
|
|
# With Blender 4.4 libraries there is no more Boost. But Linux distros may have
|
|
|
|
|
# older versions of libs like USD with a header dependency on Boost, so can't
|
|
|
|
|
# remove this entirely yet.
|
|
|
|
|
if(WITH_BOOST)
|
|
|
|
|
if(DEFINED LIBDIR AND NOT EXISTS "${LIBDIR}/boost")
|
|
|
|
|
set(WITH_BOOST OFF)
|
|
|
|
|
set(BOOST_LIBRARIES)
|
|
|
|
|
set(BOOST_PYTHON_LIBRARIES)
|
|
|
|
|
set(BOOST_INCLUDE_DIR)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(WITH_BOOST)
|
|
|
|
|
# uses in build instructions to override include and library variables
|
|
|
|
|
if(NOT BOOST_CUSTOM)
|
|
|
|
|
if(WITH_STATIC_LIBS)
|
2022-12-05 23:18:54 +01:00
|
|
|
set(Boost_USE_STATIC_LIBS OFF)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
set(Boost_USE_MULTITHREADED ON)
|
2025-01-13 10:40:18 +01:00
|
|
|
set(__boost_packages)
|
2022-12-05 23:18:54 +01:00
|
|
|
if(WITH_USD AND USD_PYTHON_SUPPORT)
|
|
|
|
|
list(APPEND __boost_packages python${PYTHON_VERSION_NO_DOTS})
|
|
|
|
|
endif()
|
2023-03-30 22:27:17 +02:00
|
|
|
set(Boost_NO_WARN_NEW_VERSIONS ON)
|
2016-08-09 15:19:11 +02:00
|
|
|
find_package(Boost 1.48 COMPONENTS ${__boost_packages})
|
|
|
|
|
if(NOT Boost_FOUND)
|
|
|
|
|
# try to find non-multithreaded if -mt not found, this flag
|
|
|
|
|
# doesn't matter for us, it has nothing to do with thread
|
|
|
|
|
# safety, but keep it to not disturb build setups
|
|
|
|
|
set(Boost_USE_MULTITHREADED OFF)
|
|
|
|
|
find_package(Boost 1.48 COMPONENTS ${__boost_packages})
|
|
|
|
|
endif()
|
|
|
|
|
unset(__boost_packages)
|
2018-09-19 17:48:11 +02:00
|
|
|
mark_as_advanced(Boost_DIR) # why doesn't boost do this?
|
2022-02-17 18:42:06 +01:00
|
|
|
mark_as_advanced(Boost_INCLUDE_DIR) # why doesn't boost do this?
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2019-04-17 06:35:54 +02:00
|
|
|
|
2025-01-22 10:02:22 +01:00
|
|
|
# Boost Python is the only library Blender directly depends on, though USD headers.
|
2022-12-07 20:38:28 +01:00
|
|
|
if(WITH_USD AND USD_PYTHON_SUPPORT)
|
|
|
|
|
set(BOOST_PYTHON_LIBRARIES ${Boost_PYTHON${PYTHON_VERSION_NO_DOTS}_LIBRARY})
|
|
|
|
|
endif()
|
|
|
|
|
set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
|
2016-08-09 15:19:11 +02:00
|
|
|
set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
|
|
|
|
|
set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
|
|
|
|
|
endif()
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(boost/lib)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2020-12-01 16:24:19 +01:00
|
|
|
if(WITH_PUGIXML)
|
|
|
|
|
find_package_wrapper(PugiXML)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("PugiXML" PUGIXML_FOUND WITH_PUGIXML)
|
2020-12-01 16:24:19 +01:00
|
|
|
endif()
|
|
|
|
|
|
2022-03-24 18:24:06 -04:00
|
|
|
if(WITH_IMAGE_WEBP)
|
2024-03-01 16:22:06 +11:00
|
|
|
if(DEFINED LIBDIR)
|
|
|
|
|
set(WEBP_ROOT_DIR ${LIBDIR}/webp)
|
|
|
|
|
endif()
|
2022-03-24 18:24:06 -04:00
|
|
|
find_package_wrapper(WebP)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("WebP" WEBP_FOUND WITH_IMAGE_WEBP)
|
2022-03-24 18:24:06 -04:00
|
|
|
endif()
|
|
|
|
|
|
2023-03-03 21:53:34 +01:00
|
|
|
find_package_wrapper(OpenImageIO REQUIRED)
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(openimageio/lib)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
|
|
|
|
if(WITH_OPENCOLORIO)
|
OpenColorIO: upgrade to version 2.0.0
Ref T84819
Build System
============
This is an API breaking new version, and the updated code only builds with
OpenColorIO 2.0 and later. Adding backwards compatibility was too complicated.
* Tinyxml was replaced with Expat, adding a new dependency.
* Yaml-cpp is now built as a dependency on Unix, as was already done on Windows.
* Removed currently unused LCMS code.
* Pystring remains built as part of OCIO itself, since it has no good build system.
* Linux and macOS check for the OpenColorIO verison, and disable it if too old.
Ref D10270
Processors and Transforms
=========================
CPU processors now need to be created to do CPU processing. These are cached
internally, but the cache lookup is not fast enough to execute per pixel or
texture sample, so for performance these are now also exposed in the C API.
The C API for transforms will no longer be needed afer all changes, so remove
it to simplify the API and fallback implementation.
Ref D10271
Display Transforms
==================
Needs a bit more manual work constructing the transform. LegacyViewingPipeline
could also have been used, but isn't really any simpler and since it's legacy
we better not rely on it.
We moved more logic into the opencolorio module, to simplify the API. There is
no need to wrap a dozen functions just to be able to do this in C rather than C++.
It's also tightly coupled to the GPU shader logic, and so should be in the same
module.
Ref D10271
GPU Display Shader
==================
To avoid baking exposure and gamma into the GLSL shader and requiring slow
recompiles when tweaking, we manually apply them in the shader. This leads
to some logic duplicaton between the CPU and GPU display processor, but it
seems unavoidable.
Caching was also changed. Previously this was done both on the imbuf and
opencolorio module levels. Now it's all done in the opencolorio module by
simply matching color space names. We no longer use cacheIDs from OpenColorIO
since computing them is expensive, and they are unlikely to match now that
more is baked into the shader code.
Shaders can now use multiple 2D textures, 3D textures and uniforms, rather
than a single 3D texture. So allocating and binding those adds some code.
Color space conversions for blending with overlays is now hardcoded in the
shader. This was using harcoded numbers anyway, if this every becomes a
general OpenColorIO transform it can be changed, but for now there is no
point to add code complexity.
Ref D10273
CIE XYZ
=======
We need standard CIE XYZ values for rendering effects like blackbody emission.
The relation to the scene linear role is based on OpenColorIO configuration.
In OpenColorIO 2.0 configs roles can no longer have the same name as color
spaces, which means our XYZ role and colorspace in the configuration give an
error.
Instead use the new standard aces_interchange role, which relates scene linear
to a known scene referred color space. Compatibility with the old XYZ role is
preserved, if the configuration file has no conflicting names.
Also includes a non-functional change to the configuraton file to use an
XYZ-to-ACES matrix instead of REC709-to-ACES, makes debugging a little easier
since the matrix is the same one we have in the code now and that is also
found easily in the ACES specs.
Ref D10274
2021-01-31 19:35:00 +01:00
|
|
|
find_package_wrapper(OpenColorIO 2.0.0)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2023-01-19 17:07:23 +11:00
|
|
|
set(OPENCOLORIO_DEFINITIONS "")
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OpenColorIO" OPENCOLORIO_FOUND WITH_OPENCOLORIO)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(opencolorio/lib)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2021-12-07 18:31:36 +01:00
|
|
|
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
|
2025-04-30 19:50:14 +02:00
|
|
|
find_package(Embree 4.0.0 REQUIRED)
|
2018-11-07 12:58:12 +01:00
|
|
|
endif()
|
2023-04-05 11:03:06 +02:00
|
|
|
add_bundled_libraries(embree/lib)
|
2018-11-07 12:58:12 +01:00
|
|
|
|
Compositor: Added denoising node
This node is built on Intel's OpenImageDenoise library.
Other denoisers could be integrated, for example Lukas' Cycles denoiser.
Compositor: Made OpenImageDenoise optional, added CMake and build_env files to find OIDN
Compositor: Fixed some warnings in the denoising operator
build_environment: Updated OpenImageDenoise to 0.8.1
build_environment: Updated OpenImageDenoise in `make deps` for macOS
Reviewers: sergey, jbakker, brecht
Reviewed By: brecht
Subscribers: YAFU, LazyDodo, Zen_YS, slumber, samgreen, tjvoll, yeus, ponomarovmax, getrad, coder.kalyan, vitos1k, Yegor, DeepBlender, kumaran7, Darkfie9825, aliasguru, aafra, ace_dragon, juang3d, pandrodor, cdog, lordodin, jtheninja, mavek, marcog, 5k1n2, Atair, rawalanche, 0o00o0oo, filibis, poor, lukasstockner97
Tags: #compositing
Differential Revision: https://developer.blender.org/D4304
2019-08-14 15:30:26 +02:00
|
|
|
if(WITH_OPENIMAGEDENOISE)
|
|
|
|
|
find_package_wrapper(OpenImageDenoise)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OpenImageDenoise" OPENIMAGEDENOISE_FOUND WITH_OPENIMAGEDENOISE)
|
2023-11-08 10:12:05 +01:00
|
|
|
add_bundled_libraries(openimagedenoise/lib)
|
Compositor: Added denoising node
This node is built on Intel's OpenImageDenoise library.
Other denoisers could be integrated, for example Lukas' Cycles denoiser.
Compositor: Made OpenImageDenoise optional, added CMake and build_env files to find OIDN
Compositor: Fixed some warnings in the denoising operator
build_environment: Updated OpenImageDenoise to 0.8.1
build_environment: Updated OpenImageDenoise in `make deps` for macOS
Reviewers: sergey, jbakker, brecht
Reviewed By: brecht
Subscribers: YAFU, LazyDodo, Zen_YS, slumber, samgreen, tjvoll, yeus, ponomarovmax, getrad, coder.kalyan, vitos1k, Yegor, DeepBlender, kumaran7, Darkfie9825, aliasguru, aafra, ace_dragon, juang3d, pandrodor, cdog, lordodin, jtheninja, mavek, marcog, 5k1n2, Atair, rawalanche, 0o00o0oo, filibis, poor, lukasstockner97
Tags: #compositing
Differential Revision: https://developer.blender.org/D4304
2019-08-14 15:30:26 +02:00
|
|
|
endif()
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(WITH_LLVM)
|
2023-01-19 17:07:24 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2017-07-31 19:04:18 +02:00
|
|
|
set(LLVM_STATIC ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
find_package_wrapper(LLVM)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("LLVM" LLVM_FOUND WITH_LLVM)
|
|
|
|
|
|
|
|
|
|
if(LLVM_FOUND)
|
|
|
|
|
if(WITH_CLANG)
|
|
|
|
|
find_package_wrapper(Clang)
|
|
|
|
|
set_and_warn_library_found("Clang" CLANG_FOUND WITH_CLANG)
|
2018-08-17 12:40:31 +02:00
|
|
|
endif()
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2018-11-26 11:41:38 +01:00
|
|
|
if(WITH_OPENSUBDIV)
|
2022-12-05 23:18:54 +01:00
|
|
|
find_package(OpenSubdiv)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
|
|
|
|
set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARIES})
|
|
|
|
|
set(OPENSUBDIV_LIBPATH) # TODO, remove and reference the absolute path everywhere
|
|
|
|
|
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OpenSubdiv" OPENSUBDIV_FOUND WITH_OPENSUBDIV)
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(opensubdiv/lib)
|
2016-08-09 15:19:11 +02:00
|
|
|
|
2019-10-09 16:44:29 +02:00
|
|
|
if(WITH_TBB)
|
2025-05-07 18:22:38 +02:00
|
|
|
find_package_wrapper(TBB 2021.13.0)
|
2025-04-15 17:31:36 +02:00
|
|
|
if(TBB_FOUND)
|
|
|
|
|
get_target_property(TBB_LIBRARIES TBB::tbb LOCATION)
|
|
|
|
|
get_target_property(TBB_INCLUDE_DIRS TBB::tbb INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
|
endif()
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("TBB" TBB_FOUND WITH_TBB)
|
2025-08-21 16:15:06 +10:00
|
|
|
mark_as_advanced(TBB_DIR)
|
2019-10-09 16:44:29 +02:00
|
|
|
endif()
|
2022-12-16 13:55:46 +01:00
|
|
|
add_bundled_libraries(tbb/lib)
|
2019-10-09 16:44:29 +02:00
|
|
|
|
2020-03-04 16:39:00 +01:00
|
|
|
if(WITH_XR_OPENXR)
|
2020-08-07 16:53:06 +02:00
|
|
|
find_package(XR_OpenXR_SDK)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("OpenXR-SDK" XR_OPENXR_SDK_FOUND WITH_XR_OPENXR)
|
2020-03-04 16:39:00 +01:00
|
|
|
endif()
|
|
|
|
|
|
2020-07-31 09:34:26 -06:00
|
|
|
if(WITH_GMP)
|
|
|
|
|
find_package_wrapper(GMP)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("GMP" GMP_FOUND WITH_GMP)
|
2020-07-31 09:34:26 -06:00
|
|
|
endif()
|
|
|
|
|
|
2020-09-15 13:16:37 -06:00
|
|
|
if(WITH_POTRACE)
|
|
|
|
|
find_package_wrapper(Potrace)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("Potrace" POTRACE_FOUND WITH_POTRACE)
|
2020-09-15 13:16:37 -06:00
|
|
|
endif()
|
|
|
|
|
|
2021-02-09 14:36:11 +01:00
|
|
|
if(WITH_HARU)
|
|
|
|
|
find_package_wrapper(Haru)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("Haru" HARU_FOUND WITH_HARU)
|
2021-02-09 14:36:11 +01:00
|
|
|
endif()
|
2025-04-22 21:23:37 -04:00
|
|
|
|
|
|
|
|
if(WITH_MANIFOLD)
|
|
|
|
|
if(WITH_LIBS_PRECOMPILED OR WITH_STRICT_BUILD_OPTIONS)
|
|
|
|
|
find_package(manifold REQUIRED)
|
|
|
|
|
else()
|
|
|
|
|
# This isn't a common system library, so disable if it's not found.
|
|
|
|
|
find_package(manifold)
|
2025-07-17 11:32:13 +02:00
|
|
|
if(TARGET manifold::manifold)
|
|
|
|
|
set(MANIFOLD_FOUND TRUE)
|
|
|
|
|
endif()
|
2025-04-22 21:23:37 -04:00
|
|
|
set_and_warn_library_found("MANIFOLD" MANIFOLD_FOUND WITH_MANIFOLD)
|
|
|
|
|
endif()
|
2025-08-21 16:18:57 +10:00
|
|
|
mark_as_advanced(manifold_DIR)
|
2025-04-22 21:23:37 -04:00
|
|
|
endif()
|
2022-10-04 19:29:52 +02:00
|
|
|
|
2022-10-17 13:24:24 +02:00
|
|
|
if(WITH_CYCLES AND WITH_CYCLES_PATH_GUIDING)
|
2022-10-04 19:29:52 +02:00
|
|
|
find_package_wrapper(openpgl)
|
2023-11-04 16:41:26 +11:00
|
|
|
mark_as_advanced(openpgl_DIR)
|
2022-10-04 19:29:52 +02:00
|
|
|
if(openpgl_FOUND)
|
|
|
|
|
get_target_property(OPENPGL_LIBRARIES openpgl::openpgl LOCATION)
|
|
|
|
|
get_target_property(OPENPGL_INCLUDE_DIR openpgl::openpgl INTERFACE_INCLUDE_DIRECTORIES)
|
2023-10-07 18:20:30 +11:00
|
|
|
if(FIRST_RUN)
|
|
|
|
|
message(STATUS "Found OpenPGL: ${OPENPGL_LIBRARIES}")
|
|
|
|
|
endif()
|
2022-10-04 19:29:52 +02:00
|
|
|
else()
|
|
|
|
|
set(WITH_CYCLES_PATH_GUIDING OFF)
|
|
|
|
|
message(STATUS "OpenPGL not found, disabling WITH_CYCLES_PATH_GUIDING")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2021-02-09 14:36:11 +01:00
|
|
|
|
2023-01-19 17:07:24 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2020-02-20 22:09:14 -07:00
|
|
|
without_system_libs_end()
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-09-24 14:35:24 +02:00
|
|
|
add_bundled_libraries(hiprt/lib)
|
|
|
|
|
|
2020-02-20 22:09:14 -07:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Build and Link Flags
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
# OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
|
2017-11-30 17:56:01 +11:00
|
|
|
if(HAIKU)
|
|
|
|
|
list(APPEND PLATFORM_LINKLIBS -lnetwork)
|
|
|
|
|
else()
|
|
|
|
|
list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm)
|
|
|
|
|
endif()
|
2016-08-09 15:19:11 +02:00
|
|
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
2023-01-19 17:07:23 +11:00
|
|
|
# `FindThreads` documentation notes that this may be empty
|
|
|
|
|
# with the system libraries provide threading functionality.
|
|
|
|
|
if(CMAKE_THREAD_LIBS_INIT)
|
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
# used by other platforms
|
|
|
|
|
set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
|
|
|
|
|
if(CMAKE_DL_LIBS)
|
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS})
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-03-07 17:56:41 +11:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
2016-08-09 15:19:11 +02:00
|
|
|
if(NOT WITH_PYTHON_MODULE)
|
|
|
|
|
# binreloc is linux only
|
|
|
|
|
set(BINRELOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/binreloc/include)
|
|
|
|
|
set(WITH_BINRELOC ON)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# lfs on glibc, all compilers should use
|
|
|
|
|
add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
|
|
|
|
|
|
2020-02-06 01:30:26 +11:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# System Libraries
|
|
|
|
|
#
|
|
|
|
|
# Keep last, so indirectly linked libraries don't override our own pre-compiled libs.
|
|
|
|
|
|
2023-01-19 17:07:24 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2022-01-26 15:20:32 +11:00
|
|
|
# Clear the prefix path as it causes the `LIBDIR` to override system locations.
|
|
|
|
|
unset(CMAKE_PREFIX_PATH)
|
|
|
|
|
|
|
|
|
|
# Since the pre-compiled `LIBDIR` directories have been handled, don't prefer static libraries.
|
|
|
|
|
set(WITH_STATIC_LIBS ${WITH_STATIC_LIBS_INIT})
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-01-26 15:30:21 +11:00
|
|
|
if(WITH_SYSTEM_FREETYPE)
|
|
|
|
|
find_package_wrapper(Freetype)
|
|
|
|
|
if(NOT FREETYPE_FOUND)
|
|
|
|
|
message(FATAL_ERROR "Failed finding system FreeType version!")
|
|
|
|
|
endif()
|
2022-08-02 14:48:05 +02:00
|
|
|
check_freetype_for_brotli()
|
2023-08-17 11:53:58 +10:00
|
|
|
# Quiet warning as this variable will be used after `FREETYPE_LIBRARIES`.
|
|
|
|
|
set(BROTLI_LIBRARIES "")
|
2022-01-26 15:30:21 +11:00
|
|
|
endif()
|
2022-01-26 15:20:32 +11:00
|
|
|
|
2020-02-20 22:09:14 -07:00
|
|
|
if(WITH_SYSTEM_EIGEN3)
|
|
|
|
|
find_package_wrapper(Eigen3)
|
|
|
|
|
if(NOT EIGEN3_FOUND)
|
|
|
|
|
message(FATAL_ERROR "Failed finding system Eigen3 version!")
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Jack is intended to use the system library.
|
|
|
|
|
if(WITH_JACK)
|
|
|
|
|
find_package_wrapper(Jack)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("JACK" JACK_FOUND WITH_JACK)
|
2020-02-20 22:09:14 -07:00
|
|
|
endif()
|
|
|
|
|
|
2021-03-02 17:29:18 +01:00
|
|
|
# Pulse is intended to use the system library.
|
|
|
|
|
if(WITH_PULSEAUDIO)
|
|
|
|
|
find_package_wrapper(Pulse)
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("PulseAudio" PULSE_FOUND WITH_PULSEAUDIO)
|
2021-03-02 17:29:18 +01:00
|
|
|
endif()
|
|
|
|
|
|
2024-08-02 12:18:26 +02:00
|
|
|
# PipeWire is intended to use the system library.
|
|
|
|
|
if(WITH_PIPEWIRE)
|
|
|
|
|
find_package(PkgConfig)
|
2025-01-06 18:19:08 +01:00
|
|
|
pkg_check_modules(PIPEWIRE libpipewire-0.3>=1.1.0)
|
2024-08-02 12:18:26 +02:00
|
|
|
set_and_warn_library_found("PipeWire" PIPEWIRE_FOUND WITH_PIPEWIRE)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-02-20 22:09:14 -07:00
|
|
|
# Audio IO
|
|
|
|
|
if(WITH_SYSTEM_AUDASPACE)
|
|
|
|
|
find_package_wrapper(Audaspace)
|
2022-09-29 19:01:35 +02:00
|
|
|
set(AUDASPACE_FOUND ${AUDASPACE_FOUND} AND ${AUDASPACE_C_FOUND})
|
|
|
|
|
set_and_warn_library_found("External Audaspace" AUDASPACE_FOUND WITH_SYSTEM_AUDASPACE)
|
2020-02-20 22:09:14 -07:00
|
|
|
endif()
|
|
|
|
|
|
2020-04-30 13:46:42 +10:00
|
|
|
if(WITH_GHOST_WAYLAND)
|
|
|
|
|
find_package(PkgConfig)
|
2022-08-29 18:59:46 +02:00
|
|
|
pkg_check_modules(xkbcommon xkbcommon)
|
|
|
|
|
|
2022-10-08 07:57:14 +11:00
|
|
|
# When dynamically linked WAYLAND is used and `${LIBDIR}/wayland` is present,
|
|
|
|
|
# there is no need to search for the libraries as they are not needed for building.
|
|
|
|
|
# Only the headers are needed which can reference the known paths.
|
2024-03-01 16:22:06 +11:00
|
|
|
set(_use_system_wayland ON)
|
|
|
|
|
if(DEFINED LIBDIR)
|
|
|
|
|
if(EXISTS "${LIBDIR}/wayland" AND WITH_GHOST_WAYLAND_DYNLOAD)
|
|
|
|
|
set(_use_system_wayland OFF)
|
|
|
|
|
endif()
|
2022-10-08 07:57:14 +11:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(_use_system_wayland)
|
|
|
|
|
pkg_check_modules(wayland-client wayland-client>=1.12)
|
|
|
|
|
pkg_check_modules(wayland-egl wayland-egl)
|
|
|
|
|
pkg_check_modules(wayland-scanner wayland-scanner)
|
|
|
|
|
pkg_check_modules(wayland-cursor wayland-cursor)
|
2023-04-04 19:08:47 +10:00
|
|
|
pkg_check_modules(wayland-protocols wayland-protocols>=1.31)
|
2022-08-29 18:59:46 +02:00
|
|
|
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
|
|
|
|
else()
|
2023-04-04 19:08:47 +10:00
|
|
|
# NOTE: this file must always refer to the newest API which is used, so older
|
|
|
|
|
# `wayland-protocols` are never found and used which then fail to locate required protocols.
|
|
|
|
|
set(_wayland_protocols_reference_file "staging/fractional-scale/fractional-scale-v1.xml")
|
|
|
|
|
|
|
|
|
|
# Reset the protocols directory the reference file from `wayland-protocols` is not found.
|
|
|
|
|
# This avoids developers having build failures when a cached directory is used that no
|
|
|
|
|
# longer contains the required file.
|
|
|
|
|
if(DEFINED WAYLAND_PROTOCOLS_DIR)
|
|
|
|
|
if(NOT EXISTS "${WAYLAND_PROTOCOLS_DIR}/${_wayland_protocols_reference_file}")
|
|
|
|
|
unset(WAYLAND_PROTOCOLS_DIR CACHE)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-12-15 18:09:40 +11:00
|
|
|
# Rocky8 packages have too old a version, a newer version exist in the pre-compiled libraries.
|
2022-08-29 18:59:46 +02:00
|
|
|
find_path(WAYLAND_PROTOCOLS_DIR
|
2023-04-04 19:08:47 +10:00
|
|
|
NAMES ${_wayland_protocols_reference_file}
|
2022-08-29 18:59:46 +02:00
|
|
|
PATH_SUFFIXES share/wayland-protocols
|
2024-06-26 12:17:40 +02:00
|
|
|
HINTS ${LIBDIR}/wayland-protocols
|
2022-08-29 18:59:46 +02:00
|
|
|
)
|
2023-04-04 19:08:47 +10:00
|
|
|
unset(_wayland_protocols_reference_file)
|
2022-06-27 16:33:58 +10:00
|
|
|
|
2022-08-29 18:59:46 +02:00
|
|
|
if(EXISTS ${WAYLAND_PROTOCOLS_DIR})
|
|
|
|
|
set(wayland-protocols_FOUND ON)
|
|
|
|
|
endif()
|
2022-10-08 07:57:14 +11:00
|
|
|
|
|
|
|
|
set(wayland-client_INCLUDE_DIRS "${LIBDIR}/wayland/include")
|
|
|
|
|
set(wayland-egl_INCLUDE_DIRS "${LIBDIR}/wayland/include")
|
|
|
|
|
set(wayland-cursor_INCLUDE_DIRS "${LIBDIR}/wayland/include")
|
|
|
|
|
|
|
|
|
|
set(wayland-client_FOUND ON)
|
|
|
|
|
set(wayland-egl_FOUND ON)
|
|
|
|
|
set(wayland-scanner_FOUND ON)
|
|
|
|
|
set(wayland-cursor_FOUND ON)
|
2022-06-27 16:33:58 +10:00
|
|
|
endif()
|
2022-11-01 12:48:57 +11:00
|
|
|
mark_as_advanced(WAYLAND_PROTOCOLS_DIR)
|
2020-04-30 13:46:42 +10:00
|
|
|
|
2022-09-29 19:01:35 +02:00
|
|
|
set_and_warn_library_found("wayland-client" wayland-client_FOUND WITH_GHOST_WAYLAND)
|
|
|
|
|
set_and_warn_library_found("wayland-egl" wayland-egl_FOUND WITH_GHOST_WAYLAND)
|
|
|
|
|
set_and_warn_library_found("wayland-scanner" wayland-scanner_FOUND WITH_GHOST_WAYLAND)
|
|
|
|
|
set_and_warn_library_found("wayland-cursor" wayland-cursor_FOUND WITH_GHOST_WAYLAND)
|
|
|
|
|
set_and_warn_library_found("wayland-protocols" wayland-protocols_FOUND WITH_GHOST_WAYLAND)
|
|
|
|
|
set_and_warn_library_found("xkbcommon" xkbcommon_FOUND WITH_GHOST_WAYLAND)
|
2022-06-24 16:10:20 +10:00
|
|
|
|
2022-09-27 11:53:12 +10:00
|
|
|
if(WITH_GHOST_WAYLAND)
|
|
|
|
|
if(WITH_GHOST_WAYLAND_LIBDECOR)
|
2022-10-08 07:57:14 +11:00
|
|
|
if(_use_system_wayland)
|
2023-04-24 16:21:33 +02:00
|
|
|
pkg_check_modules(libdecor libdecor-0>=0.1)
|
2022-10-08 07:57:14 +11:00
|
|
|
else()
|
|
|
|
|
set(libdecor_INCLUDE_DIRS "${LIBDIR}/wayland_libdecor/include/libdecor-0")
|
2023-04-24 16:21:33 +02:00
|
|
|
set(libdecor_FOUND ON)
|
2022-10-08 07:57:14 +11:00
|
|
|
endif()
|
2023-04-24 16:21:33 +02:00
|
|
|
set_and_warn_library_found("libdecor" libdecor_FOUND WITH_GHOST_WAYLAND_LIBDECOR)
|
2022-09-27 11:53:12 +10:00
|
|
|
endif()
|
2022-06-27 16:33:58 +10:00
|
|
|
|
2022-09-27 11:53:12 +10:00
|
|
|
if(WITH_GHOST_WAYLAND_LIBDECOR)
|
|
|
|
|
add_definitions(-DWITH_GHOST_WAYLAND_LIBDECOR)
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-03-01 16:22:06 +11:00
|
|
|
if(DEFINED LIBDIR)
|
2022-09-27 11:54:35 +10:00
|
|
|
set(WAYLAND_SCANNER "${LIBDIR}/wayland/bin/wayland-scanner")
|
2024-03-01 16:22:06 +11:00
|
|
|
if(NOT (EXISTS "${WAYLAND_SCANNER}"))
|
|
|
|
|
message(FATAL_ERROR "${WAYLAND_SCANNER} is missing!")
|
|
|
|
|
endif()
|
2022-09-27 11:54:35 +10:00
|
|
|
else()
|
|
|
|
|
pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
|
2024-08-15 21:49:42 +10:00
|
|
|
# Check the variable is set, otherwise an empty command will attempt to be executed.
|
|
|
|
|
if(NOT WAYLAND_SCANNER)
|
|
|
|
|
message(FATAL_ERROR "\"wayland-scanner\" could not be found!")
|
|
|
|
|
endif()
|
2022-09-27 11:54:35 +10:00
|
|
|
endif()
|
2022-11-01 12:48:57 +11:00
|
|
|
mark_as_advanced(WAYLAND_SCANNER)
|
2022-09-27 11:53:12 +10:00
|
|
|
|
|
|
|
|
# When using dynamic loading, headers generated
|
|
|
|
|
# from older versions of `wayland-scanner` aren't compatible.
|
|
|
|
|
if(WITH_GHOST_WAYLAND_DYNLOAD)
|
|
|
|
|
execute_process(
|
|
|
|
|
COMMAND ${WAYLAND_SCANNER} --version
|
|
|
|
|
# The version is written to the `stderr`.
|
|
|
|
|
ERROR_VARIABLE _wayland_scanner_out
|
|
|
|
|
ERROR_STRIP_TRAILING_WHITESPACE
|
2022-09-20 12:53:06 +10:00
|
|
|
)
|
2022-09-27 11:53:12 +10:00
|
|
|
if(NOT "${_wayland_scanner_out}" STREQUAL "")
|
|
|
|
|
string(
|
|
|
|
|
REGEX REPLACE
|
|
|
|
|
"^wayland-scanner[ \t]+([0-9]+)\.([0-9]+).*"
|
|
|
|
|
"\\1.\\2"
|
|
|
|
|
_wayland_scanner_ver
|
|
|
|
|
"${_wayland_scanner_out}"
|
2022-09-20 12:53:06 +10:00
|
|
|
)
|
2022-09-27 11:53:12 +10:00
|
|
|
if("${_wayland_scanner_ver}" VERSION_LESS "1.20")
|
|
|
|
|
message(
|
|
|
|
|
FATAL_ERROR
|
|
|
|
|
"Found ${WAYLAND_SCANNER} version \"${_wayland_scanner_ver}\", "
|
|
|
|
|
"the minimum version is 1.20!"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
unset(_wayland_scanner_ver)
|
|
|
|
|
else()
|
|
|
|
|
message(WARNING "Unable to access the version from ${WAYLAND_SCANNER}, continuing.")
|
2022-09-20 12:53:06 +10:00
|
|
|
endif()
|
2022-09-27 11:53:12 +10:00
|
|
|
unset(_wayland_scanner_out)
|
2022-09-20 12:53:06 +10:00
|
|
|
endif()
|
2022-09-27 11:53:12 +10:00
|
|
|
# End wayland-scanner version check.
|
|
|
|
|
|
2022-06-24 16:10:20 +10:00
|
|
|
endif()
|
2022-10-08 07:57:14 +11:00
|
|
|
|
|
|
|
|
unset(_use_system_wayland)
|
2020-04-30 13:46:42 +10:00
|
|
|
endif()
|
|
|
|
|
|
2020-05-01 19:14:50 +10:00
|
|
|
if(WITH_GHOST_X11)
|
2020-02-06 01:30:26 +11:00
|
|
|
find_package(X11 REQUIRED)
|
2023-11-04 16:41:26 +11:00
|
|
|
# For some reason the finder doesn't mark this.
|
|
|
|
|
mark_as_advanced(X11_xcb_xkb_INCLUDE_PATH)
|
2020-02-06 01:30:26 +11:00
|
|
|
|
|
|
|
|
find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
|
|
|
|
|
mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
|
|
|
|
|
|
|
|
|
|
if(WITH_X11_XINPUT)
|
2022-10-11 14:52:35 +02:00
|
|
|
if(NOT X11_Xinput_LIB)
|
2023-08-24 10:37:20 +10:00
|
|
|
message(
|
|
|
|
|
FATAL_ERROR
|
|
|
|
|
"LibXi not found. "
|
|
|
|
|
"Disable WITH_X11_XINPUT if you want to build without tablet support"
|
|
|
|
|
)
|
2020-02-06 01:30:26 +11:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_X11_XFIXES)
|
2022-10-11 14:52:35 +02:00
|
|
|
if(NOT X11_Xfixes_LIB)
|
2023-08-24 10:37:20 +10:00
|
|
|
message(
|
|
|
|
|
FATAL_ERROR
|
|
|
|
|
"libXfixes not found. "
|
|
|
|
|
"Disable WITH_X11_XFIXES if you want to build without"
|
|
|
|
|
)
|
2020-02-06 01:30:26 +11:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_X11_ALPHA)
|
2022-12-17 13:30:07 +11:00
|
|
|
find_library(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH})
|
2020-02-06 01:30:26 +11:00
|
|
|
mark_as_advanced(X11_Xrender_LIB)
|
2022-10-11 14:52:35 +02:00
|
|
|
if(NOT X11_Xrender_LIB)
|
2023-08-24 10:37:20 +10:00
|
|
|
message(
|
|
|
|
|
FATAL_ERROR
|
|
|
|
|
"libXrender not found. "
|
|
|
|
|
"Disable WITH_X11_ALPHA if you want to build without"
|
|
|
|
|
)
|
2020-02-06 01:30:26 +11:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
# Compilers
|
|
|
|
|
|
2022-01-15 16:36:08 +11:00
|
|
|
# Only set the linker once.
|
|
|
|
|
set(_IS_LINKER_DEFAULT ON)
|
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
# GNU Compiler
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCC)
|
2021-01-14 17:32:21 +01:00
|
|
|
# ffp-contract=off:
|
|
|
|
|
# Automatically turned on when building with "-march=native". This is
|
|
|
|
|
# explicitly turned off here as it will make floating point math give a bit
|
|
|
|
|
# different results. This will lead to automated test failures. So disable
|
2023-04-20 08:56:55 +02:00
|
|
|
# this until we support it.
|
2021-01-14 17:32:21 +01:00
|
|
|
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -ffp-contract=off")
|
2019-04-17 06:35:54 +02:00
|
|
|
|
2020-08-20 10:19:52 +02:00
|
|
|
# `maybe-uninitialized` is unreliable in release builds, but fine in debug builds.
|
|
|
|
|
set(GCC_EXTRA_FLAGS_RELEASE "-Wno-maybe-uninitialized")
|
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${GCC_EXTRA_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELEASE}")
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${GCC_EXTRA_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${GCC_EXTRA_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}")
|
2020-11-06 10:29:04 +11:00
|
|
|
string(PREPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO "${GCC_EXTRA_FLAGS_RELEASE} ")
|
2020-08-20 10:19:52 +02:00
|
|
|
unset(GCC_EXTRA_FLAGS_RELEASE)
|
|
|
|
|
|
2022-01-15 16:36:08 +11:00
|
|
|
if(WITH_LINKER_MOLD AND _IS_LINKER_DEFAULT)
|
2022-01-12 13:35:07 +11:00
|
|
|
find_program(MOLD_BIN "mold")
|
|
|
|
|
mark_as_advanced(MOLD_BIN)
|
2023-04-13 13:14:19 +10:00
|
|
|
|
2022-01-12 13:35:07 +11:00
|
|
|
if(NOT MOLD_BIN)
|
2022-01-15 16:36:08 +11:00
|
|
|
message(STATUS "The \"mold\" binary could not be found, using system linker.")
|
2022-01-12 13:35:07 +11:00
|
|
|
set(WITH_LINKER_MOLD OFF)
|
2023-04-13 13:14:19 +10:00
|
|
|
elseif(CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1)
|
2024-02-28 15:23:04 +01:00
|
|
|
message(STATUS "GCC 12.1 or newer is required for the MOLD linker.")
|
2023-04-13 13:14:19 +10:00
|
|
|
set(WITH_LINKER_MOLD OFF)
|
2022-01-12 13:35:07 +11:00
|
|
|
else()
|
2023-04-13 13:14:19 +10:00
|
|
|
get_filename_component(MOLD_BIN_DIR "${MOLD_BIN}" DIRECTORY)
|
|
|
|
|
# Check if the `-B` argument is required.
|
|
|
|
|
# This will happen when `MOLD_BIN` points to a non-standard location.
|
|
|
|
|
# Keep this option as mold is not yet a standard system component and
|
|
|
|
|
# users may have it installed in some unexpected place.
|
|
|
|
|
set(_mold_args "-fuse-ld=mold")
|
|
|
|
|
execute_process(
|
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} -B ${MOLD_BIN_DIR} ${_mold_args} -Wl,--version
|
|
|
|
|
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION_WITH_DIR
|
2022-01-12 13:35:07 +11:00
|
|
|
)
|
2023-04-13 13:14:19 +10:00
|
|
|
execute_process(
|
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} ${_mold_args} -Wl,--version
|
|
|
|
|
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION
|
|
|
|
|
)
|
|
|
|
|
if(NOT (LD_VERSION STREQUAL LD_VERSION_WITH_DIR))
|
|
|
|
|
string(PREPEND _mold_args "-B \"${MOLD_BIN_DIR}\" ")
|
|
|
|
|
set(LD_VERSION "${LD_VERSION_WITH_DIR}")
|
2022-01-12 13:35:07 +11:00
|
|
|
endif()
|
|
|
|
|
|
2023-04-13 13:14:19 +10:00
|
|
|
if("${LD_VERSION}" MATCHES "mold ")
|
|
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " ${_mold_args}")
|
|
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${_mold_args}")
|
|
|
|
|
string(APPEND CMAKE_MODULE_LINKER_FLAGS " ${_mold_args}")
|
|
|
|
|
set(_IS_LINKER_DEFAULT OFF)
|
|
|
|
|
else()
|
|
|
|
|
message(STATUS "GNU mold linker isn't available, using the default system linker.")
|
|
|
|
|
endif()
|
|
|
|
|
unset(_mold_args)
|
|
|
|
|
unset(MOLD_BIN_DIR)
|
|
|
|
|
unset(LD_VERSION)
|
2022-01-12 13:35:07 +11:00
|
|
|
endif()
|
|
|
|
|
unset(MOLD_BIN)
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-01-15 16:36:08 +11:00
|
|
|
if(WITH_LINKER_GOLD AND _IS_LINKER_DEFAULT)
|
|
|
|
|
execute_process(
|
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
|
|
|
|
|
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
|
|
|
|
if("${LD_VERSION}" MATCHES "GNU gold")
|
|
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold")
|
|
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold")
|
|
|
|
|
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold")
|
|
|
|
|
set(_IS_LINKER_DEFAULT OFF)
|
|
|
|
|
else()
|
|
|
|
|
message(STATUS "GNU gold linker isn't available, using the default system linker.")
|
|
|
|
|
endif()
|
|
|
|
|
unset(LD_VERSION)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(WITH_LINKER_LLD AND _IS_LINKER_DEFAULT)
|
|
|
|
|
execute_process(
|
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=lld -Wl,--version
|
|
|
|
|
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
|
|
|
|
|
if("${LD_VERSION}" MATCHES "LLD")
|
|
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=lld")
|
|
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=lld")
|
|
|
|
|
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=lld")
|
|
|
|
|
set(_IS_LINKER_DEFAULT OFF)
|
|
|
|
|
else()
|
|
|
|
|
message(STATUS "LLD linker isn't available, using the default system linker.")
|
|
|
|
|
endif()
|
|
|
|
|
unset(LD_VERSION)
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-01-03 13:23:38 +11:00
|
|
|
# CLang is the same as GCC for now.
|
2024-03-07 19:56:58 +11:00
|
|
|
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2023-04-20 08:56:55 +02:00
|
|
|
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -ffp-contract=off")
|
2022-01-12 13:35:07 +11:00
|
|
|
|
2022-01-15 16:36:08 +11:00
|
|
|
if(WITH_LINKER_MOLD AND _IS_LINKER_DEFAULT)
|
2022-01-12 13:35:07 +11:00
|
|
|
find_program(MOLD_BIN "mold")
|
|
|
|
|
mark_as_advanced(MOLD_BIN)
|
|
|
|
|
if(NOT MOLD_BIN)
|
2022-01-15 16:36:08 +11:00
|
|
|
message(STATUS "The \"mold\" binary could not be found, using system linker.")
|
2022-01-12 13:35:07 +11:00
|
|
|
set(WITH_LINKER_MOLD OFF)
|
|
|
|
|
else()
|
|
|
|
|
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
|
2022-01-15 16:36:08 +11:00
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
|
2022-01-15 16:12:13 +11:00
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
|
|
|
|
|
string(APPEND CMAKE_MODULE_LINKER_FLAGS " --ld-path=\"${MOLD_BIN}\"")
|
2022-01-12 13:35:07 +11:00
|
|
|
else()
|
2022-01-15 16:36:08 +11:00
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
|
2022-01-15 16:12:13 +11:00
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
|
|
|
|
|
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=\"${MOLD_BIN}\"")
|
2022-01-12 13:35:07 +11:00
|
|
|
endif()
|
2022-01-15 16:36:08 +11:00
|
|
|
set(_IS_LINKER_DEFAULT OFF)
|
2022-01-12 13:35:07 +11:00
|
|
|
endif()
|
2022-01-15 16:36:08 +11:00
|
|
|
unset(MOLD_BIN)
|
2022-01-12 13:35:07 +11:00
|
|
|
endif()
|
|
|
|
|
|
2023-06-16 10:33:30 +02:00
|
|
|
if(WITH_LINKER_LLD AND _IS_LINKER_DEFAULT)
|
|
|
|
|
find_program(LLD_BIN "ld.lld")
|
|
|
|
|
mark_as_advanced(LLD_BIN)
|
|
|
|
|
if(NOT LLD_BIN)
|
|
|
|
|
message(STATUS "The \"ld.lld\" binary could not be found, using system linker.")
|
|
|
|
|
set(WITH_LINKER_LLD OFF)
|
|
|
|
|
else()
|
|
|
|
|
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
|
|
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " --ld-path=\"${LLD_BIN}\"")
|
|
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " --ld-path=\"${LLD_BIN}\"")
|
|
|
|
|
string(APPEND CMAKE_MODULE_LINKER_FLAGS " --ld-path=\"${LLD_BIN}\"")
|
|
|
|
|
else()
|
|
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=\"${LLD_BIN}\"")
|
|
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=\"${LLD_BIN}\"")
|
|
|
|
|
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=\"${LLD_BIN}\"")
|
|
|
|
|
endif()
|
|
|
|
|
set(_IS_LINKER_DEFAULT OFF)
|
|
|
|
|
endif()
|
|
|
|
|
unset(LLD_BIN)
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-01-03 13:23:38 +11:00
|
|
|
# Intel C++ Compiler
|
2024-03-07 17:56:41 +11:00
|
|
|
elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
|
2016-08-09 15:19:11 +02:00
|
|
|
# think these next two are broken
|
|
|
|
|
find_program(XIAR xiar)
|
|
|
|
|
if(XIAR)
|
|
|
|
|
set(CMAKE_AR "${XIAR}")
|
|
|
|
|
endif()
|
|
|
|
|
mark_as_advanced(XIAR)
|
2019-04-17 06:35:54 +02:00
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
find_program(XILD xild)
|
|
|
|
|
if(XILD)
|
|
|
|
|
set(CMAKE_LINKER "${XILD}")
|
|
|
|
|
endif()
|
|
|
|
|
mark_as_advanced(XILD)
|
2019-04-17 06:35:54 +02:00
|
|
|
|
2020-11-06 10:29:04 +11:00
|
|
|
string(APPEND CMAKE_C_FLAGS " -fp-model precise -prec_div -parallel")
|
|
|
|
|
string(APPEND CMAKE_CXX_FLAGS " -fp-model precise -prec_div -parallel")
|
2019-04-17 06:35:54 +02:00
|
|
|
|
2020-11-06 10:29:04 +11:00
|
|
|
# string(APPEND PLATFORM_CFLAGS " -diag-enable sc3")
|
2016-08-09 15:19:11 +02:00
|
|
|
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
|
2020-11-06 10:29:04 +11:00
|
|
|
string(APPEND PLATFORM_LINKFLAGS " -static-intel")
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2020-03-30 21:24:13 +02:00
|
|
|
|
2022-01-15 16:36:08 +11:00
|
|
|
unset(_IS_LINKER_DEFAULT)
|
|
|
|
|
|
2020-03-30 21:24:13 +02:00
|
|
|
# Avoid conflicts with Mesa llvmpipe, Luxrender, and other plug-ins that may
|
|
|
|
|
# use the same libraries as Blender with a different version or build options.
|
2022-07-29 17:31:52 +02:00
|
|
|
set(PLATFORM_SYMBOLS_MAP ${CMAKE_SOURCE_DIR}/source/creator/symbols_unix.map)
|
2020-03-30 21:24:13 +02:00
|
|
|
set(PLATFORM_LINKFLAGS
|
2022-07-29 17:31:52 +02:00
|
|
|
"${PLATFORM_LINKFLAGS} -Wl,--version-script='${PLATFORM_SYMBOLS_MAP}'"
|
2020-03-30 21:24:13 +02:00
|
|
|
)
|
2020-04-07 03:52:46 +02:00
|
|
|
|
|
|
|
|
# Don't use position independent executable for portable install since file
|
|
|
|
|
# browsers can't properly detect blender as an executable then. Still enabled
|
|
|
|
|
# for non-portable installs as typically used by Linux distributions.
|
|
|
|
|
if(WITH_INSTALL_PORTABLE)
|
2020-11-06 10:29:04 +11:00
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -no-pie")
|
2020-04-07 03:52:46 +02:00
|
|
|
endif()
|
2020-12-21 10:47:35 +05:30
|
|
|
|
|
|
|
|
if(WITH_COMPILER_CCACHE)
|
|
|
|
|
find_program(CCACHE_PROGRAM ccache)
|
2023-07-10 12:02:15 +10:00
|
|
|
mark_as_advanced(CCACHE_PROGRAM)
|
2020-12-21 10:47:35 +05:30
|
|
|
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)
|
2023-07-10 12:02:15 +10:00
|
|
|
mark_as_advanced(
|
|
|
|
|
CMAKE_C_COMPILER_LAUNCHER
|
|
|
|
|
CMAKE_CXX_COMPILER_LAUNCHER
|
|
|
|
|
)
|
2020-12-21 10:47:35 +05:30
|
|
|
else()
|
|
|
|
|
message(WARNING "Ccache NOT found, disabling WITH_COMPILER_CCACHE")
|
|
|
|
|
set(WITH_COMPILER_CCACHE OFF)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
2022-02-11 11:10:53 +01:00
|
|
|
|
2022-12-02 18:00:32 +01:00
|
|
|
# Always link with libatomic if available, as it is required for data types
|
|
|
|
|
# which don't have intrinsics.
|
|
|
|
|
function(configure_atomic_lib_if_needed)
|
2022-02-11 11:10:53 +01:00
|
|
|
set(_source
|
|
|
|
|
"#include <atomic>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
std::atomic<uint64_t> uint64; uint64++;
|
|
|
|
|
return 0;
|
2022-08-09 13:36:45 +10:00
|
|
|
}"
|
|
|
|
|
)
|
2022-02-11 11:10:53 +01:00
|
|
|
|
|
|
|
|
include(CheckCXXSourceCompiles)
|
2022-12-02 18:00:32 +01:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES atomic)
|
|
|
|
|
check_cxx_source_compiles("${_source}" ATOMIC_OPS_WITH_LIBATOMIC)
|
|
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
2022-02-11 11:10:53 +01:00
|
|
|
|
2022-12-02 18:00:32 +01:00
|
|
|
if(ATOMIC_OPS_WITH_LIBATOMIC)
|
|
|
|
|
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -latomic" PARENT_SCOPE)
|
2022-02-11 11:10:53 +01:00
|
|
|
endif()
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2022-09-23 14:33:44 +10:00
|
|
|
configure_atomic_lib_if_needed()
|
2022-08-18 17:07:10 +02:00
|
|
|
|
|
|
|
|
if(PLATFORM_BUNDLED_LIBRARIES)
|
|
|
|
|
# For the installed Python module and installed Blender executable, we set the
|
|
|
|
|
# rpath to the relative path where the install step will copy the shared libraries.
|
|
|
|
|
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
|
|
|
|
|
list(APPEND CMAKE_INSTALL_RPATH $ORIGIN/lib)
|
|
|
|
|
|
|
|
|
|
# For executables that are built but not installed (mainly tests) we set an absolute
|
|
|
|
|
# rpath to the lib folder. 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 $ORIGIN/lib ${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/lib)
|
2022-12-05 23:05:25 +01:00
|
|
|
|
|
|
|
|
# Environment variables to run precompiled executables that needed libraries.
|
|
|
|
|
list(JOIN PLATFORM_BUNDLED_LIBRARY_DIRS ":" _library_paths)
|
2024-08-16 17:13:05 +10:00
|
|
|
# Intentionally double "$$" which expands into "$" when instantiated.
|
2024-03-07 13:26:55 +11:00
|
|
|
set(PLATFORM_ENV_BUILD
|
2024-08-16 17:13:05 +10:00
|
|
|
"LD_LIBRARY_PATH=\"${_library_paths}:$$LD_LIBRARY_PATH\""
|
2024-03-07 13:26:55 +11:00
|
|
|
)
|
|
|
|
|
set(PLATFORM_ENV_INSTALL
|
2024-08-16 17:13:05 +10:00
|
|
|
"LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/lib/;$$LD_LIBRARY_PATH"
|
2024-03-07 13:26:55 +11:00
|
|
|
)
|
2022-12-05 23:05:25 +01:00
|
|
|
unset(_library_paths)
|
2024-03-01 16:22:06 +11:00
|
|
|
else()
|
|
|
|
|
# Quiet unused variable warnings, unfortunately this can't be empty.
|
|
|
|
|
set(PLATFORM_ENV_BUILD "_DUMMY_ENV_VAR_=1")
|
|
|
|
|
set(PLATFORM_ENV_INSTALL "_DUMMY_ENV_VAR_=1")
|
2022-08-18 17:07:10 +02:00
|
|
|
endif()
|