[Bf-blender-cvs] [885cc4cf9a1] master: Build: require C11/C++11 for all operating systems in master.
Brecht Van Lommel
noreply at git.blender.org
Mon Jul 30 18:36:59 CEST 2018
Commit: 885cc4cf9a1d5c167e4cbd26c3294d8b1ad400d8
Author: Brecht Van Lommel
Date: Wed Jul 25 16:59:46 2018 +0200
Branches: master
https://developer.blender.org/rB885cc4cf9a1d5c167e4cbd26c3294d8b1ad400d8
Build: require C11/C++11 for all operating systems in master.
This is in preparation of upgrading our library dependencies, some of which
need C++11. We already use C++11 in blender2.8 and for Windows and macOS, so
this just affects Linux.
On many distributions this will not require any changes, on some
install_deps.sh will need to be run again to rebuild libraries.
Differential Revision: https://developer.blender.org/D3568
===================================================================
M CMakeLists.txt
M build_files/build_environment/install_deps.sh
M build_files/cmake/macros.cmake
M build_files/cmake/platform/platform_apple_xcode.cmake
M build_files/cmake/platform/platform_win32.cmake
M intern/cycles/CMakeLists.txt
M intern/cycles/util/util_defines.h
M intern/cycles/util/util_foreach.h
M intern/cycles/util/util_function.h
M intern/cycles/util/util_map.h
M intern/cycles/util/util_set.h
M intern/cycles/util/util_static_assert.h
M intern/cycles/util/util_thread.cpp
M intern/cycles/util/util_thread.h
M intern/cycles/util/util_vector.h
M source/blender/alembic/intern/abc_customdata.cc
M source/blender/blenlib/BLI_compiler_compat.h
M source/blender/depsgraph/CMakeLists.txt
M source/blender/depsgraph/util/deg_util_foreach.h
M source/blender/depsgraph/util/deg_util_function.h
===================================================================
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b018905e4f..f6435316fec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -505,27 +505,6 @@ if(WIN32)
set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
endif()
-# Experimental support of C11 and C++11
-#
-# We default options to whatever default standard in the current compiler.
-if(APPLE)
- set(_c11_init ON)
- set(_cxx11_init ON)
- set(WITH_C11 ON)
- set(WITH_CXX11 ON)
-elseif(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
- set(_c11_init ON)
- set(_cxx11_init ON)
-else()
- set(_c11_init OFF)
- set(_cxx11_init OFF)
-endif()
-
-option(WITH_C11 "Build with C11 standard enabled, for development use only!" ${_c11_init})
-mark_as_advanced(WITH_C11)
-option(WITH_CXX11 "Build with C++11 standard enabled, for development use only!" ${_cxx11_init})
-mark_as_advanced(WITH_CXX11)
-
# Compiler toolchain
if(CMAKE_COMPILER_IS_GNUCC)
option(WITH_LINKER_GOLD "Use ld.gold linker which is usually faster than ld.bfd" ON)
@@ -703,11 +682,8 @@ elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL O
WITH_OPENVDB OR WITH_OPENCOLORIO)
# Keep enabled
else()
- # New dependency graph needs either Boost or C++11 for function bindings.
- if(NOT WITH_CXX11)
- # Enabled but we don't need it
- set(WITH_BOOST OFF)
- endif()
+ # Disable boost if not needed.
+ set(WITH_BOOST OFF)
endif()
# auto enable openimageio for cycles
@@ -764,9 +740,6 @@ if(WITH_BUILDINFO)
endif()
endif()
-TEST_SHARED_PTR_SUPPORT()
-TEST_UNORDERED_MAP_SUPPORT()
-
if(WITH_AUDASPACE)
if(WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_DEFINITIONS
@@ -1362,42 +1335,8 @@ endif()
# Configure Ceres
if(WITH_LIBMV)
- set(CERES_DEFINES)
-
- if(WITH_CXX11)
- # nothing to be done
- elseif(SHARED_PTR_FOUND)
- if(SHARED_PTR_TR1_MEMORY_HEADER)
- list(APPEND CERES_DEFINES -DCERES_TR1_MEMORY_HEADER)
- endif()
- if(SHARED_PTR_TR1_NAMESPACE)
- list(APPEND CERES_DEFINES -DCERES_TR1_SHARED_PTR)
- endif()
- else()
- message(FATAL_ERROR "Ceres: Unable to find shared_ptr.")
- endif()
-
- if(WITH_CXX11)
- list(APPEND CERES_DEFINES -DCERES_STD_UNORDERED_MAP)
- elseif(HAVE_STD_UNORDERED_MAP_HEADER)
- if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
- list(APPEND CERES_DEFINES -DCERES_STD_UNORDERED_MAP)
- else()
- if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
- list(APPEND CERES_DEFINES -DCERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)
- else()
- list(APPEND CERES_DEFINES -DCERES_NO_UNORDERED_MAP)
- message(STATUS "Ceres: Replacing unordered_map/set with map/set (warning: slower!)")
- endif()
- endif()
- else()
- if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
- list(APPEND CERES_DEFINES -DCERES_TR1_UNORDERED_MAP)
- else()
- list(APPEND CERES_DEFINES -DCERES_NO_UNORDERED_MAP)
- message(STATUS "Ceres: Replacing unordered_map/set with map/set (warning: slower!)")
- endif()
- endif()
+ # We always have C++11 which includes unordered_map.
+ set(CERES_DEFINES -DCERES_STD_UNORDERED_MAP)
endif()
#-----------------------------------------------------------------------------
@@ -1619,28 +1558,17 @@ if(WITH_PYTHON)
endif()
endif()
-if(WITH_CXX11)
- if(
- CMAKE_COMPILER_IS_GNUCC OR
- CMAKE_C_COMPILER_ID MATCHES "Clang" OR
- CMAKE_C_COMPILER_ID MATCHES "Intel"
- )
- # TODO(sergey): Do we want c++11 or gnu-c++11 here?
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- elseif(MSVC)
- # Nothing special is needed, C++11 features are available by default.
- else()
- message(FATAL_ERROR "Compiler ${CMAKE_C_COMPILER_ID} is not supported for C++11 build yet")
- endif()
+if(
+ CMAKE_COMPILER_IS_GNUCC OR
+ CMAKE_C_COMPILER_ID MATCHES "Clang" OR
+ CMAKE_C_COMPILER_ID MATCHES "Intel"
+)
+ # TODO(sergey): Do we want c++11 or gnu-c++11 here?
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+elseif(MSVC)
+ # Nothing special is needed, C++11 features are available by default.
else()
- # GCC-6 switched to C++11 by default, which would break linking with existing libraries
- # by default. So we explicitly disable C++11 for a new GCC so no linking issues happens.
- if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0"))
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98")
- # We also disable any of C++11 ABI from usage, so we wouldn't even try to
- # link to stuff from std::__cxx11 namespace.
- add_definitions("-D_GLIBCXX_USE_CXX11_ABI=0")
- endif()
+ message(FATAL_ERROR "Unknown compiler ${CMAKE_C_COMPILER_ID}, can't enable C++11 build")
endif()
# Visual Studio has all standards it supports available by default
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index 6cd725494b3..8d277ac787e 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -290,7 +290,7 @@ SUDO="sudo"
NO_BUILD=false
NO_CONFIRM=false
-USE_CXX11=false
+USE_CXX11=true
PYTHON_VERSION="3.6.2"
PYTHON_VERSION_MIN="3.6"
@@ -501,9 +501,6 @@ while true; do
--no-confirm)
NO_CONFIRM=true; shift; continue
;;
- --use-cxx11)
- USE_CXX11=true; shift; continue
- ;;
--with-all)
WITH_ALL=true; shift; continue
;;
@@ -802,20 +799,10 @@ OPENCOLLADA_REPO_BRANCH="master"
FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
+# C++11 is required now
CXXFLAGS_BACK=$CXXFLAGS
-if [ "$USE_CXX11" = true ]; then
- WARNING "You are trying to use c++11, this *should* go smoothely with any very recent distribution
-However, if you are experiencing linking errors (also when building Blender itself), please try the following:
- * Re-run this script with '--build-all --force-all' options.
- * Ensure your gcc version is at the very least 4.8, if possible you should really rather use gcc-5.1 or above.
-
-Please note that until the transition to C++11-built libraries if completed in your distribution, situation will
-remain fuzzy and incompatibilities may happen..."
- PRINT ""
- PRINT ""
- CXXFLAGS="$CXXFLAGS -std=c++11"
- export CXXFLAGS
-fi
+CXXFLAGS="$CXXFLAGS -std=c++11"
+export CXXFLAGS
#### Show Dependencies ####
@@ -1690,9 +1677,7 @@ compile_OIIO() {
# fi
cmake_d="$cmake_d -D USE_OCIO=OFF"
- if [ "$USE_CXX11" = true ]; then
- cmake_d="$cmake_d -D OIIO_BUILD_CPP11=ON"
- fi
+ cmake_d="$cmake_d -D OIIO_BUILD_CPP11=ON"
if file /bin/cp | grep -q '32-bit'; then
cflags="-fPIC -m32 -march=i686"
@@ -1905,9 +1890,7 @@ compile_OSL() {
cmake_d="$cmake_d -D OSL_BUILD_PLUGINS=OFF"
cmake_d="$cmake_d -D OSL_BUILD_TESTS=OFF"
cmake_d="$cmake_d -D USE_SIMD=sse2"
- if [ "$USE_CXX11" = true ]; then
- cmake_d="$cmake_d -D OSL_BUILD_CPP11=1"
- fi
+ cmake_d="$cmake_d -D OSL_BUILD_CPP11=1"
#~ cmake_d="$cmake_d -D ILMBASE_VERSION=$ILMBASE_VERSION"
@@ -2293,12 +2276,6 @@ compile_ALEMBIC() {
cmake_d="-D CMAKE_INSTALL_PREFIX=$_inst"
- # Without Boost or TR1, Alembic requires C++11.
- if [ "$USE_CXX11" != true ]; then
- cmake_d="$cmake_d -D ALEMBIC_LIB_USES_BOOST=ON"
- cmake_d="$cmake_d -D ALEMBIC_LIB_USES_TR1=OFF"
- fi
-
if [ -d $INST/boost ]; then
if [ -d $INST/boost ]; then
cmake_d="$cmake_d -D BOOST_ROOT=$INST/boost"
@@ -4235,12 +4212,6 @@ print_info() {
_buildargs="$_buildargs -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES*"
_buildargs="$_buildargs -U *OPENSUBDIV* -U *OPENVDB* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC*"
- if [ "$USE_CXX11" = true ]; then
- _1="-D WITH_CXX11=ON"
- PRINT " $_1"
- _buildargs="$_buildargs $_1"
- fi
-
_1="-D WITH_CODEC_SNDFILE=ON"
PRINT " $_1"
_buildargs="$_buildargs $_1"
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 5d5425a9fc6..54a41f95819 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -859,164 +859,6 @@ macro(message_first_run)
endif()
endmacro()
-macro(TEST_UNORDERED_MAP_SUPPORT)
- # - Detect unordered_map availability
- # Test if a valid implementation of unordered_map exists
- # and define the include path
- # This module defines
- # HAVE_UNORDERED_MAP, whether unordered_map implementation was found
- #
- # HAVE_STD_UNORDERED_MAP_HEADER, <unordered_map.h> was found
- # HAVE_UNORDERED_MAP_IN_STD_NAMESPACE, unordered_map is in namespace std
- # HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE, unordered_map is in namespace std::tr1
- #
- # UNORDERED_MAP_INCLUDE_PREFIX, include path prefix for unordered_map, if found
- # UNORDERED_MAP_NAMESPACE, namespace for unordered_map, if found
-
- include(CheckIncludeFileCXX)
-
- # Workaround for newer GCC (6.x+) where C++11 was enabled by default, which lead us
- # to a situation when there is <unordered_map> include but which can't be used uless
- # C++11 is enabled.
- if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0") AND (NOT WITH_CXX11))
- set(HAVE_STD_UNORDERED_MAP_HEADER False)
- else()
- CHECK_INCLUDE_FILE_CXX("unordered_map" HAVE_STD_UNORDERED_MAP_HEADER)
- endif()
- if(HAVE_STD_UNORDERED_MAP_HEADER)
- # Even so we've found unordered_map header file it doesn't
- # mean unordered_map and unordered_set will be declared in
- # std namespace.
- #
- # Namely, MSVC 2008 have unordered_map header which declares
- # unordered_map class in std::tr1 namespace. In order to support
- # this, we do extra check to see which exactly namespace is
- # to be used.
-
- include(CheckCXXSourceCompiles)
- CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>
- int main() {
- std::unordered_map<int, int> map;
- return 0;
- }"
- HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
- if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
- message_first_run(STATUS "Found unordered_map/set in std namespace.")
-
- set(HAVE_UNORDERED_MAP "TRUE")
- set(UNORDERED_MAP_INCLUDE_PREFIX "")
- set(UNORDERED_MAP_NAMESPACE "std")
- else()
- CHECK_CXX_SOURCE_COMPILES("#include <unordered_map>
- int main() {
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list