2008-04-17 00:40:48 +02:00
# ***** BEGIN GPL LICENSE BLOCK *****
2006-11-17 03:27:12 +01:00
#
# 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
2008-04-17 00:40:48 +02:00
# of the License, or (at your option) any later version.
2006-11-17 03:27:12 +01:00
#
# 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,
2010-02-12 14:34:04 +01:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2006-11-17 03:27:12 +01:00
#
# The Original Code is Copyright (C) 2006, Blender Foundation
# All rights reserved.
2019-10-15 15:53:55 +02:00
#
2008-04-17 00:40:48 +02:00
# ***** END GPL LICENSE BLOCK *****
2006-11-17 03:27:12 +01:00
2006-12-13 03:57:57 +01:00
#-----------------------------------------------------------------------------
2011-09-30 17:51:58 +02:00
# We don't allow in-source builds. This causes no end of troubles because
# all out-of-source builds will use the CMakeCache.txt file there and even
2011-02-19 13:05:20 +01:00
# build the libs and objects in it.
2006-12-13 03:57:57 +01:00
2010-12-08 09:43:06 +01:00
if ( ${ CMAKE_SOURCE_DIR } STREQUAL ${ CMAKE_BINARY_DIR } )
2019-04-17 06:35:54 +02:00
if ( NOT DEFINED WITH_IN_SOURCE_BUILD )
message ( FATAL_ERROR
" C M a k e g e n e r a t i o n f o r b l e n d e r i s n o t a l l o w e d w i t h i n t h e s o u r c e d i r e c t o r y ! "
" \ n R e m o v e \ " $ { C M A K E _ S O U R C E _ D I R } / C M a k e C a c h e . t x t \ " a n d t r y a g a i n f r o m a n o t h e r f o l d e r , e . g . : "
" \ n "
" \ n r m C M a k e C a c h e . t x t "
" \ n c d . . "
" \ n m k d i r c m a k e - m a k e "
" \ n c d c m a k e - m a k e "
" \ n c m a k e . . / b l e n d e r "
" \ n "
" \ n A l t e r n a t e l y d e f i n e W I T H _ I N _ S O U R C E _ B U I L D t o f o r c e t h i s option ( not recommended! ) "
)
endif ( )
2010-12-08 09:43:06 +01:00
endif ( )
2006-12-13 03:57:57 +01:00
2020-07-28 14:17:13 +02:00
cmake_minimum_required ( VERSION 3.10 )
2015-11-09 16:52:29 +01:00
2018-12-14 14:48:05 +01:00
# Prever LEGACY OpenGL to eb compatible with all the existing releases and
# platforms which don't hare GLVND yet. Only do it if preference was not set
# externally.
if ( NOT DEFINED OpenGL_GL_PREFERENCE )
2019-04-17 06:35:54 +02:00
set ( OpenGL_GL_PREFERENCE "LEGACY" )
2018-12-14 14:48:05 +01:00
endif ( )
2011-06-19 15:49:20 +02:00
if ( NOT EXECUTABLE_OUTPUT_PATH )
2019-04-17 06:35:54 +02:00
set ( FIRST_RUN TRUE )
2015-06-17 01:16:17 +02:00
else ( )
2019-04-17 06:35:54 +02:00
set ( FIRST_RUN FALSE )
2011-06-19 15:49:20 +02:00
endif ( )
2011-04-06 01:31:01 +02:00
# this starts out unset
2011-06-17 04:22:38 +02:00
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules" )
2016-08-09 15:19:11 +02:00
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/platform" )
2011-04-06 01:31:01 +02:00
2011-06-27 15:18:08 +02:00
# avoid having empty buildtype
2017-06-27 01:50:35 +02:00
if ( NOT DEFINED CMAKE_BUILD_TYPE_INIT )
2019-04-17 06:35:54 +02:00
set ( CMAKE_BUILD_TYPE_INIT "Release" )
2017-06-27 01:50:35 +02:00
endif ( )
2011-06-27 15:18:08 +02:00
2018-07-30 07:20:34 +02:00
# Omit superfluous "Up-to-date" messages.
if ( NOT DEFINED CMAKE_INSTALL_MESSAGE )
2019-04-17 06:35:54 +02:00
set ( CMAKE_INSTALL_MESSAGE "LAZY" )
2018-07-30 07:20:34 +02:00
endif ( )
2010-06-07 16:28:37 +02:00
# quiet output for Makefiles, 'make -s' helps too
2010-12-08 09:43:06 +01:00
# set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
2010-06-07 16:28:37 +02:00
2011-10-26 02:51:29 +02:00
# global compile definitions since add_definitions() adds for all.
2018-05-18 14:26:02 +02:00
set_property ( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
2019-04-17 06:35:54 +02:00
$ < $ < C O N F I G : D e b u g > : D E B U G ; _ D E B U G >
$ < $ < C O N F I G : R e l e a s e > : N D E B U G >
$ < $ < C O N F I G : M i n S i z e R e l > : N D E B U G >
$ < $ < C O N F I G : R e l W i t h D e b I n f o > : N D E B U G >
2018-05-18 14:26:02 +02:00
)
2011-10-26 02:51:29 +02:00
2011-08-22 14:24:14 +02:00
#-----------------------------------------------------------------------------
# Set policy
2015-11-09 16:52:29 +01:00
# see "cmake --help-policy CMP0003"
# So library linking is more sane
cmake_policy ( SET CMP0003 NEW )
# So BUILDINFO and BLENDERPATH strings are automatically quoted
cmake_policy ( SET CMP0005 NEW )
# So syntax problems are errors
cmake_policy ( SET CMP0010 NEW )
# Input directories must have CMakeLists.txt
cmake_policy ( SET CMP0014 NEW )
2011-08-22 14:24:14 +02:00
2020-01-26 16:35:58 +01:00
# Silence draco warning on macOS, new policy works fine.
2020-02-03 18:44:52 +01:00
if ( POLICY CMP0068 )
cmake_policy ( SET CMP0068 NEW )
endif ( )
2020-01-26 16:35:58 +01:00
2020-08-23 00:24:09 +02:00
# find_package() uses <PackageName>_ROOT variables.
if ( POLICY CMP0074 )
cmake_policy ( SET CMP0074 NEW )
endif ( )
2011-05-23 16:56:14 +02:00
#-----------------------------------------------------------------------------
# Load some macros.
include ( build_files/cmake/macros.cmake )
2011-04-09 13:16:37 +02:00
2011-05-23 16:56:14 +02:00
#-----------------------------------------------------------------------------
# Initialize project.
2006-11-17 03:27:12 +01:00
2011-05-23 16:56:14 +02:00
blender_project_hack_pre ( )
2011-04-09 13:16:37 +02:00
2011-05-23 16:56:14 +02:00
project ( Blender )
2011-04-09 13:16:37 +02:00
2011-05-23 16:56:14 +02:00
blender_project_hack_post ( )
2011-04-09 13:16:37 +02:00
2011-01-21 01:06:30 +01:00
enable_testing ( )
2006-11-17 03:27:12 +01:00
#-----------------------------------------------------------------------------
# Redirect output files
2012-05-19 15:55:54 +02:00
set ( EXECUTABLE_OUTPUT_PATH ${ CMAKE_BINARY_DIR } /bin CACHE INTERNAL "" FORCE )
set ( LIBRARY_OUTPUT_PATH ${ CMAKE_BINARY_DIR } /lib CACHE INTERNAL "" FORCE )
2018-08-17 18:04:55 +02:00
if ( MSVC )
2019-04-17 06:35:54 +02:00
set ( TESTS_OUTPUT_DIR ${ EXECUTABLE_OUTPUT_PATH } /tests/ $< CONFIG > / CACHE INTERNAL "" FORCE )
2018-08-17 22:14:26 +02:00
else ( )
2019-04-17 06:35:54 +02:00
set ( TESTS_OUTPUT_DIR ${ EXECUTABLE_OUTPUT_PATH } /tests/ CACHE INTERNAL "" FORCE )
2018-08-17 18:04:55 +02:00
endif ( )
2006-11-17 03:27:12 +01:00
#-----------------------------------------------------------------------------
# Set default config options
2010-06-06 15:32:58 +02:00
2010-12-08 09:43:06 +01:00
get_blender_version ( )
2010-07-14 22:26:46 +02:00
2014-11-13 23:32:01 +01:00
2014-11-26 13:24:56 +01:00
#-----------------------------------------------------------------------------
# Options
2010-06-06 15:32:58 +02:00
# Blender internal features
2011-07-13 10:15:06 +02:00
option ( WITH_BLENDER "Build blender (disable to build only the blender player)" ON )
mark_as_advanced ( WITH_BLENDER )
2011-03-11 02:24:16 +01:00
option ( WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON )
2011-04-28 08:20:47 +02:00
2011-03-11 02:24:16 +01:00
option ( WITH_PYTHON "Enable Embedded Python API (only disable for development)" ON )
2018-06-10 08:12:13 +02:00
option ( WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON )
2018-09-03 16:49:08 +02:00
mark_as_advanced ( WITH_PYTHON ) # don't want people disabling this unless they really know what they are doing.
2012-09-28 08:45:20 +02:00
mark_as_advanced ( WITH_PYTHON_SECURITY ) # some distributions see this as a security issue, rather than have them patch it, make a build option.
2011-04-28 08:20:47 +02:00
2018-09-03 16:49:08 +02:00
option ( WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some efficiency, only enable for development)." OFF )
2015-03-05 05:23:22 +01:00
mark_as_advanced ( WITH_PYTHON_SAFETY )
2015-03-24 09:09:51 +01:00
option ( WITH_PYTHON_MODULE "Enable building as a python module which runs without a user interface, like running regular blender in background mode (experimental, only enable for development), installs to PYTHON_SITE_PACKAGES (or CMAKE_INSTALL_PREFIX if WITH_INSTALL_PORTABLE is enabled)." OFF )
2013-03-24 13:13:13 +01:00
if ( APPLE )
2019-04-17 06:35:54 +02:00
option ( WITH_PYTHON_FRAMEWORK "Enable building using the Python available in the framework (OSX only)" OFF )
2013-02-22 23:24:38 +01:00
endif ( )
2019-11-25 17:41:25 +01:00
option ( WITH_BUILDINFO "Include extra build details (only disable for development & faster builds)" ON )
2014-08-01 19:07:41 +02:00
if ( ${ CMAKE_VERSION } VERSION_LESS 2.8.8 )
2019-04-17 06:35:54 +02:00
# add_library OBJECT arg unsupported
set ( WITH_BUILDINFO OFF )
2014-08-01 19:07:41 +02:00
endif ( )
2018-09-03 16:49:08 +02:00
set ( BUILDINFO_OVERRIDE_DATE "" CACHE STRING "Use instead of the current date for reproducible builds (empty string disables this option)" )
set ( BUILDINFO_OVERRIDE_TIME "" CACHE STRING "Use instead of the current time for reproducible builds (empty string disables this option)" )
2016-09-06 15:21:23 +02:00
set ( CPACK_OVERRIDE_PACKAGENAME "" CACHE STRING "Use instead of the standard packagename (empty string disables this option)" )
mark_as_advanced ( CPACK_OVERRIDE_PACKAGENAME )
2016-05-10 18:43:58 +02:00
mark_as_advanced ( BUILDINFO_OVERRIDE_DATE )
mark_as_advanced ( BUILDINFO_OVERRIDE_TIME )
2014-08-01 19:07:41 +02:00
2011-03-11 02:24:16 +01:00
option ( WITH_IK_ITASC "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON )
2012-08-18 15:36:29 +02:00
option ( WITH_IK_SOLVER "Enable Legacy IK solver (only disable for development)" ON )
2019-11-25 17:41:25 +01:00
option ( WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ON )
2010-12-08 09:43:06 +01:00
option ( WITH_BULLET "Enable Bullet (Physics Engine)" ON )
2013-01-03 01:23:52 +01:00
option ( WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
mark_as_advanced ( WITH_SYSTEM_BULLET )
2019-11-25 17:41:25 +01:00
option ( WITH_OPENCOLORIO "Enable OpenColorIO color management" ON )
2020-03-04 16:39:00 +01:00
if ( APPLE )
# There's no OpenXR runtime in sight for macOS, neither is code well
# tested there -> disable it by default.
option ( WITH_XR_OPENXR "Enable VR features through the OpenXR specification" OFF )
mark_as_advanced ( WITH_XR_OPENXR )
else ( )
VR: Initial Virtual Reality support - Milestone 1, Scene Inspection
NOTE: While most of the milestone 1 goals are there, a few smaller features and
improvements are still to be done.
Big picture of this milestone: Initial, OpenXR-based virtual reality support
for users and foundation for advanced use cases.
Maniphest Task: https://developer.blender.org/T71347
The tasks contains more information about this milestone.
To be clear: This is not a feature rich VR implementation, it's focused on the
initial scene inspection use case. We intentionally focused on that, further
features like controller support are part of the next milestone.
- How to use?
Instructions on how to use this are here:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/How_to_Test
These will be updated and moved to a more official place (likely the manual) soon.
Currently Windows Mixed Reality and Oculus devices are usable. Valve/HTC
headsets don't support the OpenXR standard yet and hence, do not work with this
implementation.
---------------
This is the C-side implementation of the features added for initial VR
support as per milestone 1. A "VR Scene Inspection" Add-on will be
committed separately, to expose the VR functionality in the UI. It also
adds some further features for milestone 1, namely a landmarking system
(stored view locations in the VR space)
Main additions/features:
* Support for rendering viewports to an HMD, with good performance.
* Option to sync the VR view perspective with a fully interactive,
regular 3D View (VR-Mirror).
* Option to disable positional tracking. Keeps the current position (calculated
based on the VR eye center pose) when enabled while a VR session is running.
* Some regular viewport settings for the VR view
* RNA/Python-API to query and set VR session state information.
* WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data
* wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU
context)
* DNA/RNA for management of VR session settings
* `--debug-xr` and `--debug-xr-time` commandline options
* Utility batch & config file for using the Oculus runtime on Windows.
* Most VR data is runtime only. The exception is user settings which are saved
to files (`XrSessionSettings`).
* VR support can be disabled through the `WITH_XR_OPENXR` compiler flag.
For architecture and code documentation, see
https://wiki.blender.org/wiki/Source/Interface/XR.
---------------
A few thank you's:
* A huge shoutout to Ray Molenkamp for his help during the project - it would
have not been that successful without him!
* Sebastian Koenig and Simeon Conzendorf for testing and feedback!
* The reviewers, especially Brecht Van Lommel!
* Dalai Felinto for pushing and managing me to get this done ;)
* The OpenXR working group for providing an open standard. I think we're the
first bigger application to adopt OpenXR. Congratulations to them and
ourselves :)
This project started as a Google Summer of Code 2019 project - "Core Support of
Virtual Reality Headsets through OpenXR" (see
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).
Some further information, including ideas for further improvements can be found
in the final GSoC report:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/Final_Report
Differential Revisions: D6193, D7098
Reviewed by: Brecht Van Lommel, Jeroen Bakker
2020-03-17 20:20:55 +01:00
option ( WITH_XR_OPENXR "Enable VR features through the OpenXR specification" ON )
2020-03-04 16:39:00 +01:00
endif ( )
2015-07-18 10:35:03 +02:00
# Compositor
option ( WITH_COMPOSITOR "Enable the tile based nodal compositor" ON )
2019-11-25 17:41:25 +01:00
option ( WITH_OPENIMAGEDENOISE "Enable the OpenImageDenoise compositing node" ON )
2011-06-04 16:12:55 +02:00
2019-11-25 17:41:25 +01:00
option ( WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" ON )
2015-07-20 16:08:06 +02:00
2019-11-25 17:41:25 +01:00
option ( WITH_OPENVDB "Enable features relying on OpenVDB" ON )
option ( WITH_OPENVDB_BLOSC "Enable blosc compression for OpenVDB, only enable if OpenVDB was built with blosc support" ON )
2018-04-02 18:55:10 +02:00
option ( WITH_OPENVDB_3_ABI_COMPATIBLE "Assume OpenVDB library has been compiled with version 3 ABI compatibility" OFF )
mark_as_advanced ( WITH_OPENVDB_3_ABI_COMPATIBLE )
Implementation of OpenVDB as a possible cache format for smoke
simulations.
This commits implements OpenVDB as an extra cache format in the Point
Cache system for smoke simulations. Compilation with the library is
turned off by default for now, and shall be enabled when the library is
present.
A documentation of its doings is available here: http://
wiki.blender.org/index.php/User:Kevindietrich/OpenVDBSmokeExport.
A guide to compile OpenVDB can be found here (Linux): http://
wiki.blender.org/index.php?title=Dev:Doc/Building_Blender/Linux/
Dependencies_From_Source#OpenVDB
Reviewers: sergey, lukastoenne, brecht, campbellbarton
Reviewed By: brecht, campbellbarton
Subscribers: galenb, Blendify, robocyte, Lapineige, bliblubli,
jtheninja, lukasstockner97, dingto, brecht
Differential Revision: https://developer.blender.org/D1721
2016-01-23 08:39:29 +01:00
2011-07-13 08:04:54 +02:00
# GHOST Windowing Library Options
option ( WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF )
mark_as_advanced ( WITH_GHOST_DEBUG )
2011-06-23 11:27:56 +02:00
2016-01-18 10:20:08 +01:00
option ( WITH_GHOST_SDL "Enable building Blender against SDL for windowing rather than the native APIs" OFF )
2011-07-13 08:04:54 +02:00
mark_as_advanced ( WITH_GHOST_SDL )
2011-07-12 15:17:54 +02:00
2020-05-01 12:07:01 +02:00
if ( UNIX AND NOT ( APPLE OR HAIKU ) )
option ( WITH_GHOST_X11 "Enable building Blender against X11 for windowing" ON )
mark_as_advanced ( WITH_GHOST_X11 )
option ( WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing (under development)" OFF )
mark_as_advanced ( WITH_GHOST_WAYLAND )
2020-04-30 05:46:42 +02:00
endif ( )
2020-05-01 11:14:50 +02:00
if ( WITH_GHOST_X11 )
2019-04-17 06:35:54 +02:00
option ( WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON )
2014-11-13 19:43:15 +01:00
endif ( )
2020-07-31 17:34:26 +02:00
option ( WITH_GMP "Use the gmp library for more accurate booleans" OFF )
2011-07-13 08:04:54 +02:00
# Misc...
2011-06-04 16:12:55 +02:00
option ( WITH_HEADLESS "Build without graphical support (renderfarm, server mode only)" OFF )
mark_as_advanced ( WITH_HEADLESS )
2019-08-26 18:34:11 +02:00
option ( WITH_QUADRIFLOW "Build with quadriflow remesher support" ON )
2011-10-23 17:43:12 +02:00
option ( WITH_AUDASPACE "Build with blenders audio library (only disable if you know what you're doing!)" ON )
2015-06-16 10:03:35 +02:00
option ( WITH_SYSTEM_AUDASPACE "Build with external audaspace library installed on the system (only enable if you know what you're doing!)" OFF )
2011-07-13 08:04:54 +02:00
mark_as_advanced ( WITH_AUDASPACE )
2015-06-16 10:03:35 +02:00
mark_as_advanced ( WITH_SYSTEM_AUDASPACE )
if ( NOT WITH_AUDASPACE )
2019-04-17 06:35:54 +02:00
set ( WITH_SYSTEM_AUDASPACE OFF )
2015-06-16 10:03:35 +02:00
endif ( )
2011-07-13 08:04:54 +02:00
2014-04-14 11:38:34 +02:00
option ( WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON )
2015-12-02 14:09:06 +01:00
if ( UNIX AND NOT APPLE )
2019-04-17 06:35:54 +02:00
option ( WITH_OPENMP_STATIC "Link OpenMP statically (only used by the release environment)" OFF )
mark_as_advanced ( WITH_OPENMP_STATIC )
2015-12-02 14:09:06 +01:00
endif ( )
2010-06-06 15:32:58 +02:00
2020-05-01 11:14:50 +02:00
if ( WITH_GHOST_X11 )
2019-04-17 06:35:54 +02:00
option ( WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON )
option ( WITH_X11_XF86VMODE "Enable X11 video mode switching" ON )
option ( WITH_X11_XFIXES "Enable X11 XWayland cursor warping workaround" ON )
option ( WITH_X11_ALPHA "Enable X11 transparent background" ON )
2014-10-07 22:46:19 +02:00
endif ( )
if ( UNIX AND NOT APPLE )
2019-04-17 06:35:54 +02:00
option ( WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" OFF )
option ( WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system" ON )
2011-04-06 03:51:43 +02:00
else ( )
2019-04-17 06:35:54 +02:00
# not an option for other OS's
set ( WITH_SYSTEM_GLEW OFF )
set ( WITH_SYSTEM_GLES OFF )
2011-03-25 05:56:48 +01:00
endif ( )
2012-06-23 16:23:44 +02:00
2015-03-19 05:41:41 +01:00
if ( UNIX AND NOT APPLE )
2019-04-17 06:35:54 +02:00
option ( WITH_SYSTEM_EIGEN3 "Use the systems Eigen3 library" OFF )
2015-03-19 05:41:41 +01:00
endif ( )
2012-06-23 16:23:44 +02:00
2010-10-23 17:40:13 +02:00
# Modifiers
2019-12-16 15:45:47 +01:00
option ( WITH_MOD_FLUID "Enable Mantaflow Fluid Simulation Framework" ON )
2012-10-29 16:43:54 +01:00
option ( WITH_MOD_REMESH "Enable Remesh Modifier" ON )
2019-11-25 17:41:25 +01:00
option ( WITH_MOD_OCEANSIM "Enable Ocean Modifier" ON )
2010-10-23 17:40:13 +02:00
2010-06-06 15:32:58 +02:00
# Image format support
2014-11-13 23:32:01 +01:00
option ( WITH_OPENIMAGEIO "Enable OpenImageIO Support (http://www.openimageio.org)" ON )
2019-11-25 17:41:25 +01:00
option ( WITH_IMAGE_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON )
2010-12-08 09:43:06 +01:00
option ( WITH_IMAGE_OPENJPEG "Enable OpenJpeg Support (http://www.openjpeg.org)" ON )
2012-04-12 10:36:07 +02:00
option ( WITH_IMAGE_TIFF "Enable LibTIFF Support" ON )
2010-12-08 09:43:06 +01:00
option ( WITH_IMAGE_DDS "Enable DDS Image Support" ON )
option ( WITH_IMAGE_CINEON "Enable CINEON and DPX Image Support" ON )
option ( WITH_IMAGE_HDR "Enable HDR Image Support" ON )
2010-06-06 15:32:58 +02:00
2010-11-30 19:52:39 +01:00
# Audio/Video format support
2012-10-08 04:51:42 +02:00
option ( WITH_CODEC_AVI "Enable Blenders own AVI file support (raw/jpeg)" ON )
2019-11-25 17:41:25 +01:00
option ( WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" ON )
option ( WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" ON )
2013-11-17 09:23:18 +01:00
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
# Alembic support
2019-11-25 17:41:25 +01:00
option ( WITH_ALEMBIC "Enable Alembic Support" ON )
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
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
# Universal Scene Description support
2020-05-19 09:39:03 +02:00
option ( WITH_USD "Enable Universal Scene Description (USD) Support" ON )
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
2010-06-06 15:32:58 +02:00
# 3D format support
2013-11-18 17:12:19 +01:00
# Disable opencollada when we don't have precompiled libs
2019-11-25 17:41:25 +01:00
option ( WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ON )
2009-11-19 12:49:42 +01:00
2010-06-06 15:32:58 +02:00
# Sound output
2019-11-25 17:41:25 +01:00
option ( WITH_SDL "Enable SDL for sound and joystick support" ON )
2010-12-08 09:43:06 +01:00
option ( WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON )
2019-11-25 17:41:25 +01:00
if ( NOT WIN32 )
option ( WITH_JACK "Enable JACK Support (http://www.jackaudio.org)" ON )
if ( UNIX AND NOT APPLE )
option ( WITH_JACK_DYNLOAD "Enable runtime dynamic JACK libraries loading" OFF )
endif ( )
2013-03-27 08:19:54 +01:00
endif ( )
2014-11-17 12:35:36 +01:00
if ( UNIX AND NOT APPLE )
2019-04-17 06:35:54 +02:00
option ( WITH_SDL_DYNLOAD "Enable runtime dynamic SDL libraries loading" OFF )
2014-11-17 12:35:36 +01:00
endif ( )
2010-06-06 15:32:58 +02:00
# Compression
2010-12-08 09:43:06 +01:00
option ( WITH_LZO "Enable fast LZO compression (used for pointcache)" ON )
option ( WITH_LZMA "Enable best LZMA compression, (used for pointcache)" ON )
2015-03-13 12:33:31 +01:00
if ( UNIX AND NOT APPLE )
2019-04-17 06:35:54 +02:00
option ( WITH_SYSTEM_LZO "Use the system LZO library" OFF )
2015-03-13 12:33:31 +01:00
endif ( )
2019-04-11 11:26:23 +02:00
option ( WITH_DRACO "Enable Draco mesh compression Python module (used for glTF)" ON )
2010-06-06 15:32:58 +02:00
2011-11-07 13:55:18 +01:00
# Camera/motion tracking
2015-07-18 10:35:03 +02:00
option ( WITH_LIBMV "Enable Libmv structure from motion library" ON )
2019-11-25 17:41:25 +01:00
option ( WITH_LIBMV_SCHUR_SPECIALIZATIONS "Enable fixed-size schur specializations." ON )
2014-11-13 23:32:01 +01:00
mark_as_advanced ( WITH_LIBMV_SCHUR_SPECIALIZATIONS )
2011-11-07 13:55:18 +01:00
2017-04-21 10:58:01 +02:00
# Logging/unbit test libraries.
option ( WITH_SYSTEM_GFLAGS "Use system-wide Gflags instead of a bundled one" OFF )
2017-04-30 18:52:38 +02:00
option ( WITH_SYSTEM_GLOG "Use system-wide Glog instead of a bundled one" OFF )
2017-04-21 10:58:01 +02:00
mark_as_advanced ( WITH_SYSTEM_GFLAGS )
2017-04-21 14:26:25 +02:00
mark_as_advanced ( WITH_SYSTEM_GLOG )
2017-04-21 10:58:01 +02:00
2012-12-20 08:57:26 +01:00
# Freestyle
option ( WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON )
2010-06-06 15:32:58 +02:00
# Misc
2014-12-07 00:58:17 +01:00
if ( WIN32 )
2019-04-17 06:35:54 +02:00
option ( WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON )
2014-12-07 00:58:17 +01:00
endif ( )
2019-11-25 17:41:25 +01:00
option ( WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ON )
2011-03-06 12:41:30 +01:00
if ( UNIX AND NOT APPLE )
2019-04-17 06:35:54 +02:00
option ( WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON )
option ( WITH_STATIC_LIBS "Try to link with static libraries, as much as possible, to make blender more portable across distributions" OFF )
if ( WITH_STATIC_LIBS )
option ( WITH_BOOST_ICU "Boost uses ICU library (required for linking with static Boost built with libicu)." OFF )
mark_as_advanced ( WITH_BOOST_ICU )
endif ( )
2011-03-06 12:41:30 +01:00
endif ( )
2016-03-15 13:50:44 +01:00
2010-12-08 09:43:06 +01:00
option ( WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON )
2018-09-17 11:10:45 +02:00
if ( WIN32 OR APPLE )
2019-04-17 06:35:54 +02:00
# Windows and macOS have this bundled with Python libraries.
2018-09-17 11:10:45 +02:00
elseif ( WITH_PYTHON_INSTALL OR ( WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE ) )
2019-04-17 06:35:54 +02:00
set ( PYTHON_NUMPY_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module" )
mark_as_advanced ( PYTHON_NUMPY_PATH )
set ( PYTHON_NUMPY_INCLUDE_DIRS ${ PYTHON_NUMPY_PATH } /numpy/core/include CACHE PATH "Path to the include directory of the numpy module" )
mark_as_advanced ( PYTHON_NUMPY_INCLUDE_DIRS )
2017-08-18 08:24:12 +02:00
endif ( )
if ( WITH_PYTHON_INSTALL )
2019-04-17 06:35:54 +02:00
option ( WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON )
2016-03-15 13:50:44 +01:00
2019-04-17 06:35:54 +02:00
if ( UNIX AND NOT APPLE )
option ( WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON )
set ( PYTHON_REQUESTS_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'requests' module" )
mark_as_advanced ( PYTHON_REQUESTS_PATH )
endif ( )
2016-03-15 13:50:44 +01:00
endif ( )
2014-10-15 10:53:12 +02:00
option ( WITH_CPU_SSE "Enable SIMD instruction if they're detected on the host machine" ON )
mark_as_advanced ( WITH_CPU_SSE )
2012-05-02 01:22:58 +02:00
2011-04-28 15:47:27 +02:00
# Cycles
2019-04-17 06:35:54 +02:00
option ( WITH_CYCLES "Enable Cycles Render Engine" ON )
option ( WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF )
option ( WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF )
2019-11-25 17:41:25 +01:00
option ( WITH_CYCLES_OSL "Build Cycles with OSL support" ON )
2020-02-23 09:14:52 +01:00
option ( WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON )
2019-04-17 06:35:54 +02:00
option ( WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF )
option ( WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF )
2018-08-20 10:17:34 +02:00
option ( WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful on machines with limited RAM)" OFF )
mark_as_advanced ( WITH_CYCLES_CUDA_BUILD_SERIAL )
2020-07-17 15:06:55 +02:00
set ( CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 compute_75 CACHE STRING "CUDA architectures to build binaries for" )
2011-11-13 15:16:43 +01:00
mark_as_advanced ( CYCLES_CUDA_BINARIES_ARCH )
2012-05-22 14:30:37 +02:00
unset ( PLATFORM_DEFAULT )
2019-04-17 06:35:54 +02:00
option ( WITH_CYCLES_LOGGING "Build Cycles with logging support" ON )
option ( WITH_CYCLES_DEBUG "Build Cycles with extra debug capabilities" OFF )
option ( WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF )
2019-07-11 19:29:29 +02:00
option ( WITH_CYCLES_KERNEL_ASAN "Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow" OFF )
mark_as_advanced ( WITH_CYCLES_KERNEL_ASAN )
2018-02-03 18:59:09 +01:00
mark_as_advanced ( WITH_CYCLES_CUBIN_COMPILER )
2014-10-04 15:00:26 +02:00
mark_as_advanced ( WITH_CYCLES_LOGGING )
mark_as_advanced ( WITH_CYCLES_DEBUG )
2016-03-25 16:09:05 +01:00
mark_as_advanced ( WITH_CYCLES_NATIVE_ONLY )
2011-04-28 15:47:27 +02:00
2019-04-17 06:35:54 +02:00
option ( WITH_CYCLES_DEVICE_CUDA "Enable Cycles CUDA compute support" ON )
2019-09-12 14:50:06 +02:00
option ( WITH_CYCLES_DEVICE_OPTIX "Enable Cycles OptiX support" OFF )
2019-04-17 06:35:54 +02:00
option ( WITH_CYCLES_DEVICE_OPENCL "Enable Cycles OpenCL compute support" ON )
2020-08-19 10:22:00 +02:00
option ( WITH_CYCLES_NETWORK "Enable Cycles compute over network support (EXPERIMENTAL and unfinished)" OFF )
2018-02-14 10:31:04 +01:00
mark_as_advanced ( WITH_CYCLES_DEVICE_CUDA )
mark_as_advanced ( WITH_CYCLES_DEVICE_OPENCL )
mark_as_advanced ( WITH_CYCLES_NETWORK )
2016-01-14 08:24:09 +01:00
option ( WITH_CUDA_DYNLOAD "Dynamically load CUDA libraries at runtime" ON )
mark_as_advanced ( WITH_CUDA_DYNLOAD )
2012-10-06 13:00:45 +02:00
# LLVM
2019-04-17 06:35:54 +02:00
option ( WITH_LLVM "Use LLVM" OFF )
2014-08-06 12:48:06 +02:00
if ( APPLE )
2019-04-17 06:35:54 +02:00
option ( LLVM_STATIC "Link with LLVM static libraries" ON ) # we prefer static llvm build on Apple, dyn build possible though
2014-08-06 12:48:06 +02:00
else ( )
2019-04-17 06:35:54 +02:00
option ( LLVM_STATIC "Link with LLVM static libraries" OFF )
2014-08-06 12:48:06 +02:00
endif ( )
2013-04-15 18:18:35 +02:00
mark_as_advanced ( LLVM_STATIC )
2012-10-06 13:00:45 +02:00
2011-05-12 13:16:32 +02:00
# disable for now, but plan to support on all platforms eventually
2015-02-14 11:13:48 +01:00
option ( WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" ON )
2011-05-12 13:16:32 +02:00
mark_as_advanced ( WITH_MEM_JEMALLOC )
2013-10-03 14:22:44 +02:00
# currently only used for BLI_mempool
option ( WITH_MEM_VALGRIND "Enable extended valgrind support for better reporting" OFF )
mark_as_advanced ( WITH_MEM_VALGRIND )
2010-12-08 10:02:08 +01:00
# Debug
2011-03-11 02:24:16 +01:00
option ( WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF )
2010-12-08 10:02:08 +01:00
mark_as_advanced ( WITH_CXX_GUARDEDALLOC )
2018-06-28 10:48:06 +02:00
option ( WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON )
2010-12-15 11:22:26 +01:00
mark_as_advanced ( WITH_ASSERT_ABORT )
2020-06-05 11:37:49 +02:00
if ( UNIX AND NOT APPLE )
2020-07-13 10:34:44 +02:00
option ( WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Linux using Clang)" OFF )
2020-06-05 11:37:49 +02:00
mark_as_advanced ( WITH_CLANG_TIDY )
endif ( )
2019-10-09 16:44:29 +02:00
option ( WITH_BOOST "Enable features depending on boost" ON )
option ( WITH_TBB "Enable features depending on TBB (OpenVDB, OpenImageDenoise, sculpt multithreading)" ON )
2019-11-25 17:41:25 +01:00
# TBB malloc is only supported on for windows currently
if ( WIN32 )
option ( WITH_TBB_MALLOC_PROXY "Enable the TBB malloc replacement" ON )
endif ( )
2013-02-01 00:25:06 +01:00
2020-08-17 09:47:10 +02:00
# This should be turned off when Blender enter beta/rc/release
2020-08-19 10:23:21 +02:00
option ( WITH_EXPERIMENTAL_FEATURES "Enable experimental features (still need to enable them in the user preferences)" ON )
2020-08-17 09:47:10 +02:00
mark_as_advanced ( WITH_EXPERIMENTAL_FEATURES )
2014-06-18 14:49:17 +02:00
# Unit testsing
option ( WITH_GTESTS "Enable GTest unit testing" OFF )
2018-02-14 20:33:33 +01:00
option ( WITH_OPENGL_RENDER_TESTS "Enable OpenGL render related unit testing (Experimental)" OFF )
option ( WITH_OPENGL_DRAW_TESTS "Enable OpenGL UI drawing related unit testing (Experimental)" OFF )
Tests: use explicit Python to run unit tests
CentOS on the buildbot still runs Python 3.6, which is also used for the
unit tests. This means that the tests can't use language features that
are available to Blender itself. And testing with a different version of
Python than will be used by the actual code seems like a bad idea to me.
This commit adds `TEST_PYTHON_EXECUTABLE` as advanced CMake option. This
will allow us to set a specific Python executable when we need it. When
not set, a platform-specific default will be used:
- On Windows, the `python….exe` from the installation directory. This is
just like before this patch, except that this patch adds the
overridability.
- On macOS/Linux, the `${PYTHON_EXECUTABLE}` as found by CMake.
Every platform should now have a value (configured by the user or
detected by CMake) for `TEST_PYTHON_EXE`, so there is no need to allow
running without. This also removes the need to have some Python files
marked as executable.
If `TEST_PYTHON_EXE` is not user-configured, and thus the above default
is used, a status message is logged by CMake. I've seen this a lot in
other projects, and I like that it shows which values are auto-detected.
However, it's not common in Blender, so if we want we can either remove
it now, or remove it after the buildbot has been set up correctly.
Differential Revision: https://developer.blender.org/D7395
Reviewed by: campbellbarton, mont29, sergey
2020-04-10 10:35:17 +02:00
set ( TEST_PYTHON_EXE "" CACHE PATH "Python executable to run unit tests" )
mark_as_advanced ( TEST_PYTHON_EXE )
2014-06-18 14:49:17 +02:00
2014-11-13 14:07:34 +01:00
# Documentation
if ( UNIX AND NOT APPLE )
2019-04-17 06:35:54 +02:00
option ( WITH_DOC_MANPAGE "Create a manual page (Unix manpage)" OFF )
2014-11-13 14:07:34 +01:00
endif ( )
2014-10-07 22:46:19 +02:00
# OpenGL
2018-06-16 04:17:16 +02:00
option ( WITH_OPENGL "When off limits visibility of the opengl headers to just bf_gpu and gawain (temporary option for development purposes)" ON )
2014-10-07 22:46:19 +02:00
option ( WITH_GLEW_ES "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF )
option ( WITH_GL_EGL "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)" OFF )
2019-08-01 05:53:25 +02:00
option ( WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (through either EGL or the AGL/WGL/XGL 'es20' profile)" OFF )
2014-10-07 22:46:19 +02:00
mark_as_advanced (
2019-04-17 06:35:54 +02:00
W I T H _ O P E N G L
W I T H _ G L E W _ E S
W I T H _ G L _ E G L
W I T H _ G L _ P R O F I L E _ E S 2 0
2014-10-07 22:46:19 +02:00
)
if ( WIN32 )
2019-04-17 06:35:54 +02:00
option ( WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF )
mark_as_advanced ( WITH_GL_ANGLE )
2014-10-07 22:46:19 +02:00
endif ( )
if ( WITH_GLEW_ES AND WITH_SYSTEM_GLEW )
2019-04-17 06:35:54 +02:00
message ( WARNING Ignoring WITH_SYSTEM_GLEW and using WITH_GLEW_ES )
set ( WITH_SYSTEM_GLEW OFF )
2014-10-07 22:46:19 +02:00
endif ( )
2015-12-27 16:57:31 +01:00
if ( WIN32 )
2019-04-17 06:35:54 +02:00
getDefaultWindowsPrefixBase ( CMAKE_GENERIC_PROGRAM_FILES )
set ( CPACK_INSTALL_PREFIX ${ CMAKE_GENERIC_PROGRAM_FILES } / $ {} )
2014-11-08 11:32:32 +01:00
endif ( )
2016-11-02 10:42:15 +01:00
# Compiler toolchain
if ( CMAKE_COMPILER_IS_GNUCC )
2019-04-17 06:35:54 +02:00
option ( WITH_LINKER_GOLD "Use ld.gold linker which is usually faster than ld.bfd" ON )
mark_as_advanced ( WITH_LINKER_GOLD )
2020-04-27 06:10:56 +02:00
option ( WITH_LINKER_LLD "Use ld.lld linker which is usually faster than ld.gold" OFF )
mark_as_advanced ( WITH_LINKER_LLD )
2016-11-02 10:42:15 +01:00
endif ( )
2018-05-18 15:21:18 +02:00
if ( CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang" )
2019-04-17 06:35:54 +02:00
option ( WITH_COMPILER_ASAN "Build and link against address sanitizer (only for Debug & RelWithDebInfo targets)." OFF )
mark_as_advanced ( WITH_COMPILER_ASAN )
2018-05-18 15:21:18 +02:00
2019-04-17 06:35:54 +02:00
if ( WITH_COMPILER_ASAN )
set ( _asan_defaults " \
2018-05-18 15:21:18 +02:00
- f s a n i t i z e = a d d r e s s \
- f s a n i t i z e = b o o l \
- f s a n i t i z e = b o u n d s \
- f s a n i t i z e = e n u m \
- f s a n i t i z e = f l o a t - c a s t - o v e r f l o w \
- f s a n i t i z e = f l o a t - d i v i d e - b y - z e r o \
- f s a n i t i z e = n o n n u l l - a t t r i b u t e \
- f s a n i t i z e = r e t u r n s - n o n n u l l - a t t r i b u t e \
- f s a n i t i z e = s i g n e d - i n t e g e r - o v e r f l o w \
- f s a n i t i z e = u n d e f i n e d \
- f s a n i t i z e = v l a - b o u n d \
- f n o - s a n i t i z e = a l i g n m e n t \
" )
2019-04-17 06:35:54 +02:00
if ( NOT MSVC ) # not all sanitizers are supported with clang-cl, these two however are very vocal about it
set ( _asan_defaults "${_asan_defaults} -fsanitize=leak -fsanitize=object-size" )
endif ( )
set ( COMPILER_ASAN_CFLAGS "${_asan_defaults}" CACHE STRING "C flags for address sanitizer" )
mark_as_advanced ( COMPILER_ASAN_CFLAGS )
set ( COMPILER_ASAN_CXXFLAGS "${_asan_defaults}" CACHE STRING "C++ flags for address sanitizer" )
mark_as_advanced ( COMPILER_ASAN_CXXFLAGS )
unset ( _asan_defaults )
if ( NOT MSVC )
find_library ( COMPILER_ASAN_LIBRARY asan ${ CMAKE_C_IMPLICIT_LINK_DIRECTORIES } )
else ( )
2020-02-14 23:57:56 +01:00
find_library (
C O M P I L E R _ A S A N _ L I B R A R Y N A M E S c l a n g _ r t . a s a n - x 8 6 _ 6 4
2019-04-17 06:35:54 +02:00
P A T H S
[ H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ W o w 6 4 3 2 N o d e \ \ L L V M \ \ L L V M ; ] / l i b / c l a n g / 7 . 0 . 0 / l i b / w i n d o w s
[ H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ W o w 6 4 3 2 N o d e \ \ L L V M \ \ L L V M ; ] / l i b / c l a n g / 6 . 0 . 0 / l i b / w i n d o w s
)
endif ( )
mark_as_advanced ( COMPILER_ASAN_LIBRARY )
endif ( )
2018-05-18 15:21:18 +02:00
endif ( )
2017-03-05 18:05:00 +01:00
if ( WIN32 )
2019-04-17 06:35:54 +02:00
# Use hardcoded paths or find_package to find externals
option ( WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF )
mark_as_advanced ( WITH_WINDOWS_FIND_MODULES )
2016-08-23 16:47:23 +02:00
2019-06-15 20:35:36 +02:00
option ( WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS "Organize the visual studio projects according to source folder structure." ON )
mark_as_advanced ( WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS )
2018-10-22 18:17:08 +02:00
2019-06-15 20:44:47 +02:00
option ( WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS "Organize the source files in filters matching the source folders." ON )
mark_as_advanced ( WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS )
2019-04-17 06:35:54 +02:00
option ( WINDOWS_PYTHON_DEBUG "Include the files needed for debugging python scripts with visual studio 2017+." OFF )
mark_as_advanced ( WINDOWS_PYTHON_DEBUG )
2019-12-06 18:12:03 +01:00
option ( WITH_WINDOWS_BUNDLE_CRT "Bundle the C runtime for install free distribution." ON )
mark_as_advanced ( WITH_WINDOWS_BUNDLE_CRT )
2020-04-20 20:51:43 +02:00
option ( WITH_WINDOWS_SCCACHE "Use sccache to speed up builds (Ninja builder only)" OFF )
mark_as_advanced ( WITH_WINDOWS_SCCACHE )
2020-05-01 15:37:48 +02:00
option ( WITH_WINDOWS_PDB "Generate a pdb file for client side stacktraces" ON )
mark_as_advanced ( WITH_WINDOWS_PDB )
option ( WITH_WINDOWS_STRIPPED_PDB "Use a stripped PDB file" On )
mark_as_advanced ( WITH_WINDOWS_STRIPPED_PDB )
2017-03-05 18:05:00 +01:00
endif ( )
2016-08-31 14:26:05 +02:00
CMake: Add support of Ninja's pools to ease building on limited amount of RAM.
Many modern computers support a lot of threads (parrallel building
jobs), but are somewhat restricted in memory, when some building jobs
can require several GB each.
Ninja builder has pools, which extend the usual `-j X` make
parallelizing option, by allowing to specify different numbers of
parallel jobs for different targets.
This commit defines three pools, one for linking, one for usual compile,
and one for compiling some 'heavy' cpp libs, when a single file can
require GB of RAM in full debug builds.
Simply enabling WITH_NINJA_POOL_JOBS will try to set default sensible
values for those three pools based on your machine specifications, you
can then tweak further the values of NINJA_MAX_NUM_PARALLEL_ settings,
if you like.
On my system (8 cores, 16GB RAM), it allows to build a full debug with
all ASAN options build with roughly 7GB of RAM used at most, pretty much
as quickly as without that option (which would require up to 11GB of
available RAM at some points).
Review task: D4780.
2019-05-07 20:32:14 +02:00
# The following only works with the Ninja generator in CMake >= 3.0.
if ( "${CMAKE_GENERATOR}" MATCHES "Ninja" )
option ( WITH_NINJA_POOL_JOBS
" E n a b l e N i n j a p o o l s o f j o b s , t o t r y t o e a s e b u i l d i n g o n m a c h i n e s w i t h 1 6 G B o f R A M o r less ( if not yet defined, will try to set best values based on detected machine specifications ) . "
O F F )
mark_as_advanced ( WITH_NINJA_POOL_JOBS )
endif ( )
2019-10-09 17:14:00 +02:00
if ( UNIX AND NOT APPLE )
option ( WITH_CXX11_ABI "Use native C++11 ABI of compiler" ON )
mark_as_advanced ( WITH_CXX11_ABI )
endif ( )
2019-11-07 16:50:31 +01:00
# Installation process.
option ( POSTINSTALL_SCRIPT "Run given CMake script after installation process" OFF )
mark_as_advanced ( POSTINSTALL_SCRIPT )
2014-11-13 23:32:01 +01:00
# end option(...)
2014-11-11 21:44:26 +01:00
2014-11-08 11:32:32 +01:00
# By default we want to install to the directory we are compiling our executables
# unless specified otherwise, which we currently do not allow
2014-11-13 15:03:30 +01:00
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
2019-04-17 06:35:54 +02:00
if ( WIN32 )
set ( CMAKE_INSTALL_PREFIX ${ EXECUTABLE_OUTPUT_PATH } /\ ${ BUILD_TYPE } CACHE PATH "default install path" FORCE )
elseif ( APPLE )
set ( CMAKE_INSTALL_PREFIX ${ EXECUTABLE_OUTPUT_PATH } /\ ${ BUILD_TYPE } CACHE PATH "default install path" FORCE )
else ( )
if ( WITH_INSTALL_PORTABLE )
set ( CMAKE_INSTALL_PREFIX ${ EXECUTABLE_OUTPUT_PATH } CACHE PATH "default install path" FORCE )
endif ( )
endif ( )
2014-11-08 11:32:32 +01:00
endif ( )
2014-11-11 21:44:26 +01:00
2014-11-08 11:32:32 +01:00
2014-10-07 22:46:19 +02:00
# Apple
2010-12-08 09:43:06 +01:00
if ( APPLE )
2019-04-17 06:35:54 +02:00
include ( platform_apple_xcode )
2010-12-08 09:43:06 +01:00
endif ( )
2010-06-06 15:32:58 +02:00
2012-03-13 23:27:21 +01:00
2011-06-08 03:53:12 +02:00
#-----------------------------------------------------------------------------
# Check for conflicting/unsupported configurations
2018-04-16 15:54:36 +02:00
if ( NOT WITH_BLENDER AND NOT WITH_CYCLES_STANDALONE )
2019-04-17 06:35:54 +02:00
message ( FATAL_ERROR
" A t l e a s t o n e o f W I T H _ B L E N D E R o r W I T H _ C Y C L E S _ S T A N D A L O N E "
" m u s t b e e n a b l e d , n o t h i n g t o d o ! "
)
2011-07-13 10:15:06 +02:00
endif ( )
2012-11-12 05:50:45 +01:00
if ( NOT WITH_AUDASPACE )
2019-04-17 06:35:54 +02:00
if ( WITH_OPENAL )
message ( WARNING "WITH_OPENAL requires WITH_AUDASPACE which is disabled" )
set ( WITH_OPENAL OFF )
endif ( )
if ( WITH_JACK )
message ( WARNING "WITH_JACK requires WITH_AUDASPACE which is disabled" )
set ( WITH_JACK OFF )
endif ( )
2011-06-23 11:27:56 +02:00
endif ( )
2011-07-13 08:04:54 +02:00
if ( NOT WITH_SDL AND WITH_GHOST_SDL )
2019-04-17 06:35:54 +02:00
message ( FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL" )
2011-07-12 15:17:54 +02:00
endif ( )
2018-04-16 14:07:42 +02:00
# python module, needs some different options
2011-02-22 15:27:46 +01:00
if ( WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL )
2019-04-17 06:35:54 +02:00
message ( FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF" )
2011-02-22 15:27:46 +01:00
endif ( )
2013-08-08 00:40:03 +02:00
if ( NOT WITH_PYTHON )
2019-04-17 06:35:54 +02:00
set ( WITH_CYCLES OFF )
set ( WITH_DRACO OFF )
2013-08-08 00:40:03 +02:00
endif ( )
2019-04-12 14:26:17 +02:00
if ( WITH_DRACO AND NOT WITH_PYTHON_INSTALL )
2019-04-17 06:35:54 +02:00
message ( STATUS "WITH_DRACO requires WITH_PYTHON_INSTALL to be ON, disabling WITH_DRACO for now" )
set ( WITH_DRACO OFF )
2019-04-12 14:26:17 +02:00
endif ( )
2014-11-13 13:36:33 +01:00
# enable boost for cycles, audaspace or i18n
2013-02-01 00:25:06 +01:00
# otherwise if the user disabled
2020-02-07 15:27:40 +01:00
set_and_warn_dependency ( WITH_BOOST WITH_CYCLES OFF )
set_and_warn_dependency ( WITH_BOOST WITH_INTERNATIONAL OFF )
set_and_warn_dependency ( WITH_BOOST WITH_OPENVDB OFF )
set_and_warn_dependency ( WITH_BOOST WITH_OPENCOLORIO OFF )
set_and_warn_dependency ( WITH_BOOST WITH_QUADRIFLOW OFF )
set_and_warn_dependency ( WITH_BOOST WITH_USD OFF )
2020-04-02 15:03:36 +02:00
set_and_warn_dependency ( WITH_BOOST WITH_ALEMBIC OFF )
2020-02-07 15:27:40 +01:00
2020-02-09 01:17:28 +01:00
if ( WITH_BOOST AND NOT ( WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR
2020-04-02 15:03:36 +02:00
W I T H _ O P E N V D B O R W I T H _ O P E N C O L O R I O O R W I T H _ U S D O R W I T H _ A L E M B I C ) )
2020-02-07 15:27:40 +01:00
message ( STATUS "No dependencies need 'WITH_BOOST' forcing WITH_BOOST=OFF" )
2019-04-17 06:35:54 +02:00
set ( WITH_BOOST OFF )
2011-08-16 18:15:34 +02:00
endif ( )
2020-06-05 12:53:38 +02:00
set_and_warn_dependency ( WITH_TBB WITH_CYCLES OFF )
2020-02-07 15:27:40 +01:00
set_and_warn_dependency ( WITH_TBB WITH_USD OFF )
set_and_warn_dependency ( WITH_TBB WITH_OPENIMAGEDENOISE OFF )
set_and_warn_dependency ( WITH_TBB WITH_OPENVDB OFF )
set_and_warn_dependency ( WITH_TBB WITH_MOD_FLUID OFF )
2020-03-04 00:39:53 +01:00
# OpenVDB uses 'half' type from OpenEXR & fails to link without OpenEXR enabled.
set_and_warn_dependency ( WITH_IMAGE_OPENEXR WITH_OPENVDB OFF )
2013-03-27 19:44:46 +01:00
# auto enable openimageio for cycles
if ( WITH_CYCLES )
2019-04-17 06:35:54 +02:00
set ( WITH_OPENIMAGEIO ON )
2015-06-14 01:34:42 +02:00
2019-04-17 06:35:54 +02:00
# auto enable llvm for cycles_osl
if ( WITH_CYCLES_OSL )
set ( WITH_LLVM ON CACHE BOOL "" FORCE )
endif ( )
2015-06-14 01:50:33 +02:00
else ( )
2019-04-17 06:35:54 +02:00
set ( WITH_CYCLES_OSL OFF )
2013-03-27 19:44:46 +01:00
endif ( )
# auto enable openimageio linking dependencies
if ( WITH_OPENIMAGEIO )
2019-04-17 06:35:54 +02:00
set ( WITH_IMAGE_OPENEXR ON )
set ( WITH_IMAGE_TIFF ON )
2013-03-27 19:44:46 +01:00
endif ( )
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
# auto enable alembic linking dependencies
if ( WITH_ALEMBIC )
2019-04-17 06:35:54 +02:00
set ( WITH_IMAGE_OPENEXR ON )
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
endif ( )
2012-09-28 08:45:20 +02:00
# don't store paths to libs for portable distribution
2011-08-23 22:19:08 +02:00
if ( WITH_INSTALL_PORTABLE )
2019-04-17 06:35:54 +02:00
set ( CMAKE_SKIP_BUILD_RPATH TRUE )
2011-08-23 22:19:08 +02:00
endif ( )
2012-03-13 15:28:58 +01:00
if ( WITH_GHOST_SDL OR WITH_HEADLESS )
2020-05-01 12:07:01 +02:00
set ( WITH_GHOST_WAYLAND OFF )
2020-05-01 11:14:50 +02:00
set ( WITH_GHOST_X11 OFF )
2019-04-17 06:35:54 +02:00
set ( WITH_X11_XINPUT OFF )
set ( WITH_X11_XF86VMODE OFF )
set ( WITH_X11_XFIXES OFF )
set ( WITH_X11_ALPHA OFF )
set ( WITH_GHOST_XDND OFF )
set ( WITH_INPUT_IME OFF )
2020-03-18 14:55:05 +01:00
set ( WITH_XR_OPENXR OFF )
2012-03-13 15:28:58 +01:00
endif ( )
2014-10-15 10:53:12 +02:00
if ( WITH_CPU_SSE )
2019-04-17 06:35:54 +02:00
TEST_SSE_SUPPORT ( COMPILER_SSE_FLAG COMPILER_SSE2_FLAG )
2014-10-15 10:53:12 +02:00
else ( )
2019-04-17 06:35:54 +02:00
message ( STATUS "SSE and SSE2 optimizations are DISABLED!" )
set ( COMPILER_SSE_FLAG )
set ( COMPILER_SSE2_FLAG )
2014-10-15 10:53:12 +02:00
endif ( )
2012-03-13 23:27:21 +01:00
2016-03-11 09:05:44 +01:00
if ( WITH_BUILDINFO )
2019-04-17 06:35:54 +02:00
find_package ( Git )
if ( NOT GIT_FOUND )
message ( WARNING "Git was not found, disabling WITH_BUILDINFO" )
set ( WITH_BUILDINFO OFF )
endif ( )
2016-03-11 09:05:44 +01:00
endif ( )
2015-06-16 10:03:35 +02:00
if ( WITH_AUDASPACE )
2019-04-17 06:35:54 +02:00
if ( NOT WITH_SYSTEM_AUDASPACE )
set ( AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings/C" "${CMAKE_BINARY_DIR}/extern/audaspace" )
set ( AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/audaspace/bindings" )
endif ( )
2015-06-16 10:03:35 +02:00
endif ( )
2018-02-14 10:20:26 +01:00
# Auto-enable CUDA dynload if toolkit is not found.
if ( NOT WITH_CUDA_DYNLOAD )
2019-04-17 06:35:54 +02:00
find_package ( CUDA )
2019-06-18 23:24:55 +02:00
if ( NOT CUDA_FOUND )
2019-04-17 06:35:54 +02:00
message ( "CUDA toolkit not found, using dynamic runtime loading of libraries instead" )
set ( WITH_CUDA_DYNLOAD ON )
endif ( )
2018-02-14 10:20:26 +01:00
endif ( )
2012-03-14 01:30:20 +01:00
#-----------------------------------------------------------------------------
2019-09-05 20:22:52 +02:00
# Check check if submodules are cloned
2012-03-14 01:30:20 +01:00
if ( WITH_INTERNATIONAL )
2019-09-05 20:22:52 +02:00
file ( GLOB RESULT "${CMAKE_SOURCE_DIR}/release/datafiles/locale" )
list ( LENGTH RESULT DIR_LEN )
if ( DIR_LEN EQUAL 0 )
2019-04-17 06:35:54 +02:00
message ( WARNING
" T r a n s l a t i o n p a t h ' $ { C M A K E _ S O U R C E _ D I R } / r e l e a s e / d a t a f i l e s / l o c a l e ' i s m i s s i n g , "
" T h i s i s a ' g i t s u b m o d u l e ' , w h i c h a r e k n o w n n o t t o w o r k w i t h b r i d g e s t o o t h e r v e r s i o n "
" c o n t r o l s y s t e m s , d i s a b l i n g ' W I T H _ I N T E R N A T I O N A L ' . "
)
set ( WITH_INTERNATIONAL OFF )
endif ( )
2012-03-14 01:30:20 +01:00
endif ( )
if ( WITH_PYTHON )
2019-04-17 06:35:54 +02:00
# While we have this as an '#error' in 'bpy_capi_utils.h',
# upgrading Python tends to cause confusion for users who build.
# Give the error message early to make this more obvious.
#
# Do this before main 'platform_*' checks,
# because UNIX will search for the old Python paths which may not exist.
# giving errors about missing paths before this case is met.
if ( DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.7" )
message ( FATAL_ERROR "At least Python 3.7 is required to build" )
endif ( )
2019-09-05 20:22:52 +02:00
file ( GLOB RESULT "${CMAKE_SOURCE_DIR}/release/scripts/addons" )
list ( LENGTH RESULT DIR_LEN )
if ( DIR_LEN EQUAL 0 )
2019-04-17 06:35:54 +02:00
message ( WARNING
" A d d o n s p a t h ' $ { C M A K E _ S O U R C E _ D I R } / r e l e a s e / s c r i p t s / a d d o n s ' i s m i s s i n g , "
" T h i s i s a ' g i t s u b m o d u l e ' , w h i c h a r e k n o w n n o t t o w o r k w i t h b r i d g e s t o o t h e r v e r s i o n "
" c o n t r o l s y s t e m s : * C O N T I N U I N G W I T H O U T A D D O N S * "
)
endif ( )
2012-03-14 01:30:20 +01:00
endif ( )
2011-02-22 07:23:07 +01:00
#-----------------------------------------------------------------------------
# Initialize un-cached vars, avoid unused warning
2011-02-21 14:13:08 +01:00
# linux only, not cached
set ( WITH_BINRELOC OFF )
2016-12-29 07:09:11 +01:00
# MACOSX only, set to avoid uninitialized
2011-10-01 21:52:33 +02:00
set ( EXETYPE "" )
2011-06-28 04:49:49 +02:00
# C/C++ flags
set ( PLATFORM_CFLAGS )
2011-06-14 02:24:50 +02:00
2011-02-22 07:23:07 +01:00
# these are added to later on.
2011-06-28 04:49:49 +02:00
set ( C_WARNINGS )
set ( CXX_WARNINGS )
2011-10-30 05:48:00 +01:00
# for gcc -Wno-blah-blah
2018-06-22 14:17:55 +02:00
set ( C_REMOVE_STRICT_FLAGS )
2018-06-22 14:07:55 +02:00
set ( CXX_REMOVE_STRICT_FLAGS )
2011-10-30 05:48:00 +01:00
2011-06-28 04:49:49 +02:00
# libraries to link the binary with passed to target_link_libraries()
# known as LLIBS to scons
2011-10-01 21:52:33 +02:00
set ( PLATFORM_LINKLIBS "" )
2011-06-28 04:49:49 +02:00
# Added to linker flags in setup_liblinks
# - CMAKE_EXE_LINKER_FLAGS
# - CMAKE_EXE_LINKER_FLAGS_DEBUG
2011-10-01 21:52:33 +02:00
set ( PLATFORM_LINKFLAGS "" )
set ( PLATFORM_LINKFLAGS_DEBUG "" )
2011-02-22 07:23:07 +01:00
2019-06-18 23:24:55 +02:00
if ( NOT CMAKE_BUILD_TYPE MATCHES "Release" )
2019-04-17 06:35:54 +02:00
if ( WITH_COMPILER_ASAN )
set ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMPILER_ASAN_CFLAGS}" )
set ( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CFLAGS}" )
2018-06-08 11:45:05 +02:00
2019-04-17 06:35:54 +02:00
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}" )
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}" )
if ( MSVC )
set ( COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6" )
endif ( )
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 ( COMPILER_ASAN_LIBRARY )
set ( PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}" )
set ( PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}" )
set ( PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}" )
endif ( )
2019-04-17 06:35:54 +02:00
endif ( )
2018-05-18 15:21:18 +02:00
endif ( )
2011-02-22 07:23:07 +01:00
2015-07-28 09:47:21 +02:00
# ----------------------------------------------------------------------------
# Main Platform Checks
#
# - UNIX
# - WIN32
# - APPLE
2010-12-08 09:43:06 +01:00
if ( UNIX AND NOT APPLE )
2019-04-17 06:35:54 +02:00
include ( platform_unix )
2010-12-08 09:43:06 +01:00
elseif ( WIN32 )
2019-04-17 06:35:54 +02:00
include ( platform_win32 )
2010-12-08 09:43:06 +01:00
elseif ( APPLE )
2019-04-17 06:35:54 +02:00
include ( platform_apple )
2010-12-08 09:43:06 +01:00
endif ( )
2006-11-17 03:27:12 +01:00
#-----------------------------------------------------------------------------
# Common.
2010-08-11 10:23:48 +02:00
2012-12-05 16:46:31 +01:00
if ( NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM )
2019-04-17 06:35:54 +02:00
message ( FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON" )
2012-12-05 16:46:31 +01:00
endif ( )
2012-07-01 17:26:25 +02:00
if ( WITH_CYCLES )
2019-04-17 06:35:54 +02:00
if ( NOT WITH_OPENIMAGEIO )
message ( FATAL_ERROR
" C y c l e s r e q u i r e s W I T H _ O P E N I M A G E I O , t h e l i b r a r y m a y n o t h a v e b e e n f o u n d . "
" C o n f i g u r e O I I O o r d i s a b l e W I T H _ C Y C L E S "
)
endif ( )
if ( NOT WITH_BOOST )
message ( FATAL_ERROR
" C y c l e s r e q u i r e s W I T H _ B O O S T , t h e l i b r a r y m a y n o t h a v e b e e n f o u n d . "
" C o n f i g u r e B O O S T o r d i s a b l e W I T H _ C Y C L E S "
)
endif ( )
if ( WITH_CYCLES_OSL )
if ( NOT WITH_LLVM )
message ( FATAL_ERROR
" C y c l e s O S L r e q u i r e s W I T H _ L L V M , t h e l i b r a r y m a y n o t h a v e b e e n f o u n d . "
" C o n f i g u r e L L V M o r d i s a b l e W I T H _ C Y C L E S _ O S L "
)
endif ( )
endif ( )
2012-07-01 17:26:25 +02:00
endif ( )
2012-11-11 17:54:26 +01:00
if ( WITH_INTERNATIONAL )
2019-04-17 06:35:54 +02:00
if ( NOT WITH_BOOST )
message ( FATAL_ERROR
" I n t e r n a t i o n a l i z a t i o n r e q u i r e s W I T H _ B O O S T , t h e l i b r a r y m a y n o t h a v e b e e n f o u n d . "
" C o n f i g u r e B O O S T o r d i s a b l e W I T H _ I N T E R N A T I O N A L "
)
endif ( )
2012-11-11 17:54:26 +01:00
endif ( )
2012-07-01 17:26:25 +02:00
2011-08-01 08:11:41 +02:00
# See TEST_SSE_SUPPORT() for how this is defined.
2016-05-05 19:25:08 +02:00
# Do it globally, SSE2 is required for quite some time now.
# Doing it now allows to use SSE/SSE2 in inline headers.
if ( SUPPORT_SSE_BUILD )
2019-04-17 06:35:54 +02:00
set ( PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}" )
add_definitions ( -D__SSE__ -D__MMX__ )
2016-05-05 19:25:08 +02:00
endif ( )
if ( SUPPORT_SSE2_BUILD )
2019-04-17 06:35:54 +02:00
set ( PLATFORM_CFLAGS " ${PLATFORM_CFLAGS} ${COMPILER_SSE2_FLAG}" )
add_definitions ( -D__SSE2__ )
if ( NOT SUPPORT_SSE_BUILD ) # don't double up
add_definitions ( -D__MMX__ )
endif ( )
2010-12-08 09:43:06 +01:00
endif ( )
2011-09-19 10:02:17 +02:00
# set the endian define
2012-08-07 14:03:43 +02:00
if ( MSVC )
2019-04-17 06:35:54 +02:00
# for some reason this fails on msvc
add_definitions ( -D__LITTLE_ENDIAN__ )
2017-04-27 13:40:18 +02:00
2019-06-18 23:24:55 +02:00
# OSX-Note: as we do cross-compiling with specific set architecture,
# endianess-detection and auto-setting is counterproductive
# so we just set endianness according CMAKE_OSX_ARCHITECTURES
2012-08-07 15:51:19 +02:00
2020-07-16 09:25:55 +02:00
elseif ( CMAKE_OSX_ARCHITECTURES MATCHES i386 OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64 OR CMAKE_OSX_ARCHITECTURES MATCHES arm64 )
2019-04-17 06:35:54 +02:00
add_definitions ( -D__LITTLE_ENDIAN__ )
2017-04-27 13:40:18 +02:00
elseif ( CMAKE_OSX_ARCHITECTURES MATCHES ppc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc64 )
2019-04-17 06:35:54 +02:00
add_definitions ( -D__BIG_ENDIAN__ )
2017-04-27 13:40:18 +02:00
2011-09-27 03:32:27 +02:00
else ( )
2019-04-17 06:35:54 +02:00
include ( TestBigEndian )
test_big_endian ( _SYSTEM_BIG_ENDIAN )
if ( _SYSTEM_BIG_ENDIAN )
add_definitions ( -D__BIG_ENDIAN__ )
else ( )
add_definitions ( -D__LITTLE_ENDIAN__ )
endif ( )
unset ( _SYSTEM_BIG_ENDIAN )
2011-09-19 10:02:17 +02:00
endif ( )
2010-12-08 09:43:06 +01:00
if ( WITH_IMAGE_OPENJPEG )
2019-04-17 06:35:54 +02:00
# Special handling of Windows platform where openjpeg is always static.
if ( WIN32 )
set ( OPENJPEG_DEFINES "-DOPJ_STATIC" )
else ( )
set ( OPENJPEG_DEFINES "" )
endif ( )
2010-12-08 09:43:06 +01:00
endif ( )
2006-11-17 03:27:12 +01:00
2015-03-19 05:41:41 +01:00
if ( NOT WITH_SYSTEM_EIGEN3 )
2019-04-17 06:35:54 +02:00
set ( EIGEN3_INCLUDE_DIRS ${ CMAKE_SOURCE_DIR } /extern/Eigen3 )
2015-03-19 05:41:41 +01:00
endif ( )
2008-10-07 19:13:35 +02:00
2020-02-26 15:11:24 +01:00
if ( WITH_OPENVDB )
list ( APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB )
if ( WITH_OPENVDB_3_ABI_COMPATIBLE )
list ( APPEND OPENVDB_DEFINITIONS -DOPENVDB_3_ABI_COMPATIBLE )
endif ( )
list ( APPEND OPENVDB_INCLUDE_DIRS
$ { B O O S T _ I N C L U D E _ D I R }
$ { T B B _ I N C L U D E _ D I R S }
$ { O P E N E X R _ I N C L U D E _ D I R S } )
list ( APPEND OPENVDB_LIBRARIES ${ OPENEXR_LIBRARIES } ${ ZLIB_LIBRARIES } )
if ( WITH_OPENVDB_BLOSC )
list ( APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB_BLOSC )
list ( APPEND OPENVDB_LIBRARIES ${ BLOSC_LIBRARIES } ${ ZLIB_LIBRARIES } )
endif ( )
list ( APPEND OPENVDB_LIBRARIES ${ BOOST_LIBRARIES } ${ TBB_LIBRARIES } )
endif ( )
2006-11-17 03:27:12 +01:00
#-----------------------------------------------------------------------------
# Configure OpenGL.
2014-10-07 22:46:19 +02:00
2010-12-08 09:43:06 +01:00
find_package ( OpenGL )
2011-06-08 07:39:58 +02:00
blender_include_dirs_sys ( "${OPENGL_INCLUDE_DIR}" )
2014-10-07 22:46:19 +02:00
2018-06-16 04:17:16 +02:00
if ( WITH_OPENGL )
2019-04-17 06:35:54 +02:00
add_definitions ( -DWITH_OPENGL )
2018-06-16 04:17:16 +02:00
endif ( )
2014-10-07 22:46:19 +02:00
if ( WITH_SYSTEM_GLES )
2019-04-17 06:35:54 +02:00
find_package_wrapper ( OpenGLES )
2014-10-07 22:46:19 +02:00
endif ( )
2017-05-11 16:38:05 +02:00
if ( WITH_GL_PROFILE_ES20 )
2019-04-17 06:35:54 +02:00
if ( WITH_SYSTEM_GLES )
if ( NOT OPENGLES_LIBRARY )
message ( FATAL_ERROR
" U n a b l e t o f i n d O p e n G L E S l i b r a r i e s . "
" I n s t a l l t h e m o r d i s a b l e W I T H _ S Y S T E M _ G L E S . "
)
endif ( )
2014-10-07 22:46:19 +02:00
2020-01-28 10:32:29 +01:00
list ( APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}" )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
else ( )
set ( OPENGLES_LIBRARY "" CACHE FILEPATH "OpenGL ES 2.0 library file" )
mark_as_advanced ( OPENGLES_LIBRARY )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
list ( APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}" )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( NOT OPENGLES_LIBRARY )
message ( FATAL_ERROR
" T o c o m p i l e W I T H _ G L _ E G L y o u n e e d t o s e t O P E N G L E S _ L I B R A R Y "
" t o t h e f i l e p a t h o f a n O p e n G L E S 2 . 0 l i b r a r y . "
)
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( WIN32 )
# Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
set ( OPENGLES_DLL "" CACHE FILEPATH "OpenGL ES 2.0 redistributable DLL file" )
mark_as_advanced ( OPENGLES_DLL )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( NOT OPENGLES_DLL )
message ( FATAL_ERROR
" T o c o m p i l e W I T H _ G L _ P R O F I L E _ E S 2 0 y o u n e e d t o s e t O P E N G L E S _ D L L t o t h e f i l e "
" p a t h o f a n O p e n G L E S 2 . 0 r u n t i m e d y n a m i c l i n k library ( DLL ) . "
)
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( WITH_GL_ANGLE )
list ( APPEND GL_DEFINITIONS -DWITH_ANGLE )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
set ( D3DCOMPILER_DLL "" CACHE FILEPATH "Direct3D Compiler redistributable DLL file (needed by ANGLE)" )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
get_filename_component ( D3DCOMPILER_FILENAME "${D3DCOMPILER_DLL}" NAME )
list ( APPEND GL_DEFINITIONS "-DD3DCOMPILER=\" \\\"${D3DCOMPILER_FILENAME}\\\"\"")
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
mark_as_advanced ( D3DCOMPILER_DLL )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( D3DCOMPILER_DLL STREQUAL "" )
message ( FATAL_ERROR
" T o c o m p i l e W I T H _ G L _ A N G L E y o u n e e d t o s e t D 3 D C O M P I L E R _ D L L t o t h e f i l e "
" p a t h o f a c o p y o f t h e D i r e c t X r e d i s t r i b u t a b l e D L L f i l e : D 3 D C o m p i l e r _ 4 6 . d l l "
)
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
endif ( )
2014-10-07 22:46:19 +02:00
2017-05-11 16:38:05 +02:00
else ( )
2019-04-17 06:35:54 +02:00
if ( OpenGL_GL_PREFERENCE STREQUAL "LEGACY" AND OPENGL_gl_LIBRARY )
list ( APPEND BLENDER_GL_LIBRARIES ${ OPENGL_gl_LIBRARY } )
else ( )
list ( APPEND BLENDER_GL_LIBRARIES ${ OPENGL_opengl_LIBRARY } ${ OPENGL_glx_LIBRARY } )
endif ( )
2014-10-07 22:46:19 +02:00
endif ( )
if ( WITH_GL_EGL )
2020-01-28 10:32:29 +01:00
find_package ( OpenGL REQUIRED EGL )
list ( APPEND BLENDER_GL_LIBRARIES OpenGL::EGL )
list ( APPEND GL_DEFINITIONS -DWITH_GL_EGL -DGLEW_EGL -DGLEW_INC_EGL )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( WITH_SYSTEM_GLES )
if ( NOT OPENGLES_EGL_LIBRARY )
message ( FATAL_ERROR
" U n a b l e t o f i n d O p e n G L E S l i b r a r i e s . "
" I n s t a l l t h e m o r d i s a b l e W I T H _ S Y S T E M _ G L E S . "
)
endif ( )
2014-10-07 22:46:19 +02:00
2020-01-28 10:32:29 +01:00
list ( APPEND BLENDER_GL_LIBRARIES ${ OPENGLES_EGL_LIBRARY } )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
else ( )
set ( OPENGLES_EGL_LIBRARY "" CACHE FILEPATH "EGL library file" )
mark_as_advanced ( OPENGLES_EGL_LIBRARY )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
list ( APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}" "${OPENGLES_EGL_LIBRARY}" )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( NOT OPENGLES_EGL_LIBRARY )
message ( FATAL_ERROR
" T o c o m p i l e W I T H _ G L _ E G L y o u n e e d t o s e t O P E N G L E S _ E G L _ L I B R A R Y "
" t o t h e f i l e p a t h o f a n E G L l i b r a r y . "
)
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( WIN32 )
# Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
set ( OPENGLES_EGL_DLL "" CACHE FILEPATH "EGL redistributable DLL file" )
mark_as_advanced ( OPENGLES_EGL_DLL )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( NOT OPENGLES_EGL_DLL )
message ( FATAL_ERROR
" T o c o m p i l e W I T H _ G L _ E G L y o u n e e d t o s e t O P E N G L E S _ E G L _ D L L "
" t o t h e f i l e p a t h o f a n E G L r u n t i m e d y n a m i c l i n k library ( DLL ) . "
)
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
endif ( )
2014-10-07 22:46:19 +02:00
endif ( )
if ( WITH_GL_PROFILE_ES20 )
2019-04-17 06:35:54 +02:00
list ( APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_ES20 )
2017-05-11 16:38:05 +02:00
else ( )
2019-04-17 06:35:54 +02:00
list ( APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE )
2014-10-07 22:46:19 +02:00
endif ( )
2010-11-19 12:33:12 +01:00
#-----------------------------------------------------------------------------
# Configure OpenMP.
2014-07-08 00:29:53 +02:00
if ( WITH_OPENMP )
2019-04-17 06:35:54 +02:00
if ( NOT OPENMP_CUSTOM )
find_package ( OpenMP )
endif ( )
if ( OPENMP_FOUND )
if ( NOT WITH_OPENMP_STATIC )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
else ( )
# Typically avoid adding flags as defines but we can't
# pass OpenMP flags to the linker for static builds, meaning
# we can't add any OpenMP related flags to CFLAGS variables
# since they're passed to the linker as well.
add_definitions ( "${OpenMP_C_FLAGS}" )
find_library_static ( OpenMP_LIBRARIES gomp ${ CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES } )
endif ( )
else ( )
set ( WITH_OPENMP OFF )
endif ( )
mark_as_advanced (
O p e n M P _ C _ F L A G S
O p e n M P _ C X X _ F L A G S
)
2011-09-30 17:51:58 +02:00
endif ( )
2010-11-19 12:33:12 +01:00
2011-04-06 01:31:01 +02:00
#-----------------------------------------------------------------------------
# Configure GLEW
2012-06-23 15:42:14 +02:00
if ( WITH_SYSTEM_GLEW )
2019-04-17 06:35:54 +02:00
find_package ( GLEW )
2011-04-06 01:31:01 +02:00
2019-04-17 06:35:54 +02:00
# Note: There is an assumption here that the system GLEW is not a static library.
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( NOT GLEW_FOUND )
message ( FATAL_ERROR "GLEW is required to build Blender. Install it or disable WITH_SYSTEM_GLEW." )
endif ( )
2011-04-06 01:31:01 +02:00
2019-11-18 06:26:32 +01:00
set ( GLEW_INCLUDE_PATH "${GLEW_INCLUDE_DIR}" )
2019-04-17 06:35:54 +02:00
set ( BLENDER_GLEW_LIBRARIES ${ GLEW_LIBRARY } )
2012-06-23 15:42:14 +02:00
else ( )
2019-04-17 06:35:54 +02:00
if ( WITH_GLEW_ES )
set ( GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include" )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
list ( APPEND GL_DEFINITIONS -DGLEW_STATIC -DWITH_GLEW_ES )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
# These definitions remove APIs from glew.h, making GLEW smaller, and catching unguarded API usage
if ( WITH_GL_PROFILE_ES20 )
list ( APPEND GL_DEFINITIONS -DGLEW_ES_ONLY )
else ( )
# No ES functions are needed
list ( APPEND GL_DEFINITIONS -DGLEW_NO_ES )
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
if ( WITH_GL_PROFILE_ES20 )
if ( WITH_GL_EGL )
list ( APPEND GL_DEFINITIONS -DGLEW_USE_LIB_ES20 )
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
# ToDo: This is an experiment to eliminate ES 1 symbols,
# GLEW doesn't really properly provide this level of control
# (for example, without modification it eliminates too many symbols)
# so there are lots of modifications to GLEW to make this work,
# and no attempt to make it work beyond Blender at this point.
list ( APPEND GL_DEFINITIONS -DGL_ES_VERSION_1_0=0 -DGL_ES_VERSION_CL_1_1=0 -DGL_ES_VERSION_CM_1_1=0 )
endif ( )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
set ( BLENDER_GLEW_LIBRARIES extern_glew_es bf_intern_glew_mx )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
else ( )
set ( GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include" )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
list ( APPEND GL_DEFINITIONS -DGLEW_STATIC )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
# This won't affect the non-experimental glew library,
# but is used for conditional compilation elsewhere.
list ( APPEND GL_DEFINITIONS -DGLEW_NO_ES )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
set ( BLENDER_GLEW_LIBRARIES extern_glew )
2014-10-07 22:46:19 +02:00
2019-04-17 06:35:54 +02:00
endif ( )
2014-10-07 22:46:19 +02:00
2011-04-06 01:31:01 +02:00
endif ( )
2017-03-23 02:33:19 +01:00
list ( APPEND GL_DEFINITIONS -DGLEW_NO_GLU )
2013-01-03 01:23:52 +01:00
#-----------------------------------------------------------------------------
# Configure Bullet
if ( WITH_BULLET AND WITH_SYSTEM_BULLET )
2019-04-17 06:35:54 +02:00
find_package ( Bullet )
if ( NOT BULLET_FOUND )
set ( WITH_BULLET OFF )
endif ( )
2013-01-03 01:23:52 +01:00
else ( )
2019-04-17 06:35:54 +02:00
set ( BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src" )
# set(BULLET_LIBRARIES "")
2013-01-03 01:23:52 +01:00
endif ( )
2006-11-17 03:27:12 +01:00
#-----------------------------------------------------------------------------
2011-03-24 01:14:49 +01:00
# Configure Python.
if ( WITH_PYTHON_MODULE )
2019-04-17 06:35:54 +02:00
add_definitions ( -DPy_ENABLE_SHARED )
2011-09-30 17:51:58 +02:00
endif ( )
2011-03-24 01:14:49 +01:00
2016-01-04 12:47:36 +01:00
#-----------------------------------------------------------------------------
# Configure GLog/GFlags
if ( WITH_LIBMV OR WITH_GTESTS OR ( WITH_CYCLES AND WITH_CYCLES_LOGGING ) )
2019-04-17 06:35:54 +02:00
if ( WITH_SYSTEM_GFLAGS )
find_package ( Gflags )
if ( NOT GFLAGS_FOUND )
message ( FATAL_ERROR "System wide Gflags is requested but was not found" )
endif ( )
# FindGflags does not define this, and we are not even sure what to use here.
set ( GFLAGS_DEFINES )
else ( )
set ( GFLAGS_DEFINES
- D G F L A G S _ D L L _ D E F I N E _ F L A G =
- D G F L A G S _ D L L _ D E C L A R E _ F L A G =
- D G F L A G S _ D L L _ D E C L =
)
set ( GFLAGS_NAMESPACE "gflags" )
set ( GFLAGS_LIBRARIES extern_gflags )
set ( GFLAGS_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/extern/gflags/src" )
endif ( )
if ( WITH_SYSTEM_GLOG )
find_package ( Glog )
if ( NOT GLOG_FOUND )
message ( FATAL_ERROR "System wide Glog is requested but was not found" )
endif ( )
# FindGlog does not define this, and we are not even sure what to use here.
set ( GLOG_DEFINES )
else ( )
set ( GLOG_DEFINES
- D G O O G L E _ G L O G _ D L L _ D E C L =
)
set ( GLOG_LIBRARIES extern_glog )
if ( WIN32 )
set ( GLOG_INCLUDE_DIRS ${ CMAKE_SOURCE_DIR } /extern/glog/src/windows )
else ( )
set ( GLOG_INCLUDE_DIRS ${ CMAKE_SOURCE_DIR } /extern/glog/include )
endif ( )
endif ( )
2016-01-04 12:47:36 +01:00
endif ( )
2016-01-04 14:11:12 +01:00
#-----------------------------------------------------------------------------
# Configure Ceres
if ( WITH_LIBMV )
2019-04-17 06:35:54 +02:00
# We always have C++11 which includes unordered_map.
2020-06-18 10:12:01 +02:00
set ( CERES_DEFINES "-DCERES_STD_UNORDERED_MAP;-DCERES_USE_CXX_THREADS" )
2016-01-04 14:11:12 +01:00
endif ( )
CMake: Add support of Ninja's pools to ease building on limited amount of RAM.
Many modern computers support a lot of threads (parrallel building
jobs), but are somewhat restricted in memory, when some building jobs
can require several GB each.
Ninja builder has pools, which extend the usual `-j X` make
parallelizing option, by allowing to specify different numbers of
parallel jobs for different targets.
This commit defines three pools, one for linking, one for usual compile,
and one for compiling some 'heavy' cpp libs, when a single file can
require GB of RAM in full debug builds.
Simply enabling WITH_NINJA_POOL_JOBS will try to set default sensible
values for those three pools based on your machine specifications, you
can then tweak further the values of NINJA_MAX_NUM_PARALLEL_ settings,
if you like.
On my system (8 cores, 16GB RAM), it allows to build a full debug with
all ASAN options build with roughly 7GB of RAM used at most, pretty much
as quickly as without that option (which would require up to 11GB of
available RAM at some points).
Review task: D4780.
2019-05-07 20:32:14 +02:00
#-----------------------------------------------------------------------------
# Extra limits to number of jobs running in parallel for some kind os tasks.
# Only supported by Ninja build system currently.
if ( "${CMAKE_GENERATOR}" MATCHES "Ninja" AND WITH_NINJA_POOL_JOBS )
if ( NOT NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS AND
N O T N I N J A _ M A X _ N U M _ P A R A L L E L _ C O M P I L E _ H E A V Y _ J O B S A N D
N O T N I N J A _ M A X _ N U M _ P A R A L L E L _ L I N K _ J O B S )
# Try to define good default values.
# Max mem of heavy cpp files compilation: about 2.5GB
# Max mem during linking: about 3.3GB
cmake_host_system_information ( RESULT _NUM_CORES QUERY NUMBER_OF_LOGICAL_CORES )
# Note: this gives mem in MB.
cmake_host_system_information ( RESULT _TOT_MEM QUERY TOTAL_PHYSICAL_MEMORY )
# Heuristics... the more cores we have, the more free mem we have to keep for the non-heavy tasks too.
if ( ${ _TOT_MEM } LESS 8000 AND ${ _NUM_CORES } GREATER 2 )
set ( _compile_heavy_jobs "1" )
elseif ( ${ _TOT_MEM } LESS 16000 AND ${ _NUM_CORES } GREATER 4 )
set ( _compile_heavy_jobs "2" )
elseif ( ${ _TOT_MEM } LESS 24000 AND ${ _NUM_CORES } GREATER 8 )
set ( _compile_heavy_jobs "3" )
elseif ( ${ _TOT_MEM } LESS 32000 AND ${ _NUM_CORES } GREATER 16 )
set ( _compile_heavy_jobs "4" )
elseif ( ${ _TOT_MEM } LESS 64000 AND ${ _NUM_CORES } GREATER 32 )
set ( _compile_heavy_jobs "8" )
else ( )
set ( _compile_heavy_jobs "" )
endif ( )
set ( NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS "${_compile_heavy_jobs}" CACHE STRING
" D e f i n e t h e m a x i m u m n u m b e r o f c o n c u r r e n t h e a v y c o m p i l a t i o n j o b s , f o r n i n j a b u i l d system ( used for some targets which cpp files can take several GB each during compilation ) . " F O R C E )
mark_as_advanced ( NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS )
set ( _compile_heavy_jobs )
# Only set regular compile jobs if we set heavy jobs, otherwise default (using all cores) if fine.
if ( NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS )
math ( EXPR _compile_jobs "${_NUM_CORES} - 1" )
else ( )
set ( _compile_jobs "" )
endif ( )
set ( NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS "${_compile_jobs}" CACHE STRING
" D e f i n e t h e m a x i m u m n u m b e r o f c o n c u r r e n t c o m p i l a t i o n j o b s , f o r n i n j a b u i l d s y s t e m . " F O R C E )
mark_as_advanced ( NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS )
set ( _compile_jobs )
# In practice, even when there is RAM available, this proves to be quicker than running in parallel
# (due to slow disks accesses).
set ( NINJA_MAX_NUM_PARALLEL_LINK_JOBS "1" CACHE STRING
" D e f i n e t h e m a x i m u m n u m b e r o f c o n c u r r e n t l i n k j o b s , f o r n i n j a b u i l d s y s t e m . " F O R C E )
mark_as_advanced ( NINJA_MAX_NUM_PARALLEL_LINK_JOBS )
set ( _NUM_CORES )
set ( _TOT_MEM )
endif ( )
if ( NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS )
set_property ( GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool= ${ NINJA_MAX_NUM_PARALLEL_COMPILE_JOBS } )
set ( CMAKE_JOB_POOL_COMPILE compile_job_pool )
endif ( )
if ( NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS )
set_property ( GLOBAL APPEND PROPERTY JOB_POOLS compile_heavy_job_pool= ${ NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS } )
endif ( )
if ( NINJA_MAX_NUM_PARALLEL_LINK_JOBS )
set_property ( GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool= ${ NINJA_MAX_NUM_PARALLEL_LINK_JOBS } )
set ( CMAKE_JOB_POOL_LINK link_job_pool )
endif ( )
endif ( )
2011-03-24 01:14:49 +01:00
#-----------------------------------------------------------------------------
2006-11-17 03:27:12 +01:00
# Extra compile flags
2010-10-18 14:35:40 +02:00
2010-12-08 09:43:06 +01:00
if ( CMAKE_COMPILER_IS_GNUCC )
2010-12-16 10:55:35 +01:00
2019-04-17 06:35:54 +02:00
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ALL -Wall )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ERROR_VLA -Werror=vla )
# system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_LOGICAL_OP -Wlogical-op )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_UNDEF -Wundef )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_INIT_SELF -Winit-self ) # needs -Wuninitialized
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_RESTRICT -Wrestrict )
2019-10-07 03:20:49 +02:00
# C-only.
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_NULL -Wnonnull )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ABSOLUTE_VALUE -Wabsolute-value )
2019-04-17 06:35:54 +02:00
# gcc 4.2 gives annoying warnings on every file with this
if ( NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3" )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized )
endif ( )
# versions before gcc4.6 give many BLI_math warnings
if ( NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.6" )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls )
endif ( )
# versions before gcc4.8 include global name-space.
if ( NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.8" )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_SHADOW -Wshadow )
endif ( )
# disable because it gives warnings for printf() & friends.
# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
if ( NOT APPLE )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable )
endif ( )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_ALL -Wall )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self ) # needs -Wuninitialized
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_TYPE_LIMITS -Wtype-limits )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_ERROR_RETURN_TYPE -Werror=return-type )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_POINTER_ARITH -Wpointer-arith )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_UNUSED_PARAMETER -Wunused-parameter )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_UNDEF -Wundef )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict )
# gcc 4.2 gives annoying warnings on every file with this
if ( NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3" )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized )
endif ( )
# causes too many warnings
if ( NOT APPLE )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_UNDEF -Wundef )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations )
endif ( )
# Use 'ATTR_FALLTHROUGH' macro to suppress.
if ( CMAKE_COMPILER_IS_GNUCC AND ( NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0" ) )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5 )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5 )
endif ( )
# flags to undo strict flags
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_TYPE_LIMITS -Wno-type-limits )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_IN_BOOL_CONTEXT -Wno-int-in-bool-context )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_FORMAT -Wno-format )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_SWITCH -Wno-switch )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs )
if ( CMAKE_COMPILER_IS_GNUCC AND ( NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0" ) )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough )
endif ( )
if ( NOT APPLE )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable )
endif ( )
2011-10-30 05:48:00 +01:00
2013-12-02 01:36:33 +01:00
elseif ( CMAKE_C_COMPILER_ID MATCHES "Clang" )
2012-06-11 14:13:41 +02:00
2019-04-17 06:35:54 +02:00
# strange, clang complains these are not supported, but then uses them.
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ALL -Wall )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_ALL -Wall )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_OVERLOADED_VIRTUAL -Wno-overloaded-virtual ) # we get a lot of these, if its a problem a dev needs to look into it.
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof )
# gives too many unfixable warnings
# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_MACROS -Wunused-macros)
# ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS -Wunused-macros)
# flags to undo strict flags
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter )
2020-02-20 11:06:40 +01:00
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable )
2019-04-17 06:35:54 +02:00
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef )
ADD_CHECK_C_COMPILER_FLAG ( C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs )
2020-02-20 11:06:40 +01:00
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNDEFINED_VAR_TEMPLATE -Wno-undefined-var-template )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_INSTANTIATION_AFTER_SPECIALIZATION -Wno-instantiation-after-specialization )
2013-07-15 10:26:16 +02:00
2010-12-16 10:55:35 +01:00
elseif ( CMAKE_C_COMPILER_ID MATCHES "Intel" )
2019-04-17 06:35:54 +02:00
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_ALL -Wall )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith )
ADD_CHECK_C_COMPILER_FLAG ( C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas )
2010-12-16 10:55:35 +01:00
2019-04-17 06:35:54 +02:00
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_ALL -Wall )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof )
ADD_CHECK_CXX_COMPILER_FLAG ( CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare )
2010-12-16 10:55:35 +01:00
2019-04-17 06:35:54 +02:00
# disable numbered, false positives
set ( C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199" )
set ( CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199" )
2014-11-08 21:17:04 +01:00
elseif ( CMAKE_C_COMPILER_ID MATCHES "MSVC" )
2019-04-17 06:35:54 +02:00
# most msvc warnings are C & C++
set ( _WARNINGS
# warning level:
" / W 3 "
" / w 3 4 0 6 2 " # switch statement contains 'default' but no 'case' labels
" / w 3 4 1 1 5 " # 'type' : named type definition in parentheses
" / w 3 4 1 8 9 " # local variable is initialized but not referenced
# disable:
" / w d 4 0 1 8 " # signed/unsigned mismatch
" / w d 4 1 4 6 " # unary minus operator applied to unsigned type, result still unsigned
" / w d 4 0 6 5 " # switch statement contains 'default' but no 'case' labels
" / w d 4 1 2 7 " # conditional expression is constant
" / w d 4 1 8 1 " # qualifier applied to reference type; ignored
" / w d 4 2 0 0 " # zero-sized array in struct/union
" / w d 4 2 4 4 " # conversion from 'type1' to 'type2', possible loss of data
" / w d 4 2 6 7 " # conversion from 'size_t' to 'type', possible loss of data
" / w d 4 3 0 5 " # truncation from 'type1' to 'type2'
" / w d 4 8 0 0 " # forcing value to bool 'true' or 'false'
" / w d 4 8 2 8 " # The file contains a character that is illegal
" / w d 4 9 9 6 " # identifier was declared deprecated
2019-05-27 00:13:31 +02:00
" / w d 4 6 6 1 " # no suitable definition provided for explicit template instantiation request
2019-04-17 06:35:54 +02:00
# errors:
" / w e 4 0 1 3 " # 'function' undefined; assuming extern returning int
" / w e 4 1 3 3 " # incompatible pointer types
" / w e 4 4 3 1 " # missing type specifier - int assumed
)
if ( MSVC_VERSION GREATER_EQUAL 1911 )
# see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017
2019-10-28 15:32:33 +01:00
set ( _WARNINGS "${_WARNINGS} /w35038" ) # order of initialization in c++ constructors
2019-04-17 06:35:54 +02:00
endif ( )
string ( REPLACE ";" " " _WARNINGS "${_WARNINGS}" )
set ( C_WARNINGS "${_WARNINGS}" )
set ( CXX_WARNINGS "${_WARNINGS}" )
unset ( _WARNINGS )
2010-12-08 09:43:06 +01:00
endif ( )
2010-10-17 08:38:56 +02:00
2011-07-16 08:55:45 +02:00
# ensure python header is found since detection can fail, this could happen
# with _any_ library but since we used a fixed python version this tends to
# be most problematic.
if ( WITH_PYTHON )
2019-04-17 06:35:54 +02:00
if ( NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h" )
message ( FATAL_ERROR
" M i s s i n g : \ " $ { P Y T H O N _ I N C L U D E _ D I R } / P y t h o n . h \ " , \ n "
" S e t t h e c a c h e e n t r y ' P Y T H O N _ I N C L U D E _ D I R ' t o p o i n t "
" t o a v a l i d p y t h o n i n c l u d e p a t h . C o n t a i n i n g "
" P y t h o n . h f o r p y t h o n v e r s i o n \ " $ { P Y T H O N _ V E R S I O N } \ " "
)
endif ( )
if ( WIN32 OR APPLE )
# Windows and macOS have this bundled with Python libraries.
elseif ( ( WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY ) OR ( WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE ) )
if ( ( "${PYTHON_NUMPY_PATH}" STREQUAL "" ) OR ( ${ PYTHON_NUMPY_PATH } MATCHES NOTFOUND ) )
find_python_package ( numpy )
unset ( PYTHON_NUMPY_INCLUDE_DIRS CACHE )
set ( PYTHON_NUMPY_INCLUDE_DIRS ${ PYTHON_NUMPY_PATH } /numpy/core/include CACHE PATH "Path to the include directory of the numpy module" )
mark_as_advanced ( PYTHON_NUMPY_INCLUDE_DIRS )
endif ( )
endif ( )
if ( WIN32 OR APPLE )
# pass, we have this in lib/python/site-packages
elseif ( WITH_PYTHON_INSTALL_REQUESTS )
find_python_package ( requests )
endif ( )
2011-07-16 08:55:45 +02:00
endif ( )
2019-10-01 20:36:11 +02:00
if ( MSVC )
2020-06-18 11:01:52 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17" )
2019-10-01 20:36:11 +02:00
elseif (
2019-04-17 06:35:54 +02:00
C M A K E _ C O M P I L E R _ I S _ G N U C C O R
C M A K E _ C _ C O M P I L E R _ I D M A T C H E S " C l a n g " O R
C M A K E _ C _ C O M P I L E R _ I D M A T C H E S " I n t e l "
2018-07-25 16:59:46 +02:00
)
2020-06-18 11:01:52 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17" )
2016-05-22 13:41:55 +02:00
else ( )
2020-06-19 14:44:03 +02:00
message ( FATAL_ERROR "Unknown compiler ${CMAKE_C_COMPILER_ID}, can't enable C++17 build" )
2015-02-09 18:23:21 +01:00
endif ( )
2015-11-22 22:31:29 +01:00
# Visual Studio has all standards it supports available by default
Windows: Add support for building with clang.
This commit contains the minimum to make clang build/work with blender, asan and ninja build support is forthcoming
Things to note:
1) Builds and runs, and is able to pass all tests (except for the freestyle_stroke_material.blend test which was broken at that time for all platforms by the looks of it)
2) It's slightly faster than msvc when using cycles. (time in seconds, on an i7-3370)
victor_cpu
msvc:3099.51
clang:2796.43
pavillon_barcelona_cpu
msvc:1872.05
clang:1827.72
koro_cpu
msvc:1097.58
clang:1006.51
fishy_cat_cpu
msvc:815.37
clang:722.2
classroom_cpu
msvc:1705.39
clang:1575.43
bmw27_cpu
msvc:552.38
clang:561.53
barbershop_interior_cpu
msvc:2134.93
clang:1922.33
3) clang on windows uses a drop in replacement for the Microsoft cl.exe (takes some of the Microsoft parameters, but not all, and takes some of the clang parameters but not all) and uses ms headers + libraries + linker, so you still need visual studio installed and will use our existing vc14 svn libs.
4) X64 only currently, X86 builds but crashes on startup.
5) Tested with llvm/clang 6.0.0
6) Requires visual studio integration, available at https://github.com/LazyDodo/llvm-vs2017-integration
7) The Microsoft compiler spawns a few copies of cl in parallel to get faster build times, clang doesn't, so the build time is 3-4x slower than with msvc.
8) No openmp support yet. Have not looked at this much, the binary distribution of clang doesn't seem to include it on windows.
9) No ASAN support yet, some of the sanitizers can be made to work, but it was decided to leave support out of this commit.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D3304
2018-05-28 22:34:47 +02:00
# Clang on windows copies this behavior and does not support these switches
if (
2019-04-17 06:35:54 +02:00
C M A K E _ C O M P I L E R _ I S _ G N U C C O R
( C M A K E _ C _ C O M P I L E R _ I D M A T C H E S " C l a n g " AND ( NOT MSVC ) ) O R
( C M A K E _ C _ C O M P I L E R _ I D M A T C H E S " I n t e l " )
Windows: Add support for building with clang.
This commit contains the minimum to make clang build/work with blender, asan and ninja build support is forthcoming
Things to note:
1) Builds and runs, and is able to pass all tests (except for the freestyle_stroke_material.blend test which was broken at that time for all platforms by the looks of it)
2) It's slightly faster than msvc when using cycles. (time in seconds, on an i7-3370)
victor_cpu
msvc:3099.51
clang:2796.43
pavillon_barcelona_cpu
msvc:1872.05
clang:1827.72
koro_cpu
msvc:1097.58
clang:1006.51
fishy_cat_cpu
msvc:815.37
clang:722.2
classroom_cpu
msvc:1705.39
clang:1575.43
bmw27_cpu
msvc:552.38
clang:561.53
barbershop_interior_cpu
msvc:2134.93
clang:1922.33
3) clang on windows uses a drop in replacement for the Microsoft cl.exe (takes some of the Microsoft parameters, but not all, and takes some of the clang parameters but not all) and uses ms headers + libraries + linker, so you still need visual studio installed and will use our existing vc14 svn libs.
4) X64 only currently, X86 builds but crashes on startup.
5) Tested with llvm/clang 6.0.0
6) Requires visual studio integration, available at https://github.com/LazyDodo/llvm-vs2017-integration
7) The Microsoft compiler spawns a few copies of cl in parallel to get faster build times, clang doesn't, so the build time is 3-4x slower than with msvc.
8) No openmp support yet. Have not looked at this much, the binary distribution of clang doesn't seem to include it on windows.
9) No ASAN support yet, some of the sanitizers can be made to work, but it was decided to leave support out of this commit.
Reviewers: campbellbarton
Differential Revision: https://developer.blender.org/D3304
2018-05-28 22:34:47 +02:00
)
2019-04-17 06:35:54 +02:00
# Use C11 + GNU extensions, works with GCC, Clang, ICC
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11" )
2015-11-22 17:12:54 +01:00
endif ( )
2019-10-09 17:14:00 +02:00
if ( UNIX AND NOT APPLE )
if ( NOT WITH_CXX11_ABI )
set ( PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0" )
endif ( )
endif ( )
2012-10-20 15:08:51 +02:00
# Include warnings first, so its possible to disable them with user defined flags
# eg: -Wno-uninitialized
set ( CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}" )
set ( CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}" )
2009-10-19 18:20:12 +02:00
2017-04-27 13:40:18 +02:00
# defined above, platform specific but shared names
2013-08-28 06:32:39 +02:00
mark_as_advanced (
2019-04-17 06:35:54 +02:00
C Y C L E S _ O S L
O S L _ L I B _ E X E C
O S L _ C O M P I L E R
O S L _ L I B _ C O M P
O S L _ L I B _ Q U E R Y
O S L _ I N C L U D E _ D I R
2013-08-28 06:32:39 +02:00
)
mark_as_advanced (
2019-04-17 06:35:54 +02:00
L L V M _ C O N F I G
L L V M _ R O O T _ D I R
L L V M _ L I B R A R Y
L L V M _ V E R S I O N
2013-08-28 06:32:39 +02:00
)
2011-02-21 00:39:29 +01:00
#-------------------------------------------------------------------------------
# Global Defines
2011-05-24 08:44:39 +02:00
# better not set includes here but this debugging option is off by default.
2010-12-08 09:43:06 +01:00
if ( WITH_CXX_GUARDEDALLOC )
2019-04-17 06:35:54 +02:00
include_directories ( ${ CMAKE_SOURCE_DIR } /intern/guardedalloc )
add_definitions ( -DWITH_CXX_GUARDEDALLOC )
2010-12-08 09:43:06 +01:00
endif ( )
2006-11-17 03:27:12 +01:00
2010-12-15 11:22:26 +01:00
if ( WITH_ASSERT_ABORT )
2019-04-17 06:35:54 +02:00
add_definitions ( -DWITH_ASSERT_ABORT )
2010-12-15 11:22:26 +01:00
endif ( )
2010-12-16 13:48:30 +01:00
# message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
# message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
2006-11-17 03:27:12 +01:00
#-----------------------------------------------------------------------------
# Libraries
2010-12-06 11:56:37 +01:00
2018-04-16 15:54:36 +02:00
if ( WITH_BLENDER )
2019-04-17 06:35:54 +02:00
add_subdirectory ( intern )
add_subdirectory ( extern )
2014-06-18 14:49:17 +02:00
2019-04-17 06:35:54 +02:00
# source after intern and extern to gather all
# internal and external library information first, for test linking
add_subdirectory ( source )
2014-01-20 20:41:54 +01:00
elseif ( WITH_CYCLES_STANDALONE )
2019-04-17 06:35:54 +02:00
add_subdirectory ( intern/cycles )
add_subdirectory ( extern/clew )
if ( WITH_CUDA_DYNLOAD )
add_subdirectory ( extern/cuew )
endif ( )
if ( NOT WITH_SYSTEM_GLEW )
add_subdirectory ( extern/glew )
endif ( )
2014-01-20 20:41:54 +01:00
endif ( )
2006-11-17 03:27:12 +01:00
#-----------------------------------------------------------------------------
# Blender Application
2011-07-13 10:15:06 +02:00
if ( WITH_BLENDER )
2019-04-17 06:35:54 +02:00
add_subdirectory ( source/creator )
2011-07-13 10:15:06 +02:00
endif ( )
2006-11-17 03:27:12 +01:00
2008-09-09 23:15:30 +02:00
2014-06-18 13:44:40 +02:00
#-----------------------------------------------------------------------------
# Testing
add_subdirectory ( tests )
CMake: Add support of Ninja's pools to ease building on limited amount of RAM.
Many modern computers support a lot of threads (parrallel building
jobs), but are somewhat restricted in memory, when some building jobs
can require several GB each.
Ninja builder has pools, which extend the usual `-j X` make
parallelizing option, by allowing to specify different numbers of
parallel jobs for different targets.
This commit defines three pools, one for linking, one for usual compile,
and one for compiling some 'heavy' cpp libs, when a single file can
require GB of RAM in full debug builds.
Simply enabling WITH_NINJA_POOL_JOBS will try to set default sensible
values for those three pools based on your machine specifications, you
can then tweak further the values of NINJA_MAX_NUM_PARALLEL_ settings,
if you like.
On my system (8 cores, 16GB RAM), it allows to build a full debug with
all ASAN options build with roughly 7GB of RAM used at most, pretty much
as quickly as without that option (which would require up to 11GB of
available RAM at some points).
Review task: D4780.
2019-05-07 20:32:14 +02:00
#-----------------------------------------------------------------------------
# Define 'heavy' submodules (for Ninja builder when using pools).
setup_heavy_lib_pool ( )
2011-02-15 19:33:05 +01:00
#-----------------------------------------------------------------------------
# CPack for generating packages
include ( build_files/cmake/packaging.cmake )
2011-06-19 15:49:20 +02:00
2016-07-18 15:16:45 +02:00
#-----------------------------------------------------------------------------
# Use dynamic loading for OpenMP
if ( WITH_BLENDER )
2019-04-17 06:35:54 +02:00
openmp_delayload ( blender )
2017-10-30 02:58:44 +01:00
endif ( )
2011-06-19 15:49:20 +02:00
#-----------------------------------------------------------------------------
# Print Final Configuration
if ( FIRST_RUN )
2015-06-17 01:16:17 +02:00
2019-04-17 06:35:54 +02:00
set ( _config_msg "\nBlender Configuration\n=====================" )
function ( info_cfg_option
_ s e t t i n g
)
set ( _msg " - ${_setting}" )
string ( LENGTH "${_msg}" _len )
while ( "32" GREATER "${_len}" )
set ( _msg "${_msg} " )
math ( EXPR _len "${_len} + 1" )
endwhile ( )
set ( _config_msg "${_config_msg}\n${_msg}${${_setting}}" PARENT_SCOPE )
endfunction ( )
function ( info_cfg_text
_ t e x t
)
set ( _config_msg "${_config_msg}\n\n ${_text}" PARENT_SCOPE )
endfunction ( )
message ( STATUS "C Compiler: \" ${ CMAKE_C_COMPILER_ID } \"")
message ( STATUS "C++ Compiler: \" ${ CMAKE_CXX_COMPILER_ID } \"")
info_cfg_text ( "Build Options:" )
info_cfg_option ( WITH_BULLET )
info_cfg_option ( WITH_IK_SOLVER )
info_cfg_option ( WITH_IK_ITASC )
info_cfg_option ( WITH_OPENCOLLADA )
info_cfg_option ( WITH_FFTW3 )
info_cfg_option ( WITH_INTERNATIONAL )
info_cfg_option ( WITH_INPUT_NDOF )
info_cfg_option ( WITH_CYCLES )
info_cfg_option ( WITH_FREESTYLE )
info_cfg_option ( WITH_OPENCOLORIO )
2020-03-04 16:39:00 +01:00
info_cfg_option ( WITH_XR_OPENXR )
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
info_cfg_option ( WITH_OPENIMAGEDENOISE )
2019-04-17 06:35:54 +02:00
info_cfg_option ( WITH_OPENVDB )
info_cfg_option ( WITH_ALEMBIC )
2019-08-26 18:34:11 +02:00
info_cfg_option ( WITH_QUADRIFLOW )
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
info_cfg_option ( WITH_USD )
2020-05-04 23:58:48 +02:00
info_cfg_option ( WITH_TBB )
2019-04-17 06:35:54 +02:00
info_cfg_text ( "Compiler Options:" )
info_cfg_option ( WITH_BUILDINFO )
info_cfg_option ( WITH_OPENMP )
info_cfg_text ( "System Options:" )
info_cfg_option ( WITH_INSTALL_PORTABLE )
info_cfg_option ( WITH_X11_ALPHA )
info_cfg_option ( WITH_X11_XF86VMODE )
info_cfg_option ( WITH_X11_XFIXES )
info_cfg_option ( WITH_X11_XINPUT )
info_cfg_option ( WITH_MEM_JEMALLOC )
info_cfg_option ( WITH_MEM_VALGRIND )
info_cfg_option ( WITH_SYSTEM_GLEW )
info_cfg_text ( "Image Formats:" )
info_cfg_option ( WITH_OPENIMAGEIO )
info_cfg_option ( WITH_IMAGE_CINEON )
info_cfg_option ( WITH_IMAGE_DDS )
info_cfg_option ( WITH_IMAGE_HDR )
info_cfg_option ( WITH_IMAGE_OPENEXR )
info_cfg_option ( WITH_IMAGE_OPENJPEG )
info_cfg_option ( WITH_IMAGE_TIFF )
info_cfg_text ( "Audio:" )
info_cfg_option ( WITH_OPENAL )
info_cfg_option ( WITH_SDL )
info_cfg_option ( WITH_SDL_DYNLOAD )
info_cfg_option ( WITH_JACK )
info_cfg_option ( WITH_JACK_DYNLOAD )
info_cfg_option ( WITH_CODEC_AVI )
info_cfg_option ( WITH_CODEC_FFMPEG )
info_cfg_option ( WITH_CODEC_SNDFILE )
info_cfg_text ( "Compression:" )
info_cfg_option ( WITH_LZMA )
info_cfg_option ( WITH_LZO )
info_cfg_text ( "Python:" )
info_cfg_option ( WITH_PYTHON_INSTALL )
info_cfg_option ( WITH_PYTHON_INSTALL_NUMPY )
info_cfg_option ( WITH_PYTHON_MODULE )
info_cfg_option ( WITH_PYTHON_SAFETY )
if ( APPLE )
info_cfg_option ( WITH_PYTHON_FRAMEWORK )
endif ( )
info_cfg_text ( "Modifiers:" )
info_cfg_option ( WITH_MOD_REMESH )
info_cfg_option ( WITH_MOD_FLUID )
info_cfg_option ( WITH_MOD_OCEANSIM )
info_cfg_text ( "OpenGL:" )
info_cfg_option ( WITH_GLEW_ES )
info_cfg_option ( WITH_GL_EGL )
info_cfg_option ( WITH_GL_PROFILE_ES20 )
if ( WIN32 )
info_cfg_option ( WITH_GL_ANGLE )
endif ( )
info_cfg_text ( "" )
message ( "${_config_msg}" )
2011-06-19 15:49:20 +02:00
endif ( )
2014-11-16 12:57:42 +01:00
if ( 0 )
2019-04-17 06:35:54 +02:00
print_all_vars ( )
2014-11-16 12:57:42 +01:00
endif ( )