diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-03-07 19:22:48 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-03-07 19:22:48 +0300 |
commit | 0ef5c14de0413dd6b81b94338d70079513da1a48 (patch) | |
tree | ab354fb8d5f4307985052fe35ae21e175584d5b4 /CMakeLists.txt | |
parent | 26fd1c71e1f76938b8291148bcdc2441f5f5cd49 (diff) | |
parent | 400f2e4be67b8db1b85cacdcc21ca4c2d7bda2b3 (diff) |
Merge branch 'master' into tmp-vulkan
# Conflicts:
# source/blender/blenkernel/BKE_global.h
# source/blender/gpu/intern/gpu_context.cc
# source/blender/windowmanager/intern/wm_window.c
# source/creator/creator_args.c
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 332 |
1 files changed, 226 insertions, 106 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a3ed069f304..7dd1a6cd879 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,8 +43,8 @@ endif() cmake_minimum_required(VERSION 3.10) -# 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 +# Prefer LEGACY OpenGL to be compatible with all the existing releases and +# platforms which don't have GLVND yet. Only do it if preference was not set # externally. if(NOT DEFINED OpenGL_GL_PREFERENCE) set(OpenGL_GL_PREFERENCE "LEGACY") @@ -63,6 +63,9 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/platform") # avoid having empty buildtype if(NOT DEFINED CMAKE_BUILD_TYPE_INIT) set(CMAKE_BUILD_TYPE_INIT "Release") + # Internal logic caches this variable, avoid showing it by default + # since it's easy to accidentally set instead of the build type. + mark_as_advanced(CMAKE_BUILD_TYPE_INIT) endif() # Omit superfluous "Up-to-date" messages. @@ -164,10 +167,6 @@ if(APPLE) endif() option(WITH_BUILDINFO "Include extra build details (only disable for development & faster builds)" ON) -if(${CMAKE_VERSION} VERSION_LESS 2.8.8) - # add_library OBJECT arg unsupported - set(WITH_BUILDINFO OFF) -endif() 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)") set(CPACK_OVERRIDE_PACKAGENAME "" CACHE STRING "Use instead of the standard packagename (empty string disables this option)") @@ -178,6 +177,7 @@ mark_as_advanced(BUILDINFO_OVERRIDE_TIME) option(WITH_IK_ITASC "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON) option(WITH_IK_SOLVER "Enable Legacy IK solver (only disable for development)" ON) option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke, ocean sim, and audio effects)" ON) +option(WITH_PUGIXML "Enable PugiXML support (Used for OpenImageIO, Grease Pencil SVG export)" ON) option(WITH_BULLET "Enable Bullet (Physics Engine)" ON) option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" ) mark_as_advanced(WITH_SYSTEM_BULLET) @@ -198,11 +198,13 @@ option(WITH_OPENIMAGEDENOISE "Enable the OpenImageDenoise compositing node" ON option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" ON) -option(WITH_POTRACE "Enable features relying on potrace" OFF) +option(WITH_POTRACE "Enable features relying on potrace" ON) 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) 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) +option(WITH_NANOVDB "Enable usage of NanoVDB data structure for rendering on the GPU" ON) +option(WITH_HARU "Enable features relying on Libharu (Grease pencil PDF export)" ON) # GHOST Windowing Library Options option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF) @@ -223,8 +225,6 @@ if(WITH_GHOST_X11) option(WITH_GHOST_XDND "Enable drag'n'drop support on X11 using XDND protocol" ON) endif() -option(WITH_GMP "Use the gmp library for more accurate booleans" OFF) - # Misc... option(WITH_HEADLESS "Build without graphical support (renderfarm, server mode only)" OFF) mark_as_advanced(WITH_HEADLESS) @@ -347,16 +347,21 @@ if(UNIX AND NOT APPLE) endif() option(WITH_PYTHON_INSTALL "Copy system python into the blender install folder" ON) + +if((WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE) OR WITH_MOD_FLUID) + option(WITH_PYTHON_NUMPY "Include NumPy in Blender (used by Audaspace and Mantaflow)" ON) +endif() + if(WIN32 OR APPLE) # Windows and macOS have this bundled with Python libraries. -elseif(WITH_PYTHON_INSTALL OR (WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE)) +elseif(WITH_PYTHON_INSTALL OR WITH_PYTHON_NUMPY) 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") + set(PYTHON_NUMPY_INCLUDE_DIRS "" CACHE PATH "Path to the include directory of the NumPy module") mark_as_advanced(PYTHON_NUMPY_INCLUDE_DIRS) endif() if(WITH_PYTHON_INSTALL) - option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder" ON) + option(WITH_PYTHON_INSTALL_NUMPY "Copy system NumPy into the blender install folder" ON) if(UNIX AND NOT APPLE) option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON) @@ -365,8 +370,8 @@ if(WITH_PYTHON_INSTALL) endif() endif() -option(WITH_CPU_SSE "Enable SIMD instruction if they're detected on the host machine" ON) -mark_as_advanced(WITH_CPU_SSE) +option(WITH_CPU_SIMD "Enable SIMD instruction if they're detected on the host machine" ON) +mark_as_advanced(WITH_CPU_SIMD) # Cycles option(WITH_CYCLES "Enable Cycles Render Engine" ON) @@ -378,7 +383,8 @@ 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) 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) -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") +set(CYCLES_TEST_DEVICES CPU CACHE STRING "Run regression tests on the specified device types (CPU CUDA OPTIX OPENCL)" ) +set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 sm_75 sm_86 compute_75 CACHE STRING "CUDA architectures to build binaries for") mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH) unset(PLATFORM_DEFAULT) option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON) @@ -410,6 +416,7 @@ else() option(LLVM_STATIC "Link with LLVM static libraries" OFF) endif() mark_as_advanced(LLVM_STATIC) +option(WITH_CLANG "Use Clang" OFF) # disable for now, but plan to support on all platforms eventually option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" ON) @@ -426,8 +433,8 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC) option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" ON) mark_as_advanced(WITH_ASSERT_ABORT) -if(UNIX AND NOT APPLE) - option(WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Linux using Clang)" OFF) +if((UNIX AND NOT APPLE) OR (CMAKE_GENERATOR MATCHES "^Visual Studio.+")) + option(WITH_CLANG_TIDY "Use Clang Tidy to analyze the source code (only enable for development on Linux using Clang, or Windows using the Visual Studio IDE)" OFF) mark_as_advanced(WITH_CLANG_TIDY) endif() @@ -530,10 +537,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") # Silence the warning that object-size is not effective in -O0. set(_asan_defaults "${_asan_defaults}") else() - set(_asan_defaults "${_asan_defaults} -fsanitize=object-size") + string(APPEND _asan_defaults " -fsanitize=object-size") endif() else() - set(_asan_defaults "${_asan_defaults} -fsanitize=leak -fsanitize=object-size") + string(APPEND _asan_defaults " -fsanitize=leak -fsanitize=object-size") endif() set(COMPILER_ASAN_CFLAGS "${_asan_defaults}" CACHE STRING "C flags for address sanitizer") @@ -574,6 +581,11 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") endif() endif() +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + option(WITH_COMPILER_SHORT_FILE_MACRO "Make paths in macros like __FILE__ relative to top level source and build directories." ON) + mark_as_advanced(WITH_COMPILER_SHORT_FILE_MACRO) +endif() + if(WIN32) # Use hardcoded paths or find_package to find externals option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF) @@ -602,6 +614,12 @@ if(WIN32) endif() +if(UNIX) + # See WITH_WINDOWS_SCCACHE for Windows. + option(WITH_COMPILER_CCACHE "Use ccache to improve rebuild times (Works with Ninja, Makefiles and Xcode)" OFF) + mark_as_advanced(WITH_COMPILER_CCACHE) +endif() + # The following only works with the Ninja generator in CMake >= 3.0. if("${CMAKE_GENERATOR}" MATCHES "Ninja") option(WITH_NINJA_POOL_JOBS @@ -696,6 +714,8 @@ 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) set_and_warn_dependency(WITH_BOOST WITH_ALEMBIC OFF) +set_and_warn_dependency(WITH_PUGIXML WITH_CYCLES_OSL OFF) +set_and_warn_dependency(WITH_PUGIXML WITH_OPENIMAGEIO OFF) if(WITH_BOOST AND NOT (WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR WITH_OPENVDB OR WITH_OPENCOLORIO OR WITH_USD OR WITH_ALEMBIC)) @@ -709,8 +729,15 @@ 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) -# OpenVDB uses 'half' type from OpenEXR & fails to link without OpenEXR enabled. +# NanoVDB requires OpenVDB to convert the data structure +set_and_warn_dependency(WITH_OPENVDB WITH_NANOVDB OFF) + +# OpenVDB and OpenColorIO uses 'half' type from OpenEXR set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENVDB OFF) +set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENCOLORIO OFF) + +# Haru needs `TIFFFaxBlackCodes` & `TIFFFaxWhiteCodes` symbols from TIFF. +set_and_warn_dependency(WITH_IMAGE_TIFF WITH_HARU OFF) # auto enable openimageio for cycles if(WITH_CYCLES) @@ -719,6 +746,7 @@ if(WITH_CYCLES) # auto enable llvm for cycles_osl if(WITH_CYCLES_OSL) set(WITH_LLVM ON CACHE BOOL "" FORCE) + set(WITH_CLANG ON CACHE BOOL "" FORCE) endif() else() set(WITH_CYCLES_OSL OFF) @@ -752,14 +780,6 @@ if(WITH_GHOST_SDL OR WITH_HEADLESS) set(WITH_XR_OPENXR OFF) endif() -if(WITH_CPU_SSE) - TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG) -else() - message(STATUS "SSE and SSE2 optimizations are DISABLED!") - set(COMPILER_SSE_FLAG) - set(COMPILER_SSE2_FLAG) -endif() - if(WITH_BUILDINFO) find_package(Git) if(NOT GIT_FOUND) @@ -808,8 +828,8 @@ if(WITH_PYTHON) # 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") + if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.9") + message(FATAL_ERROR "At least Python 3.9 is required to build") endif() file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/scripts/addons") @@ -843,11 +863,10 @@ set(CXX_WARNINGS) set(C_REMOVE_STRICT_FLAGS) set(CXX_REMOVE_STRICT_FLAGS) -# libraries to link the binary with passed to target_link_libraries() -# known as LLIBS to scons +# Libraries to link to targets in setup_platform_linker_libs set(PLATFORM_LINKLIBS "") -# Added to linker flags in setup_liblinks +# Added to target linker flags in setup_platform_linker_flags # - CMAKE_EXE_LINKER_FLAGS # - CMAKE_EXE_LINKER_FLAGS_DEBUG set(PLATFORM_LINKFLAGS "") @@ -855,21 +874,29 @@ set(PLATFORM_LINKFLAGS_DEBUG "") if(NOT CMAKE_BUILD_TYPE MATCHES "Release") 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}") - - 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(NOT APPLE) + # Avoid passing address sanitizer compiler flags to `try_compile`. + # Since linker flags are not set, all compiler checks and `find_package` + # calls that rely on `try_compile` will fail. + # See CMP0066 also. + string(APPEND CMAKE_C_FLAGS_DEBUG " ${COMPILER_ASAN_CFLAGS}") + string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " ${COMPILER_ASAN_CFLAGS}") + + string(APPEND CMAKE_CXX_FLAGS_DEBUG " ${COMPILER_ASAN_CXXFLAGS}") + string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " ${COMPILER_ASAN_CXXFLAGS}") + endif() if(MSVC) set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6") endif() - if(APPLE) - # COMPILER_ASAN_CFLAGS and COMPILER_ASAN_CXXFLAGS are the same as of - # now, so use either for PLATFORM_CFLAGS. - set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${COMPILER_ASAN_CFLAGS}") - set(COMPILER_ASAN_LINKER_FLAGS "-fno-omit-frame-pointer -fsanitize=address") - endif(APPLE) - if(COMPILER_ASAN_LIBRARY) + + if(APPLE AND COMPILER_ASAN_LIBRARY) + string(REPLACE " " ";" _list_COMPILER_ASAN_CFLAGS ${COMPILER_ASAN_CFLAGS}) + set(_is_CONFIG_DEBUG "$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>") + add_compile_options("$<${_is_CONFIG_DEBUG}:${_list_COMPILER_ASAN_CFLAGS}>") + add_link_options("$<${_is_CONFIG_DEBUG}:-fno-omit-frame-pointer;-fsanitize=address>") + unset(_list_COMPILER_ASAN_CFLAGS) + unset(_is_CONFIG_DEBUG) + elseif(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}") @@ -932,22 +959,55 @@ if(WITH_INTERNATIONAL) endif() endif() -# See TEST_SSE_SUPPORT() for how this is defined. +# See TEST_SSE_SUPPORT() and TEST_NEON_SUPPORT() for how these are defined. +# +# This is done globally, so that all modules can use it if available, and +# because these are used in headers used by many modules. +if(WITH_CPU_SIMD) + set(COMPILER_SSE_FLAG) + set(COMPILER_SSE2_FLAG) -# 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) - set(PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}") - add_definitions(-D__SSE__ -D__MMX__) -endif() -if(SUPPORT_SSE2_BUILD) - 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__) + # Test Neon first since macOS Arm can compile and run x86-64 SSE binaries. + TEST_NEON_SUPPORT() + if(SUPPORT_NEON_BUILD) + # Neon + if(SSE2NEON_FOUND) + blender_include_dirs_sys("${SSE2NEON_INCLUDE_DIRS}") + add_definitions(-DWITH_SSE2NEON) + endif() + else() + # SSE + TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG) + if(SUPPORT_SSE_BUILD) + string(PREPEND PLATFORM_CFLAGS "${COMPILER_SSE_FLAG} ") + add_definitions(-D__SSE__ -D__MMX__) + endif() + if(SUPPORT_SSE2_BUILD) + string(APPEND PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG}") + add_definitions(-D__SSE2__) + if(NOT SUPPORT_SSE_BUILD) # don't double up + add_definitions(-D__MMX__) + endif() + endif() endif() -endif() + # Print instructions used + if(SUPPORT_NEON_BUILD) + if(SSE2NEON_FOUND) + message(STATUS "Neon SIMD instructions enabled") + else() + message(STATUS "Neon SIMD instructions detected but unused, requires sse2neon") + endif() + elseif(SUPPORT_SSE2_BUILD) + message(STATUS "SSE2 SIMD instructions enabled") + elseif(SUPPORT_SSE_BUILD) + message(STATUS "SSE SIMD instructions enabled") + else() + message(STATUS "No SIMD instructions detected") + endif() +else() + message(STATUS "SIMD instructions disabled") +endif() # set the endian define if(MSVC) @@ -993,6 +1053,9 @@ if(WITH_OPENVDB) list(APPEND OPENVDB_DEFINITIONS -DOPENVDB_3_ABI_COMPATIBLE) endif() + # OpenVDB headers use deprecated TBB headers, silence warning. + list(APPEND OPENVDB_DEFINITIONS -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1) + list(APPEND OPENVDB_INCLUDE_DIRS ${BOOST_INCLUDE_DIR} ${TBB_INCLUDE_DIRS} @@ -1164,8 +1227,9 @@ if(WITH_OPENMP) 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}") + string(APPEND CMAKE_C_FLAGS " ${OpenMP_C_FLAGS}") + string(APPEND CMAKE_CXX_FLAGS " ${OpenMP_CXX_FLAGS}") + string(APPEND CMAKE_EXE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}") else() # Typically avoid adding flags as defines but we can't # pass OpenMP flags to the linker for static builds, meaning @@ -1419,6 +1483,7 @@ if(CMAKE_COMPILER_IS_GNUCC) # 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) + ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized) endif() # versions before gcc4.6 give many BLI_math warnings @@ -1482,10 +1547,14 @@ if(CMAKE_COMPILER_IS_GNUCC) 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_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable) + ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized) 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) + ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable) + ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized) 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) @@ -1524,6 +1593,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") 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_VARIABLE -Wno-unused-variable) 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_MISLEADING_INDENTATION -Wno-misleading-indentation) 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) @@ -1534,15 +1604,18 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") 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_PARAMETER -Wno-unused-parameter) 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_UNUSED_VARIABLE -Wno-unused-variable) 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) 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) + ADD_CHECK_CXX_COMPILER_FLAG(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation) elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") @@ -1555,8 +1628,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare) # 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") + string(APPEND C_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199") + string(APPEND CXX_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199") elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") # most msvc warnings are C & C++ set(_WARNINGS @@ -1587,7 +1660,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") if(MSVC_VERSION GREATER_EQUAL 1911) # see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038?view=vs-2017 - set(_WARNINGS "${_WARNINGS} /w35038") # order of initialization in c++ constructors + string(APPEND _WARNINGS " /w35038") # order of initialization in c++ constructors endif() string(REPLACE ";" " " _WARNINGS "${_WARNINGS}") @@ -1611,36 +1684,33 @@ if(WITH_PYTHON) 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)) + elseif((WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY) OR WITH_PYTHON_NUMPY) if(("${PYTHON_NUMPY_PATH}" STREQUAL "") OR (${PYTHON_NUMPY_PATH} MATCHES NOTFOUND)) - find_python_package(numpy) - 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) + find_python_package(numpy "core/include") endif() endif() if(WIN32 OR APPLE) # pass, we have this in lib/python/site-packages elseif(WITH_PYTHON_INSTALL_REQUESTS) - find_python_package(requests) + find_python_package(requests "") endif() endif() if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") + string(APPEND CMAKE_CXX_FLAGS " /std:c++17") # Make MSVC properly report the value of the __cplusplus preprocessor macro # Available MSVC 15.7 (1914) and up, without this it reports 199711L regardless # of the C++ standard chosen above if(MSVC_VERSION GREATER 1913) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") + string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus") endif() elseif( CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Intel" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + string(APPEND CMAKE_CXX_FLAGS " -std=c++17") else() message(FATAL_ERROR "Unknown compiler ${CMAKE_C_COMPILER_ID}, can't enable C++17 build") endif() @@ -1653,12 +1723,47 @@ if( (CMAKE_C_COMPILER_ID MATCHES "Intel") ) # Use C11 + GNU extensions, works with GCC, Clang, ICC - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") + string(APPEND CMAKE_C_FLAGS " -std=gnu11") endif() if(UNIX AND NOT APPLE) if(NOT WITH_CXX11_ABI) - set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") + string(APPEND PLATFORM_CFLAGS " -D_GLIBCXX_USE_CXX11_ABI=0") + endif() +endif() + +if(WITH_COMPILER_SHORT_FILE_MACRO) + # Use '-fmacro-prefix-map' for Clang and GCC (MSVC doesn't support this). + ADD_CHECK_C_COMPILER_FLAG(C_PREFIX_MAP_FLAGS C_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar) + ADD_CHECK_CXX_COMPILER_FLAG(CXX_PREFIX_MAP_FLAGS CXX_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar) + if(C_MACRO_PREFIX_MAP AND CXX_MACRO_PREFIX_MAP) + if(APPLE) + if(XCODE AND ${XCODE_VERSION} VERSION_LESS 12.0) + # Developers may have say LLVM Clang-10.0.1 toolchain (which supports the flag) + # with Xcode-11 (the Clang of which doesn't support the flag). + message(WARNING + "-fmacro-prefix-map flag is NOT supported by Clang shipped with Xcode-${XCODE_VERSION}." + " Some Xcode functionality in Product menu may not work. Disabling WITH_COMPILER_SHORT_FILE_MACRO." + ) + set(WITH_COMPILER_SHORT_FILE_MACRO OFF) + endif() + endif() + if(WITH_COMPILER_SHORT_FILE_MACRO) + path_ensure_trailing_slash(_src_dir "${CMAKE_SOURCE_DIR}") + path_ensure_trailing_slash(_bin_dir "${CMAKE_BINARY_DIR}") + # Keep this variable so it can be stripped from build-info. + set(PLATFORM_CFLAGS_FMACRO_PREFIX_MAP + "-fmacro-prefix-map=\"${_src_dir}\"=\"\" -fmacro-prefix-map=\"${_bin_dir}\"=\"\"") + string(APPEND PLATFORM_CFLAGS " ${PLATFORM_CFLAGS_FMACRO_PREFIX_MAP}") + unset(_src_dir) + unset(_bin_dir) + endif() + else() + message(WARNING + "-fmacro-prefix-map flag is NOT supported by C/C++ compiler." + " Disabling WITH_COMPILER_SHORT_FILE_MACRO." + ) + set(WITH_COMPILER_SHORT_FILE_MACRO OFF) endif() endif() @@ -1711,8 +1816,20 @@ if(WITH_BLENDER) # internal and external library information first, for test linking add_subdirectory(source) elseif(WITH_CYCLES_STANDALONE) + add_subdirectory(intern/glew-mx) + add_subdirectory(intern/guardedalloc) + add_subdirectory(intern/libc_compat) + add_subdirectory(intern/numaapi) + add_subdirectory(intern/sky) + add_subdirectory(intern/cycles) add_subdirectory(extern/clew) + if(WITH_CYCLES_LOGGING) + if(NOT WITH_SYSTEM_GFLAGS) + add_subdirectory(extern/gflags) + endif() + add_subdirectory(extern/glog) + endif() if(WITH_CUDA_DYNLOAD) add_subdirectory(extern/cuew) endif() @@ -1722,6 +1839,10 @@ elseif(WITH_CYCLES_STANDALONE) endif() #----------------------------------------------------------------------------- +# Testing +add_subdirectory(tests) + +#----------------------------------------------------------------------------- # Blender Application if(WITH_BLENDER) add_subdirectory(source/creator) @@ -1729,11 +1850,6 @@ endif() #----------------------------------------------------------------------------- -# Testing -add_subdirectory(tests) - - -#----------------------------------------------------------------------------- # Define 'heavy' submodules (for Ninja builder when using pools). setup_heavy_lib_pool() @@ -1762,7 +1878,7 @@ if(FIRST_RUN) set(_msg " - ${_setting}") string(LENGTH "${_msg}" _len) while("32" GREATER "${_len}") - set(_msg "${_msg} ") + string(APPEND _msg " ") math(EXPR _len "${_len} + 1") endwhile() @@ -1780,24 +1896,28 @@ if(FIRST_RUN) message(STATUS "C++ Compiler: \"${CMAKE_CXX_COMPILER_ID}\"") info_cfg_text("Build Options:") + info_cfg_option(WITH_ALEMBIC) 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_CLANG) info_cfg_option(WITH_CYCLES) + info_cfg_option(WITH_FFTW3) info_cfg_option(WITH_FREESTYLE) + info_cfg_option(WITH_GMP) + info_cfg_option(WITH_HARU) + info_cfg_option(WITH_IK_ITASC) + info_cfg_option(WITH_IK_SOLVER) + info_cfg_option(WITH_INPUT_NDOF) + info_cfg_option(WITH_INTERNATIONAL) + info_cfg_option(WITH_OPENCOLLADA) info_cfg_option(WITH_OPENCOLORIO) - info_cfg_option(WITH_XR_OPENXR) info_cfg_option(WITH_OPENIMAGEDENOISE) info_cfg_option(WITH_OPENVDB) - info_cfg_option(WITH_ALEMBIC) + info_cfg_option(WITH_POTRACE) + info_cfg_option(WITH_PUGIXML) info_cfg_option(WITH_QUADRIFLOW) - info_cfg_option(WITH_USD) info_cfg_option(WITH_TBB) - info_cfg_option(WITH_GMP) + info_cfg_option(WITH_USD) + info_cfg_option(WITH_XR_OPENXR) info_cfg_text("Compiler Options:") info_cfg_option(WITH_BUILDINFO) @@ -1805,58 +1925,58 @@ if(FIRST_RUN) info_cfg_text("System Options:") info_cfg_option(WITH_INSTALL_PORTABLE) + info_cfg_option(WITH_MEM_JEMALLOC) + info_cfg_option(WITH_MEM_VALGRIND) + info_cfg_option(WITH_SYSTEM_GLEW) info_cfg_option(WITH_X11_ALPHA) info_cfg_option(WITH_X11_XF86VMODE) info_cfg_option(WITH_X11_XFIXES) info_cfg_option(WITH_X11_XINPUT) - 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_option(WITH_OPENIMAGEIO) 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_option(WITH_JACK) + info_cfg_option(WITH_JACK_DYNLOAD) + info_cfg_option(WITH_OPENAL) + info_cfg_option(WITH_SDL) + info_cfg_option(WITH_SDL_DYNLOAD) info_cfg_text("Compression:") info_cfg_option(WITH_LZMA) info_cfg_option(WITH_LZO) info_cfg_text("Python:") + if(APPLE) + info_cfg_option(WITH_PYTHON_FRAMEWORK) + endif() info_cfg_option(WITH_PYTHON_INSTALL) info_cfg_option(WITH_PYTHON_INSTALL_NUMPY) info_cfg_option(WITH_PYTHON_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_option(WITH_MOD_REMESH) 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_option(WITH_GL_EGL) + info_cfg_option(WITH_GL_PROFILE_ES20) + info_cfg_option(WITH_GLEW_ES) info_cfg_text("") |