Fix T48554: Absolute grid snap fails w/ cursor pivot
[blender.git] / CMakeLists.txt
index 44a9b687e47a4a7129bec38edae862bcd4bad849..b558fe1482049f9e509876a30c44deef2f240e3a 100644 (file)
@@ -172,7 +172,6 @@ if(UNIX AND NOT APPLE)
        set(_init_CODEC_FFMPEG                   OFF)
        set(_init_CYCLES_OSL                     OFF)
        set(_init_IMAGE_OPENEXR                  OFF)
-       set(_init_INPUT_NDOF                     OFF)
        set(_init_JACK                           OFF)
        set(_init_OPENCOLLADA                    OFF)
        set(_init_OPENCOLORIO                    OFF)
@@ -478,9 +477,19 @@ if(WIN32)
 endif()
 
 # Experimental support of C11 and C++11
-option(WITH_C11 "Build with C11 standard enabled, for development use only!" OFF)
+#
+# 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()
+
+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!" OFF)
+option(WITH_CXX11 "Build with C++11 standard enabled, for development use only!" ${_cxx11_init})
 mark_as_advanced(WITH_CXX11)
 
 # Dependency graph
@@ -823,21 +832,6 @@ set(PLATFORM_LINKFLAGS "")
 set(PLATFORM_LINKFLAGS_DEBUG "")
 
 
-# For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
-# On Unix:
-#   cmake ../blender \
-#         -D PYTHON_VERSION=3.5 \
-#         -D PYTHON_INCLUDE_DIR=/opt/py35/include/python3.5d \
-#         -D PYTHON_LIBRARY=/opt/py35/lib/libpython3.5d.so
-#
-# On Macs:
-#   cmake ../blender \
-#         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5 \
-#         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/config \
-#         -G Xcode
-#
-# When changing any of this remember to update the notes in doc/build_systems/cmake.txt
-
 #-----------------------------------------------------------------------------
 #Platform specifics
 
@@ -1039,14 +1033,12 @@ if(UNIX AND NOT APPLE)
 
        if(WITH_INPUT_NDOF)
                find_package_wrapper(Spacenav)
-               if(NOT SPACENAV_FOUND)
-                       set(WITH_INPUT_NDOF OFF)
-               endif()
-
-               # use generic names within blenders buildsystem.
                if(SPACENAV_FOUND)
+                       # use generic names within blenders buildsystem.
                        set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS})
                        set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES})
+               else()
+                       set(WITH_INPUT_NDOF OFF)
                endif()
        endif()
 
@@ -1328,15 +1320,8 @@ elseif(WIN32)
                set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
                set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
 
-               set(PLATFORM_LINKFLAGS
-                       "/SUBSYSTEM:CONSOLE "
-                       "/STACK:2097152 "
-                       "/INCREMENTAL:NO "
-                       "/NODEFAULTLIB:msvcrt.lib "
-                       "/NODEFAULTLIB:msvcmrt.lib "
-                       "/NODEFAULTLIB:msvcurt.lib "
-                       "/NODEFAULTLIB:msvcrtd.lib "
-               )
+               set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ")
+               set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib ")
 
                # Ignore meaningless for us linker warnings.
                set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /ignore:4049 /ignore:4217 /ignore:4221")
@@ -1974,7 +1959,7 @@ elseif(WIN32)
                set(OPENAL ${LIBDIR}/openal)
                set(OPENALDIR ${LIBDIR}/openal)
                set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
-               if(MSVC12)
+               if(MSVC)
                        set(OPENAL_LIBRARY openal32)
                else()
                        set(OPENAL_LIBRARY wrap_oal)
@@ -2151,15 +2136,7 @@ elseif(APPLE)
 
        set(PLATFORM_CFLAGS "-pipe -funsigned-char")
        set(PLATFORM_LINKFLAGS
-               "-fexceptions -framework CoreServices "
-               "-framework Foundation "
-               "-framework IOKit "
-               "-framework AppKit "
-               "-framework Cocoa "
-               "-framework Carbon "
-               "-framework AudioUnit "
-               "-framework AudioToolbox "
-               "-framework CoreAudio "
+               "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio"
        )
        if(WITH_CODEC_QUICKTIME)
                set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
@@ -2175,24 +2152,6 @@ elseif(APPLE)
                list(APPEND PLATFORM_LINKLIBS stdc++)
        endif()
 
-       # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED!
-       # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
-       if(WITH_INPUT_NDOF)
-               # This thread it *should* work and check the framework - campbell
-               # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
-               find_library(3DCONNEXION_CLIENT_FRAMEWORK
-                       NAMES 3DconnexionClient
-               )
-               if(NOT 3DCONNEXION_CLIENT_FRAMEWORK)
-                       set(WITH_INPUT_NDOF OFF)
-               endif()
-
-               if(WITH_INPUT_NDOF)
-                       set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework 3DconnexionClient")
-                       set(NDOF_INCLUDE_DIRS /Library/Frameworks/3DconnexionClient.framework/Headers )
-               endif()
-       endif()
-
        if(WITH_JACK)
                set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp")
        endif()
@@ -2260,10 +2219,6 @@ elseif(APPLE)
                set(TIFF_LIBPATH ${TIFF}/lib)
        endif()
 
-       if(WITH_INPUT_NDOF)
-               # linker needs "-weak_framework 3DconnexionClient"
-       endif()
-
        if(WITH_BOOST)
                set(BOOST ${LIBDIR}/boost)
                set(BOOST_INCLUDE_DIR ${BOOST}/include)
@@ -2437,8 +2392,7 @@ elseif(APPLE)
        endif()
        # Get rid of eventually clashes, we export some symbols explicite as local
        set(PLATFORM_LINKFLAGS
-               "${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list "
-               "-Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map"
+               "${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map"
        )
 
        if(WITH_CXX11)
@@ -3077,12 +3031,22 @@ endif()
 
 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)
                # 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()
+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()
 endif()
 
 # Visual Studio has all standards it supports available by default