2016-08-09 15:19:11 +02:00
|
|
|
# ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# The Original Code is Copyright (C) 2016, Blender Foundation
|
|
|
|
# All rights reserved.
|
|
|
|
# ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
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
|
2018-08-29 16:15:54 +02:00
|
|
|
if(NOT DEFINED LIBDIR)
|
2019-10-09 17:14:00 +02:00
|
|
|
# Path to a locally compiled libraries.
|
2018-08-29 16:15:54 +02:00
|
|
|
set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
|
|
|
|
string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME)
|
2019-10-09 17:14:00 +02:00
|
|
|
set(LIBDIR_NATIVE_ABI ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
|
|
|
|
|
|
|
|
# Path to precompiled libraries with known CentOS 7 ABI.
|
|
|
|
set(LIBDIR_CENTOS7_ABI ${CMAKE_SOURCE_DIR}/../lib/linux_centos7_x86_64)
|
|
|
|
|
|
|
|
# Choose the best suitable libraries.
|
|
|
|
if(EXISTS ${LIBDIR_NATIVE_ABI})
|
|
|
|
set(LIBDIR ${LIBDIR_NATIVE_ABI})
|
|
|
|
elseif(EXISTS ${LIBDIR_CENTOS7_ABI})
|
|
|
|
set(LIBDIR ${LIBDIR_CENTOS7_ABI})
|
|
|
|
set(WITH_CXX11_ABI OFF)
|
2020-07-27 17:29:13 +02:00
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCC AND
|
|
|
|
CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3)
|
|
|
|
message(FATAL_ERROR "GCC version must be at least 9.3 for precompiled libraries, found ${CMAKE_C_COMPILER_VERSION}")
|
|
|
|
endif()
|
2019-10-09 17:14:00 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Avoid namespace pollustion.
|
|
|
|
unset(LIBDIR_NATIVE_ABI)
|
|
|
|
unset(LIBDIR_CENTOS7_ABI)
|
2018-08-29 16:15:54 +02:00
|
|
|
endif()
|
2017-07-31 19:04:18 +02:00
|
|
|
|
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})
|
|
|
|
|
2017-07-31 19:04:18 +02:00
|
|
|
if(EXISTS ${LIBDIR})
|
2019-10-09 17:14:00 +02:00
|
|
|
message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
|
|
|
|
|
2017-07-31 19:04:18 +02:00
|
|
|
file(GLOB LIB_SUBDIRS ${LIBDIR}/*)
|
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)
|
2018-08-29 15:05:03 +02:00
|
|
|
# NOTE: Make sure "proper" compiled zlib comes first before the one
|
|
|
|
# which is a part of OpenCollada. They have different ABI, and we
|
|
|
|
# do need to use the official one.
|
|
|
|
set(CMAKE_PREFIX_PATH ${LIBDIR}/zlib ${LIB_SUBDIRS})
|
2017-07-31 19:04:18 +02:00
|
|
|
set(WITH_STATIC_LIBS ON)
|
2020-09-10 14:54:21 +02:00
|
|
|
# OpenMP usually can't be statically linked into shared libraries,
|
|
|
|
# due to not being compiled with position independent code.
|
|
|
|
if(NOT WITH_PYTHON_MODULE)
|
|
|
|
set(WITH_OPENMP_STATIC ON)
|
|
|
|
endif()
|
2020-01-22 22:38:26 -07:00
|
|
|
set(Boost_NO_BOOST_CMAKE ON)
|
|
|
|
set(BOOST_ROOT ${LIBDIR}/boost)
|
|
|
|
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)
|
2017-07-31 19:04:18 +02:00
|
|
|
endif()
|
|
|
|
|
2019-03-02 02:53:09 +01:00
|
|
|
if(WITH_STATIC_LIBS)
|
2020-11-06 10:29:04 +11:00
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -static-libstdc++")
|
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.
|
|
|
|
|
|
|
|
if(EXISTS ${LIBDIR})
|
|
|
|
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-01-24 15:25:05 +01:00
|
|
|
|
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)
|
|
|
|
if(EXISTS ${LIBDIR})
|
|
|
|
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}
|
|
|
|
# )
|
2022-01-26 15:30:21 +11:00
|
|
|
endif()
|
2022-01-25 16:18:53 +01:00
|
|
|
endif()
|
2016-08-09 15:19:11 +02:00
|
|
|
|
|
|
|
if(WITH_PYTHON)
|
|
|
|
# No way to set py35, remove for now.
|
|
|
|
# find_package(PythonLibs)
|
|
|
|
|
|
|
|
# Use our own instead, since without py is such a rare case,
|
|
|
|
# require this package
|
|
|
|
# XXX Linking errors with debian static python :/
|
|
|
|
# find_package_wrapper(PythonLibsUnix REQUIRED)
|
|
|
|
find_package(PythonLibsUnix REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_IMAGE_OPENEXR)
|
|
|
|
find_package_wrapper(OpenEXR) # our own module
|
|
|
|
if(NOT OPENEXR_FOUND)
|
|
|
|
set(WITH_IMAGE_OPENEXR OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_IMAGE_OPENJPEG)
|
|
|
|
find_package_wrapper(OpenJPEG)
|
|
|
|
if(NOT OPENJPEG_FOUND)
|
|
|
|
set(WITH_IMAGE_OPENJPEG OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_IMAGE_TIFF)
|
|
|
|
# XXX Linking errors with debian static tiff :/
|
|
|
|
# find_package_wrapper(TIFF)
|
|
|
|
find_package(TIFF)
|
|
|
|
if(NOT TIFF_FOUND)
|
|
|
|
set(WITH_IMAGE_TIFF OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_OPENAL)
|
|
|
|
find_package_wrapper(OpenAL)
|
|
|
|
if(NOT OPENAL_FOUND)
|
|
|
|
set(WITH_OPENAL OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_SDL)
|
|
|
|
if(WITH_SDL_DYNLOAD)
|
|
|
|
set(SDL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern/sdlew/include/SDL2")
|
|
|
|
set(SDL_LIBRARY)
|
|
|
|
else()
|
|
|
|
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}")
|
|
|
|
else()
|
|
|
|
find_package_wrapper(SDL)
|
|
|
|
endif()
|
|
|
|
mark_as_advanced(
|
|
|
|
SDL_INCLUDE_DIR
|
|
|
|
SDL_LIBRARY
|
|
|
|
)
|
|
|
|
# unset(SDLMAIN_LIBRARY CACHE)
|
|
|
|
if(NOT SDL_FOUND)
|
|
|
|
set(WITH_SDL OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Codecs
|
|
|
|
if(WITH_CODEC_SNDFILE)
|
|
|
|
find_package_wrapper(SndFile)
|
2019-07-19 09:14:15 +10:00
|
|
|
if(NOT SNDFILE_FOUND)
|
2016-08-09 15:19:11 +02:00
|
|
|
set(WITH_CODEC_SNDFILE OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_CODEC_FFMPEG)
|
2017-07-31 19:04:18 +02:00
|
|
|
if(EXISTS ${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
|
|
|
|
x264
|
|
|
|
xvidcore)
|
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-01-12 18:21:43 +01:00
|
|
|
if(NOT FFMPEG_FOUND)
|
|
|
|
set(WITH_CODEC_FFMPEG OFF)
|
|
|
|
message(STATUS "FFmpeg not found, disabling it")
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_FFTW3)
|
|
|
|
find_package_wrapper(Fftw3)
|
|
|
|
if(NOT FFTW3_FOUND)
|
|
|
|
set(WITH_FFTW3 OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_OPENCOLLADA)
|
|
|
|
find_package_wrapper(OpenCOLLADA)
|
|
|
|
if(OPENCOLLADA_FOUND)
|
2020-03-27 14:24:52 +01:00
|
|
|
if(WITH_STATIC_LIBS)
|
2020-04-02 22:05:03 +02:00
|
|
|
# PCRE is bundled with OpenCollada without headers, so can't use
|
|
|
|
# find_package reliably to detect it.
|
|
|
|
set(PCRE_LIBRARIES ${LIBDIR}/opencollada/lib/libpcre.a)
|
2020-03-27 14:24:52 +01:00
|
|
|
else()
|
|
|
|
find_package_wrapper(PCRE)
|
|
|
|
endif()
|
2020-04-02 18:52:22 +02:00
|
|
|
find_package_wrapper(XML2)
|
2016-08-09 15:19:11 +02:00
|
|
|
else()
|
|
|
|
set(WITH_OPENCOLLADA OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_MEM_JEMALLOC)
|
|
|
|
find_package_wrapper(JeMalloc)
|
|
|
|
if(NOT JEMALLOC_FOUND)
|
|
|
|
set(WITH_MEM_JEMALLOC OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_INPUT_NDOF)
|
|
|
|
find_package_wrapper(Spacenav)
|
|
|
|
if(SPACENAV_FOUND)
|
|
|
|
# use generic names within blenders buildsystem.
|
|
|
|
set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS})
|
|
|
|
set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES})
|
|
|
|
else()
|
|
|
|
set(WITH_INPUT_NDOF OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-12-07 18:31:36 +01:00
|
|
|
if(WITH_CYCLES AND WITH_CYCLES_OSL)
|
2016-08-09 15:19:11 +02:00
|
|
|
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
|
2020-08-07 16:53:06 +02:00
|
|
|
if(EXISTS ${CYCLES_OSL} AND NOT OSL_ROOT)
|
2016-08-09 15:19:11 +02:00
|
|
|
set(OSL_ROOT ${CYCLES_OSL})
|
|
|
|
endif()
|
2020-08-07 16:53:06 +02:00
|
|
|
find_package_wrapper(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()
|
|
|
|
else()
|
|
|
|
message(STATUS "OSL not found, disabling it from Cycles")
|
|
|
|
set(WITH_CYCLES_OSL OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_OPENVDB)
|
|
|
|
find_package_wrapper(OpenVDB)
|
2018-04-24 13:26:54 +02:00
|
|
|
find_package_wrapper(Blosc)
|
2020-10-02 17:40:28 +02:00
|
|
|
|
2019-10-09 16:44:29 +02:00
|
|
|
if(NOT OPENVDB_FOUND)
|
2016-08-09 15:19:11 +02:00
|
|
|
set(WITH_OPENVDB OFF)
|
|
|
|
set(WITH_OPENVDB_BLOSC OFF)
|
|
|
|
message(STATUS "OpenVDB not found, disabling it")
|
2018-04-24 13:26:54 +02:00
|
|
|
elseif(NOT BLOSC_FOUND)
|
|
|
|
set(WITH_OPENVDB_BLOSC OFF)
|
2019-01-15 11:13:31 +11:00
|
|
|
message(STATUS "Blosc not found, disabling it for OpenVBD")
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-10-02 17:40:28 +02:00
|
|
|
if(WITH_NANOVDB)
|
|
|
|
find_package_wrapper(NanoVDB)
|
|
|
|
|
|
|
|
if(NOT NANOVDB_FOUND)
|
|
|
|
set(WITH_NANOVDB OFF)
|
|
|
|
message(STATUS "NanoVDB not found, disabling it")
|
|
|
|
endif()
|
|
|
|
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)
|
|
|
|
|
2020-06-15 11:55:40 +02:00
|
|
|
if(NOT ALEMBIC_FOUND)
|
2016-08-09 15:19:11 +02:00
|
|
|
set(WITH_ALEMBIC OFF)
|
|
|
|
endif()
|
|
|
|
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)
|
|
|
|
|
|
|
|
if(NOT USD_FOUND)
|
|
|
|
set(WITH_USD OFF)
|
|
|
|
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)
|
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
|
|
|
endif()
|
|
|
|
set(Boost_USE_MULTITHREADED ON)
|
2016-09-05 13:10:19 +02:00
|
|
|
set(__boost_packages filesystem regex thread date_time)
|
2021-12-07 18:31:36 +01:00
|
|
|
if(WITH_CYCLES AND WITH_CYCLES_OSL)
|
2016-08-09 15:19:11 +02:00
|
|
|
if(NOT (${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6"))
|
|
|
|
list(APPEND __boost_packages wave)
|
|
|
|
else()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(WITH_INTERNATIONAL)
|
|
|
|
list(APPEND __boost_packages locale)
|
|
|
|
endif()
|
|
|
|
if(WITH_OPENVDB)
|
|
|
|
list(APPEND __boost_packages iostreams)
|
|
|
|
endif()
|
2016-09-05 13:10:19 +02:00
|
|
|
list(APPEND __boost_packages system)
|
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)
|
|
|
|
if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU)
|
|
|
|
find_package(IcuLinux)
|
|
|
|
endif()
|
2018-09-19 17:48:11 +02:00
|
|
|
mark_as_advanced(Boost_DIR) # why doesn't boost do this?
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
2019-04-17 06:35:54 +02:00
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
|
|
|
|
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
|
|
|
|
set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
|
|
|
|
set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
|
CMake: Refactor external dependencies handling
This is a more correct fix to the issue Brecht was fixing in D6600.
While the fix in that patch worked fine for linking it broke ASAN
runtime under some circumstances.
For example, `make full debug developer` would compile, but trying
to start blender will cause assert failure in ASAN (related on check
that ASAN is not running already).
Top-level idea: leave it to CMake to keep track of dependency graph.
The root of the issue comes to the fact that target like "blender" is
configured to use a lot of static libraries coming from Blender sources
and to use external static libraries. There is nothing which ensures
order between blender's and external libraries. Only order of blender
libraries is guaranteed.
It was possible that due to a cycle or other circumstances some of
blender libraries would have been passed to linker after libraries
it uses, causing linker errors.
For example, this order will likely fail:
libbf_blenfont.a libfreetype6.a libbf_blenfont.a
This change makes it so blender libraries are explicitly provided
their dependencies to an external libraries, which allows CMake to
ensure they are always linked against them.
General rule here: if bf_foo depends on an external library it is
to be provided to LIBS for bf_foo.
For example, if bf_blenkernel depends on opensubdiv then LIBS in
blenkernel's CMakeLists.txt is to include OPENSUBDIB_LIBRARIES.
The change is made based on searching for used include folders
such as OPENSUBDIV_INCLUDE_DIRS and adding corresponding libraries
to LIBS ion that CMakeLists.txt. Transitive dependencies are not
simplified by this approach, but I am not aware of any downside of
this: CMake should be smart enough to simplify them on its side.
And even if not, this shouldn't affect linking time.
Benefit of not relying on transitive dependencies is that build
system is more robust towards future changes. For example, if
bf_intern_opensubiv is no longer depends on OPENSUBDIV_LIBRARIES
and all such code is moved to bf_blenkernel this will not break
linking.
The not-so-trivial part is change to blender_add_lib (and its
version in Cycles). The complexity is caused by libraries being
provided as a single list argument which doesn't allow to use
different release and debug libraries on Windows. The idea is:
- Have every library prefixed as "optimized" or "debug" if
separation is needed (non-prefixed libraries will be considered
"generic").
- Loop through libraries passed to function and do simple parsing
which will look for "optimized" and "debug" words and specify
following library to corresponding category.
This isn't something particularly great. Alternative would be to
use target_link_libraries() directly, which sounds like more code
but which is more explicit and allows to have more flexibility
and control comparing to wrapper approach.
Tested the following configurations on Linux, macOS and Windows:
- make full debug developer
- make full release developer
- make lite debug developer
- make lite release developer
NOTE: Linux libraries needs to be compiled with D6641 applied,
otherwise, depending on configuration, it's possible to run into
duplicated zlib symbols error.
Differential Revision: https://developer.blender.org/D6642
2020-01-20 18:36:19 +01:00
|
|
|
|
|
|
|
if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU)
|
|
|
|
find_package(IcuLinux)
|
|
|
|
list(APPEND BOOST_LIBRARIES ${ICU_LIBRARIES})
|
|
|
|
endif()
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
|
2020-12-01 16:24:19 +01:00
|
|
|
if(WITH_PUGIXML)
|
|
|
|
find_package_wrapper(PugiXML)
|
2021-01-26 15:27:57 +01:00
|
|
|
|
2021-02-05 09:45:16 +11:00
|
|
|
if(NOT PUGIXML_FOUND)
|
2021-01-26 15:27:57 +01:00
|
|
|
set(WITH_PUGIXML OFF)
|
|
|
|
message(STATUS "PugiXML not found, disabling WITH_PUGIXML")
|
|
|
|
endif()
|
2020-12-01 16:24:19 +01:00
|
|
|
endif()
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(WITH_OPENIMAGEIO)
|
|
|
|
find_package_wrapper(OpenImageIO)
|
|
|
|
set(OPENIMAGEIO_LIBRARIES
|
|
|
|
${OPENIMAGEIO_LIBRARIES}
|
|
|
|
${PNG_LIBRARIES}
|
|
|
|
${JPEG_LIBRARIES}
|
|
|
|
${ZLIB_LIBRARIES}
|
|
|
|
${BOOST_LIBRARIES}
|
|
|
|
)
|
|
|
|
set(OPENIMAGEIO_LIBPATH) # TODO, remove and reference the absolute path everywhere
|
|
|
|
set(OPENIMAGEIO_DEFINITIONS "")
|
2019-04-17 06:35:54 +02:00
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(WITH_IMAGE_TIFF)
|
|
|
|
list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}")
|
|
|
|
endif()
|
|
|
|
if(WITH_IMAGE_OPENEXR)
|
|
|
|
list(APPEND OPENIMAGEIO_LIBRARIES "${OPENEXR_LIBRARIES}")
|
|
|
|
endif()
|
2019-04-17 06:35:54 +02:00
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(NOT OPENIMAGEIO_FOUND)
|
|
|
|
set(WITH_OPENIMAGEIO OFF)
|
|
|
|
message(STATUS "OpenImageIO not found, disabling WITH_CYCLES")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES})
|
|
|
|
set(OPENCOLORIO_LIBPATH) # TODO, remove and reference the absolute path everywhere
|
|
|
|
set(OPENCOLORIO_DEFINITIONS)
|
|
|
|
|
|
|
|
if(NOT OPENCOLORIO_FOUND)
|
|
|
|
set(WITH_OPENCOLORIO OFF)
|
|
|
|
message(STATUS "OpenColorIO not found")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-12-07 18:31:36 +01:00
|
|
|
if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
|
2020-02-17 23:44:12 +01:00
|
|
|
find_package(Embree 3.8.0 REQUIRED)
|
2018-11-07 12:58:12 +01:00
|
|
|
endif()
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
if(NOT OPENIMAGEDENOISE_FOUND)
|
|
|
|
set(WITH_OPENIMAGEDENOISE OFF)
|
|
|
|
message(STATUS "OpenImageDenoise not found")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(WITH_LLVM)
|
2017-07-31 19:04:18 +02:00
|
|
|
if(EXISTS ${LIBDIR})
|
|
|
|
set(LLVM_STATIC ON)
|
|
|
|
endif()
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
find_package_wrapper(LLVM)
|
2021-02-24 07:13:37 -07:00
|
|
|
if(WITH_CLANG)
|
|
|
|
find_package_wrapper(Clang)
|
|
|
|
endif()
|
2018-08-17 12:40:31 +02:00
|
|
|
# Symbol conflicts with same UTF library used by OpenCollada
|
|
|
|
if(EXISTS ${LIBDIR})
|
|
|
|
if(WITH_OPENCOLLADA AND (${LLVM_VERSION} VERSION_LESS "4.0.0"))
|
|
|
|
list(REMOVE_ITEM OPENCOLLADA_LIBRARIES ${OPENCOLLADA_UTF_LIBRARY})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
if(NOT LLVM_FOUND)
|
|
|
|
set(WITH_LLVM OFF)
|
2021-02-24 07:13:37 -07:00
|
|
|
set(WITH_CLANG OFF)
|
2016-08-09 15:19:11 +02:00
|
|
|
message(STATUS "LLVM not found")
|
2021-02-24 07:13:37 -07:00
|
|
|
else()
|
|
|
|
if(NOT CLANG_FOUND)
|
|
|
|
set(WITH_CLANG OFF)
|
|
|
|
message(STATUS "Clang not found")
|
|
|
|
endif()
|
2016-08-09 15:19:11 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-11-26 11:41:38 +01:00
|
|
|
if(WITH_OPENSUBDIV)
|
2016-08-09 15:19:11 +02:00
|
|
|
find_package_wrapper(OpenSubdiv)
|
|
|
|
|
|
|
|
set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARIES})
|
|
|
|
set(OPENSUBDIV_LIBPATH) # TODO, remove and reference the absolute path everywhere
|
|
|
|
|
|
|
|
if(NOT OPENSUBDIV_FOUND)
|
|
|
|
set(WITH_OPENSUBDIV OFF)
|
|
|
|
message(STATUS "OpenSubdiv not found")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-10-09 16:44:29 +02:00
|
|
|
if(WITH_TBB)
|
|
|
|
find_package_wrapper(TBB)
|
2021-06-16 00:02:39 +10:00
|
|
|
if(NOT TBB_FOUND)
|
|
|
|
message(WARNING "TBB not found, disabling WITH_TBB")
|
|
|
|
set(WITH_TBB OFF)
|
|
|
|
endif()
|
2019-10-09 16:44:29 +02:00
|
|
|
endif()
|
|
|
|
|
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)
|
2020-03-04 16:39:00 +01:00
|
|
|
if(NOT XR_OPENXR_SDK_FOUND)
|
|
|
|
message(WARNING "OpenXR-SDK not found, disabling WITH_XR_OPENXR")
|
|
|
|
set(WITH_XR_OPENXR OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-07-31 09:34:26 -06:00
|
|
|
if(WITH_GMP)
|
|
|
|
find_package_wrapper(GMP)
|
|
|
|
if(NOT GMP_FOUND)
|
|
|
|
message(WARNING "GMP not found, disabling WITH_GMP")
|
|
|
|
set(WITH_GMP OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-09-15 13:16:37 -06:00
|
|
|
if(WITH_POTRACE)
|
|
|
|
find_package_wrapper(Potrace)
|
|
|
|
if(NOT POTRACE_FOUND)
|
|
|
|
message(WARNING "potrace not found, disabling WITH_POTRACE")
|
|
|
|
set(WITH_POTRACE OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-02-09 14:36:11 +01:00
|
|
|
if(WITH_HARU)
|
|
|
|
find_package_wrapper(Haru)
|
|
|
|
if(NOT HARU_FOUND)
|
|
|
|
message(WARNING "Haru not found, disabling WITH_HARU")
|
|
|
|
set(WITH_HARU OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-02-20 22:09:14 -07:00
|
|
|
if(EXISTS ${LIBDIR})
|
|
|
|
without_system_libs_end()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# 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)
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
# used by other platforms
|
|
|
|
set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
|
|
|
if(CMAKE_DL_LIBS)
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
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.
|
|
|
|
|
2022-01-26 15:20:32 +11:00
|
|
|
if(EXISTS ${LIBDIR})
|
|
|
|
# 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()
|
|
|
|
endif()
|
2022-01-26 15:20:32 +11:00
|
|
|
|
2020-02-20 22:09:14 -07:00
|
|
|
if(WITH_LZO AND WITH_SYSTEM_LZO)
|
|
|
|
find_package_wrapper(LZO)
|
|
|
|
if(NOT LZO_FOUND)
|
|
|
|
message(FATAL_ERROR "Failed finding system LZO version!")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
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)
|
|
|
|
if(NOT JACK_FOUND)
|
|
|
|
set(WITH_JACK OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-03-02 17:29:18 +01:00
|
|
|
# Pulse is intended to use the system library.
|
|
|
|
if(WITH_PULSEAUDIO)
|
|
|
|
find_package_wrapper(Pulse)
|
|
|
|
if(NOT PULSE_FOUND)
|
|
|
|
set(WITH_PULSEAUDIO OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-02-20 22:09:14 -07:00
|
|
|
# Audio IO
|
|
|
|
if(WITH_SYSTEM_AUDASPACE)
|
|
|
|
find_package_wrapper(Audaspace)
|
|
|
|
if(NOT AUDASPACE_FOUND OR NOT AUDASPACE_C_FOUND)
|
|
|
|
message(FATAL_ERROR "Audaspace external library not found!")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-04-30 13:46:42 +10:00
|
|
|
if(WITH_GHOST_WAYLAND)
|
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(wayland-client REQUIRED wayland-client>=1.12)
|
|
|
|
pkg_check_modules(wayland-egl REQUIRED wayland-egl)
|
|
|
|
pkg_check_modules(wayland-scanner REQUIRED wayland-scanner)
|
|
|
|
pkg_check_modules(xkbcommon REQUIRED xkbcommon)
|
|
|
|
pkg_check_modules(wayland-cursor REQUIRED wayland-cursor)
|
2021-05-26 20:57:32 +01:00
|
|
|
pkg_check_modules(dbus REQUIRED dbus-1)
|
2020-04-30 13:46:42 +10:00
|
|
|
|
2021-08-02 17:15:53 +02:00
|
|
|
set(WITH_GL_EGL ON)
|
|
|
|
|
2020-05-20 22:42:43 +01:00
|
|
|
list(APPEND PLATFORM_LINKLIBS
|
|
|
|
${wayland-client_LINK_LIBRARIES}
|
|
|
|
${wayland-egl_LINK_LIBRARIES}
|
|
|
|
${xkbcommon_LINK_LIBRARIES}
|
|
|
|
${wayland-cursor_LINK_LIBRARIES}
|
2021-05-26 20:57:32 +01:00
|
|
|
${dbus_LINK_LIBRARIES}
|
2020-05-20 22:42:43 +01:00
|
|
|
)
|
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)
|
|
|
|
|
|
|
|
find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
|
|
|
|
mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
|
|
|
|
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${X11_X11_LIB})
|
|
|
|
|
|
|
|
if(WITH_X11_XINPUT)
|
|
|
|
if(X11_Xinput_LIB)
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "LibXi not found. Disable WITH_X11_XINPUT if you
|
|
|
|
want to build without tablet support")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_X11_XF86VMODE)
|
|
|
|
# XXX, why doesn't cmake make this available?
|
|
|
|
find_library(X11_Xxf86vmode_LIB Xxf86vm ${X11_LIB_SEARCH_PATH})
|
|
|
|
mark_as_advanced(X11_Xxf86vmode_LIB)
|
|
|
|
if(X11_Xxf86vmode_LIB)
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${X11_Xxf86vmode_LIB})
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "libXxf86vm not found. Disable WITH_X11_XF86VMODE if you
|
|
|
|
want to build without")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_X11_XFIXES)
|
|
|
|
if(X11_Xfixes_LIB)
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${X11_Xfixes_LIB})
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "libXfixes not found. Disable WITH_X11_XFIXES if you
|
|
|
|
want to build without")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_X11_ALPHA)
|
|
|
|
find_library(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH})
|
|
|
|
mark_as_advanced(X11_Xrender_LIB)
|
|
|
|
if(X11_Xrender_LIB)
|
|
|
|
list(APPEND PLATFORM_LINKLIBS ${X11_Xrender_LIB})
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "libXrender not found. Disable WITH_X11_ALPHA if you
|
|
|
|
want to build without")
|
|
|
|
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
|
|
|
|
# this until we support it. Seems to default to off in clang and the intel
|
|
|
|
# compiler.
|
|
|
|
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-12 13:35:07 +11:00
|
|
|
# NOTE(@campbellbarton): Eventually mold will be able to use `-fuse-ld=mold`,
|
|
|
|
# however at the moment this only works for GCC 12.1+ (unreleased at time of writing).
|
|
|
|
# So a workaround is used here "-B" which points to another path to find system commands
|
|
|
|
# such as `ld`.
|
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()
|
|
|
|
# By default mold installs the binary to:
|
|
|
|
# - `{PREFIX}/bin/mold` as well as a symbolic-link in...
|
|
|
|
# - `{PREFIX}/lib/mold/ld`.
|
|
|
|
# (where `PREFIX` is typically `/usr/`).
|
|
|
|
#
|
|
|
|
# This block of code finds `{PREFIX}/lib/mold` from the `mold` binary.
|
|
|
|
# Other methods of searching for the path could also be made to work,
|
|
|
|
# we could even make our own directory and symbolic-link, however it's more
|
|
|
|
# convenient to use the one provided by mold.
|
|
|
|
#
|
|
|
|
# Use the binary path to "mold", to find the common prefix which contains "lib/mold".
|
|
|
|
# The parent directory: e.g. `/usr/bin/mold` -> `/usr/bin/`.
|
|
|
|
get_filename_component(MOLD_PREFIX "${MOLD_BIN}" DIRECTORY)
|
|
|
|
# The common prefix path: e.g. `/usr/bin/` -> `/usr/` to use as a hint.
|
|
|
|
get_filename_component(MOLD_PREFIX "${MOLD_PREFIX}" DIRECTORY)
|
|
|
|
# Find `{PREFIX}/lib/mold/ld`, store the directory component (without the `ld`).
|
|
|
|
# Then pass `-B {PREFIX}/lib/mold` to GCC so the `ld` located there overrides the default.
|
|
|
|
find_path(
|
|
|
|
MOLD_BIN_DIR "ld"
|
|
|
|
HINTS "${MOLD_PREFIX}"
|
2022-01-17 18:07:12 +11:00
|
|
|
# The default path is `libexec`, Arch Linux for e.g.
|
|
|
|
# replaces this with `lib` so check both.
|
|
|
|
PATH_SUFFIXES "libexec/mold" "lib/mold" "lib64/mold"
|
2022-01-12 13:35:07 +11:00
|
|
|
NO_DEFAULT_PATH
|
|
|
|
NO_CACHE
|
|
|
|
)
|
|
|
|
if(NOT MOLD_BIN_DIR)
|
|
|
|
message(STATUS
|
|
|
|
"The mold linker could not find the directory containing the linker command "
|
2022-01-17 18:07:12 +11:00
|
|
|
"(typically "
|
|
|
|
"\"${MOLD_PREFIX}/libexec/mold/ld\") or "
|
|
|
|
"\"${MOLD_PREFIX}/lib/mold/ld\") using system linker.")
|
2022-01-12 13:35:07 +11:00
|
|
|
set(WITH_LINKER_MOLD OFF)
|
|
|
|
endif()
|
|
|
|
unset(MOLD_PREFIX)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_LINKER_MOLD)
|
|
|
|
# GCC will search for `ld` in this directory first.
|
2022-01-15 16:36:08 +11:00
|
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
|
2022-01-15 16:12:13 +11:00
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
|
|
|
|
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -B \"${MOLD_BIN_DIR}\"")
|
2022-01-15 16:36:08 +11:00
|
|
|
set(_IS_LINKER_DEFAULT OFF)
|
2022-01-12 13:35:07 +11:00
|
|
|
endif()
|
|
|
|
unset(MOLD_BIN)
|
|
|
|
unset(MOLD_BIN_DIR)
|
|
|
|
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()
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
# CLang is the same as GCC for now.
|
|
|
|
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
|
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()
|
|
|
|
|
2016-08-09 15:19:11 +02:00
|
|
|
# Intel C++ Compiler
|
|
|
|
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
|
|
|
# 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.
|
|
|
|
set(PLATFORM_LINKFLAGS
|
|
|
|
"${PLATFORM_LINKFLAGS} -Wl,--version-script='${CMAKE_SOURCE_DIR}/source/creator/blender.map'"
|
|
|
|
)
|
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)
|
|
|
|
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)
|
|
|
|
else()
|
|
|
|
message(WARNING "Ccache NOT found, disabling WITH_COMPILER_CCACHE")
|
|
|
|
set(WITH_COMPILER_CCACHE OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|