Fix C++11 building on MSVC 2015
[blender.git] / CMakeLists.txt
index 5f7d59a28cf13f72d00044113e36e7fa377130fc..a7f1c00c850626fb8497694059ade3fc5e7e028c 100644 (file)
@@ -155,6 +155,7 @@ option_defaults_init(
        _init_BUILDINFO
        _init_CODEC_FFMPEG
        _init_CYCLES_OSL
+       _init_CYCLES_OPENSUBDIV
        _init_IMAGE_OPENEXR
        _init_INPUT_NDOF
        _init_JACK
@@ -172,6 +173,7 @@ if(UNIX AND NOT APPLE)
        # disable less important dependencies by default
        set(_init_CODEC_FFMPEG                   OFF)
        set(_init_CYCLES_OSL                     OFF)
+       set(_init_CYCLES_OPENSUBDIV              OFF)
        set(_init_IMAGE_OPENEXR                  OFF)
        set(_init_JACK                           OFF)
        set(_init_OPENCOLLADA                    OFF)
@@ -220,8 +222,8 @@ if(${CMAKE_VERSION} VERSION_LESS 2.8.8)
 endif()
 set(BUILDINFO_OVERRIDE_DATE "" CACHE STRING "Use instead of the current date for reproducable builds (empty string disables this option)")
 set(BUILDINFO_OVERRIDE_TIME "" CACHE STRING "Use instead of the current time for reproducable builds (empty string disables this option)")
-set(PACKAGENAME_OVERRIDE "" CACHE STRING "Use instead of the standard packagename (empty string disables this option)")
-mark_as_advanced(PACKAGENAME_OVERRIDE)
+set(CPACK_OVERRIDE_PACKAGENAME "" CACHE STRING "Use instead of the standard packagename (empty string disables this option)")
+mark_as_advanced(CPACK_OVERRIDE_PACKAGENAME)
 mark_as_advanced(BUILDINFO_OVERRIDE_DATE)
 mark_as_advanced(BUILDINFO_OVERRIDE_TIME)
 
@@ -331,7 +333,7 @@ option(WITH_ALEMBIC             "Enable Alembic Support" OFF)
 option(WITH_ALEMBIC_HDF5        "Enable Legacy Alembic Support (not officially supported)" OFF)
 
 if(APPLE)
-       option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" ON)
+       option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
 endif()
 
 # 3D format support
@@ -341,9 +343,9 @@ option(WITH_OPENCOLLADA   "Enable OpenCollada Support (http://www.opencollada.or
 # Sound output
 option(WITH_SDL           "Enable SDL for sound and joystick support" ${_init_SDL})
 option(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
-option(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" ${_init_JACK})
+option(WITH_JACK          "Enable JACK Support (http://www.jackaudio.org)" ${_init_JACK})
 if(UNIX AND NOT APPLE)
-       option(WITH_JACK_DYNLOAD  "Enable runtime dynamic Jack libraries loading" OFF)
+       option(WITH_JACK_DYNLOAD  "Enable runtime dynamic JACK libraries loading" OFF)
 endif()
 if(UNIX AND NOT APPLE)
        option(WITH_SDL_DYNLOAD  "Enable runtime dynamic SDL libraries loading" OFF)
@@ -400,9 +402,9 @@ 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)
 option(WITH_CYCLES_OSL                         "Build Cycles with OSL support" ${_init_CYCLES_OSL})
-option(WITH_CYCLES_OPENSUBDIV          "Build Cycles with OpenSubdiv support" ON)
+option(WITH_CYCLES_OPENSUBDIV          "Build Cycles with OpenSubdiv support" ${_init_CYCLES_OPENSUBDIV})
 option(WITH_CYCLES_CUDA_BINARIES       "Build Cycles CUDA binaries" OFF)
-set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_37 sm_50 sm_52 CACHE STRING "CUDA architectures to build binaries for")
+set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 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)
@@ -495,17 +497,22 @@ endif()
 # We default options to whatever default standard in the current compiler.
 if(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()
+set(_cxx11_init ON)
 
 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)
+       mark_as_advanced(WITH_LINKER_GOLD)
+endif()
+
 # Dependency graph
 option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
 mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
@@ -627,9 +634,21 @@ if(APPLE)
                set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT})
        endif()
 
-       if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
-               # 10.6 is our min. target, if you use higher sdk, weak linking happens
-               set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE)
+       if(WITH_CXX11)
+               # 10.9 is our min. target, if you use higher sdk, weak linking happens
+               if(CMAKE_OSX_DEPLOYMENT_TARGET)
+                       if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.9)
+                               message(STATUS "Setting deployment target to 10.9, lower versions are incompatible with WITH_CXX11")
+                               set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
+                       endif()
+               else()
+                       set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "" FORCE)
+               endif()
+       else()
+               if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
+                       # 10.6 is our min. target, if you use higher sdk, weak linking happens
+                       set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE)
+               endif()
        endif()
        
        if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
@@ -717,7 +736,7 @@ elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL O
        # Keep enabled
 else()
        # New dependency graph needs either Boost or C++11 for function bindings.
-       if(NOT USE_CXX11)
+       if(NOT WITH_CXX11)
                # Enabled but we don't need it
                set(WITH_BOOST OFF)
        endif()
@@ -952,11 +971,6 @@ if(WITH_CYCLES)
                        )
                endif()
        endif()
-
-       if(WITH_CYCLES_OPENSUBDIV AND NOT WITH_OPENSUBDIV)
-               message(STATUS "WITH_CYCLES_OPENSUBDIV requires WITH_OPENSUBDIV to be ON, turning OFF")
-               set(WITH_CYCLES_OPENSUBDIV OFF)
-       endif()
 endif()
 
 if(WITH_INTERNATIONAL)
@@ -977,7 +991,7 @@ if(SUPPORT_SSE_BUILD)
        add_definitions(-D__SSE__ -D__MMX__)
 endif()
 if(SUPPORT_SSE2_BUILD)
-       set(PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG} ${PLATFORM_CFLAGS}")
+       set(PLATFORM_CFLAGS " ${PLATFORM_CFLAGS} ${COMPILER_SSE2_FLAG}")
        add_definitions(-D__SSE2__)
        if(NOT SUPPORT_SSE_BUILD) # dont double up
                add_definitions(-D__MMX__)
@@ -1552,7 +1566,7 @@ if(WITH_CXX11)
        if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
                # TODO(sergey): Do we want c++11 or gnu-c++11 here?
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-       elseif(MSVC12)
+       elseif(MSVC14 OR MSVC12)
                # 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")