CMake: De-duplicate checks around unordered maps and shared pointer
[blender.git] / CMakeLists.txt
index 2d4fb2b725464f545df6de1eec8a8bd5d6ad6780..e91f4b503a23b51d88eac6c001c41c4d4239e23f 100644 (file)
@@ -399,6 +399,9 @@ mark_as_advanced(WITH_CYCLES_LOGGING)
 mark_as_advanced(WITH_CYCLES_DEBUG)
 mark_as_advanced(WITH_CYCLES_WERROR)
 
+option(WITH_CUDA_DYNLOAD "Dynamically load CUDA libraries at runtime" ON)
+mark_as_advanced(WITH_CUDA_DYNLOAD)
+
 # LLVM
 option(WITH_LLVM                                       "Use LLVM" OFF)
 if(APPLE)
@@ -728,6 +731,9 @@ if(HAVE_STDBOOL_H)
        add_definitions(-DHAVE_STDBOOL_H)
 endif()
 
+TEST_SHARED_PTR_SUPPORT()
+TEST_UNORDERED_MAP_SUPPORT()
+
 if(WITH_AUDASPACE)
        if(WITH_SYSTEM_AUDASPACE)
                set(AUDASPACE_DEFINITIONS
@@ -1486,8 +1492,8 @@ elseif(WIN32)
                                        set(BOOST_DEBUG_POSTFIX "vc120-mt-sgd-1_55.lib")
                                else()
                                        set(BOOST_LIBPATH ${BOOST}/lib)
-                                       set(BOOST_POSTFIX "vc90-mt-s-1_49.lib")
-                                       set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib")
+                                       set(BOOST_POSTFIX "vc140-mt-s-1_60.lib")
+                                       set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-1_60.lib")
                                endif()
                                set(BOOST_LIBRARIES
                                        optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX}
@@ -1619,12 +1625,7 @@ elseif(WIN32)
                
                if(WITH_MINGW64)
                        message(STATUS "Compiling for 64 bit with MinGW-w64.")
-                       execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
-                       if(GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
-                               set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64_gcc49)
-                       else()
-                               set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
-                       endif()
+                       set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
                else()
                        message(STATUS "Compiling for 32 bit with MinGW-w32.")
                        set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
@@ -2474,7 +2475,7 @@ if(WITH_OPENMP)
                        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
                else()
                        # Typically avoid adding flags as defines but we can't
-                       # ass OpenMP flags to the linker for static builds, meaning
+                       # 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}")
@@ -2585,6 +2586,59 @@ if(WITH_PYTHON_MODULE)
        add_definitions(-DPy_ENABLE_SHARED)
 endif()
 
+#-----------------------------------------------------------------------------
+# Configure GLog/GFlags
+
+if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
+       set(GLOG_DEFINES
+               -DGOOGLE_GLOG_DLL_DECL=
+       )
+
+       set(GFLAGS_DEFINES
+               -DGFLAGS_DLL_DEFINE_FLAG=
+               -DGFLAGS_DLL_DECLARE_FLAG=
+               -DGFLAGS_DLL_DECL=
+       )
+endif()
+
+#-----------------------------------------------------------------------------
+# Configure Ceres
+
+if(WITH_LIBMV)
+       set(CERES_DEFINES)
+
+       if(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(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()
+endif()
+
 #-----------------------------------------------------------------------------
 # Extra compile flags
 
@@ -2856,7 +2910,9 @@ if(WITH_BLENDER OR WITH_PLAYER)
 elseif(WITH_CYCLES_STANDALONE)
        add_subdirectory(intern/cycles)
        add_subdirectory(extern/clew)
-       add_subdirectory(extern/cuew)
+       if(WITH_CUDA_DYNLOAD)
+               add_subdirectory(extern/cuew)
+       endif()
        if(NOT WITH_SYSTEM_GLEW)
                add_subdirectory(extern/glew)
        endif()