Lock-free memory allocator
[blender.git] / CMakeLists.txt
index 0379e46bc719ecf8632048eba7b0e933055b8d63..6eb8ec097b4ccc28bc6416f0dc1a72fdbc8b047d 100644 (file)
@@ -118,9 +118,10 @@ mark_as_advanced(WITH_BLENDER)
 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
 
 option(WITH_PYTHON        "Enable Embedded Python API  (only disable for development)" ON)
-option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default (recommend to leave off)" OFF)
+option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON) 
 mark_as_advanced(WITH_PYTHON)  # dont want people disabling this unless they really know what they are doing.
 mark_as_advanced(WITH_PYTHON_SECURITY)  # some distributions see this as a security issue, rather than have them patch it, make a build option.
+set(WITH_PYTHON_SECURITY ON CACHE BOOL "ON" FORCE) # temp force on. 
 
 option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency, only enable for development)." OFF)
 option(WITH_PYTHON_MODULE "Enable building as a python module which runs without a user interface, like running regular blender in background mode (experimental, only enable for development)" OFF)
@@ -205,6 +206,7 @@ option(WITH_MOD_OCEANSIM        "Enable Ocean Modifier" OFF)
 option(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
 option(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
 option(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
+option(WITH_IMAGE_PSD           "Enable Photoshop PSD Support" ON)
 option(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
 option(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
 option(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
@@ -260,10 +262,11 @@ mark_as_advanced(PYTHON_NUMPY_PATH)
 
 # Cycles
 option(WITH_CYCLES                                     "Enable cycles Render Engine" ON)
-option(WITH_CYCLES_TEST                                "Build cycles test application" OFF)
+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" OFF)
 option(WITH_CYCLES_CUDA_BINARIES       "Build cycles CUDA binaries" OFF)
-set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 CACHE STRING "CUDA architectures to build binaries for")
+set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 CACHE STRING "CUDA architectures to build binaries for")
 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
 unset(PLATFORM_DEFAULT)
 
@@ -276,13 +279,14 @@ mark_as_advanced(LLVM_STATIC)
 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
 mark_as_advanced(WITH_MEM_JEMALLOC)
 
+# currently only used for BLI_mempool
+option(WITH_MEM_VALGRIND "Enable extended valgrind support for better reporting" OFF)
+mark_as_advanced(WITH_MEM_VALGRIND)
+
 # Debug
 option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
 
-option(WITH_GUARDEDALLOC "Enable GuardedAlloc (DISABLE AT OWN RISK!)" ON)
-mark_as_advanced(WITH_GUARDEDALLOC)
-
 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
 mark_as_advanced(WITH_ASSERT_ABORT)
 
@@ -304,7 +308,9 @@ if(APPLE)
        endif()
        
        execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version
-       if(${MAC_SYS} MATCHES 12)
+       if(${MAC_SYS} MATCHES 13)
+               set(OSX_SYSTEM 10.9)
+       elseif(${MAC_SYS} MATCHES 12)
                set(OSX_SYSTEM 10.8)
        elseif(${MAC_SYS} MATCHES 11)
                set(OSX_SYSTEM 10.7)
@@ -316,9 +322,22 @@ if(APPLE)
                set(OSX_SYSTEM unsupported)
        endif()
        message(STATUS "Detected system-version: " ${OSX_SYSTEM})
-
+       
+       # workaround for incorrect cmake xcode lookup for developer previews - XCODE_VERSION does not take xcode-select path into accout
+       # but would always look into /Applications/Xcode.app while dev versions are named Xcode<version>-DP<preview_number>
+       execute_process(COMMAND xcode-select --print-path  OUTPUT_VARIABLE XCODE_CHECK OUTPUT_STRIP_TRAILING_WHITESPACE)
+       string(REPLACE "/Contents/Developer" "" XCODE_BUNDLE ${XCODE_CHECK}) # truncate to bundlepath in any case
+       message(STATUS "Xcode-bundle : " ${XCODE_BUNDLE})
+       
        if(${CMAKE_GENERATOR} MATCHES "Xcode")
        
+               if(${XCODE_VERSION} VERSION_GREATER 4.2) # earlier xcode has no bundled developer dir, no sense in getting xcode path from
+                       string(SUBSTRING "${XCODE_CHECK}" 14 6 DP_NAME) # reduce to XCode name without dp extension
+                       if(${DP_NAME} MATCHES Xcode5)
+                               set(XCODE_VERSION 5)
+                       endif()
+               endif()
+
                ##### cmake incompatibility with xcode  4.3 and higher #####
                if(${XCODE_VERSION} MATCHES '') # cmake fails due looking for xcode in the wrong path, thus will be empty var
                        message(FATAL_ERROR "Xcode 4.3 and higher must be used with cmake 2.8-8 or higher")
@@ -342,15 +361,16 @@ if(APPLE)
        if(${XCODE_VERSION} VERSION_LESS 4.3)
                set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk CACHE PATH "" FORCE)  # use guaranteed existing sdk
        else()
-               # note: i don't use xcode-select path on purpose, cause also /Applications/Xcode.app would be allowed
-               # absolute pathes are more foolproof here !
-               set(OSX_SYSROOT_PREFIX /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform)
+               # note: xcode-select path could be ambigous, cause /Applications/Xcode.app/Contents/Developer or /Applications/Xcode.app would be allowed
+               # so i use a selfcomposed bundlepath here  
+               set(OSX_SYSROOT_PREFIX ${XCODE_BUNDLE}/Contents/Developer/Platforms/MacOSX.platform)
+               message(STATUS "OSX_SYSROOT_PREFIX: " ${OSX_SYSROOT_PREFIX})
                set(OSX_DEVELOPER_PREFIX /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk) # use guaranteed existing sdk
                set(CMAKE_OSX_SYSROOT ${OSX_SYSROOT_PREFIX}/${OSX_DEVELOPER_PREFIX} CACHE PATH "" FORCE)
        endif()
        
        if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
-                       set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "" FORCE) # 10.5 is our min. target, if you use higher sdk, weak linking happens
+               set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "" FORCE) # 10.5 is our min. target, if you use higher sdk, weak linking happens
        endif()
        
        if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
@@ -372,7 +392,7 @@ endif()
 #-----------------------------------------------------------------------------
 # Check for conflicting/unsupported configurations
 
-if(NOT WITH_BLENDER AND NOT WITH_PLAYER AND NOT WITH_CYCLES_TEST)
+if(NOT WITH_BLENDER AND NOT WITH_PLAYER AND NOT WITH_CYCLES_STANDALONE)
        message(FATAL_ERROR "At least one of WITH_BLENDER or WITH_PLAYER must be enabled, nothing to do!")
 endif()
 
@@ -415,6 +435,15 @@ if(WITH_PYTHON_MODULE)
        set(WITH_HEADLESS ON)
 endif()
 
+if(NOT WITH_PYTHON)
+       set(WITH_CYCLES OFF)
+endif()
+
+# auto enable openimageio for photoshop psd
+if(WITH_IMAGE_PSD)
+       set(WITH_OPENIMAGEIO ON)
+endif()
+
 # enable boost for cycles, booleans, audaspace or i18n
 # otherwise if the user disabled
 if(NOT WITH_BOOST)
@@ -434,7 +463,7 @@ if(NOT WITH_BOOST)
 
        set_and_warn(WITH_OPENAL         OFF)  # depends on AUDASPACE
        set_and_warn(WITH_GAMEENGINE     OFF)  # depends on AUDASPACE
-elseif(WITH_CYCLES OR WITH_MOD_BOOLEAN OR WITH_AUDASPACE OR WITH_INTERNATIONAL)
+elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_MOD_BOOLEAN OR WITH_AUDASPACE OR WITH_INTERNATIONAL)
        # Keep enabled
 else()
        # Enabled but we don't need it
@@ -537,9 +566,6 @@ set(PLATFORM_LINKFLAGS "")
 set(PLATFORM_LINKFLAGS_DEBUG "")
 
 
-# disabled for now, not supported
-# option(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
-
 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
 # On Unix:
 #   cmake ../blender \
@@ -561,12 +587,12 @@ set(PLATFORM_LINKFLAGS_DEBUG "")
 if(UNIX AND NOT APPLE)
        macro(find_package_wrapper)
                string(TOUPPER ${ARGV0} _NAME_UPPER)
-               if(${WITH_STATIC_LIBS})
+               if(WITH_STATIC_LIBS)
                        set(_cmake_find_library_suffixes_back ${CMAKE_FIND_LIBRARY_SUFFIXES})
                        set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
                endif()
                find_package(${ARGV})
-               if(${WITH_STATIC_LIBS})
+               if(WITH_STATIC_LIBS)
                        set(CMAKE_FIND_LIBRARY_SUFFIXES ${_cmake_find_library_suffixes_back})
                        unset(_cmake_find_library_suffixes_back)
                endif()
@@ -706,7 +732,7 @@ if(UNIX AND NOT APPLE)
        if(WITH_BOOST)
                # uses in build instructions to override include and library variables
                if(NOT BOOST_CUSTOM)
-                       if(${WITH_STATIC_LIBS})
+                       if(WITH_STATIC_LIBS)
                                set(Boost_USE_STATIC_LIBS ON)
                        endif()
                        set(Boost_USE_MULTITHREADED ON)
@@ -769,43 +795,48 @@ if(UNIX AND NOT APPLE)
                endif()
 
                if(LLVM_DIRECTORY)
-                       FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS ${LLVM_DIRECTORY}/bin NO_CMAKE_PATH)
+                       find_program(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS ${LLVM_DIRECTORY}/bin NO_CMAKE_PATH)
                        if(NOT LLVM_CONFIG)
-                               FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS ${LLVM_DIRECTORY}/bin NO_CMAKE_PATH)
+                               find_program(LLVM_CONFIG llvm-config HINTS ${LLVM_DIRECTORY}/bin NO_CMAKE_PATH)
                        endif()
                else()
-                       FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION})
+                       find_program(LLVM_CONFIG llvm-config-${LLVM_VERSION})
                        if(NOT LLVM_CONFIG)
-                               FIND_PROGRAM(LLVM_CONFIG llvm-config)
+                               find_program(LLVM_CONFIG llvm-config)
                        endif()
                endif()
-               execute_process(COMMAND ${LLVM_CONFIG} --version
-                               OUTPUT_VARIABLE LLVM_VERSION
-                               OUTPUT_STRIP_TRAILING_WHITESPACE)
-               execute_process(COMMAND ${LLVM_CONFIG} --prefix
-                               OUTPUT_VARIABLE LLVM_DIRECTORY
-                               OUTPUT_STRIP_TRAILING_WHITESPACE)
-               execute_process(COMMAND ${LLVM_CONFIG} --libdir
-                               OUTPUT_VARIABLE LLVM_LIB_DIR
-                               OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+               if(NOT DEFINED LLVM_VERSION)
+                       execute_process(COMMAND ${LLVM_CONFIG} --version
+                                                       OUTPUT_VARIABLE LLVM_VERSION
+                                                       OUTPUT_STRIP_TRAILING_WHITESPACE)
+                       set(LLVM_VERSION ${LLVM_VERSION} CACHE STRING "Version of LLVM to use")
+               endif()
+               if(NOT DEFINED LLVM_DIRECTORY)
+                       execute_process(COMMAND ${LLVM_CONFIG} --prefix
+                                                       OUTPUT_VARIABLE LLVM_DIRECTORY
+                                                       OUTPUT_STRIP_TRAILING_WHITESPACE)
+                       set(LLVM_DIRECTORY ${LLVM_DIRECTORY} CACHE PATH "Path to the LLVM installation")
+               endif()
+               if(NOT DEFINED LLVM_LIBPATH)
+                       execute_process(COMMAND ${LLVM_CONFIG} --libdir
+                                                       OUTPUT_VARIABLE LLVM_LIBPATH
+                                                       OUTPUT_STRIP_TRAILING_WHITESPACE)
+                       set(LLVM_LIBPATH ${LLVM_LIBPATH} CACHE PATH "Path to the LLVM library path")
+               endif()
 
                if(LLVM_STATIC)
                        find_library(LLVM_LIBRARY
                                     NAMES LLVMAnalysis # first of a whole bunch of libs to get
-                                    PATHS ${LLVM_LIB_DIR})
+                                    PATHS ${LLVM_LIBPATH})
                else()
                        find_library(LLVM_LIBRARY
                                     NAMES LLVM-${LLVM_VERSION}
-                                    PATHS ${LLVM_LIB_DIR})
+                                    PATHS ${LLVM_LIBPATH})
                endif()
 
-               message(STATUS "LLVM version  = ${LLVM_VERSION}")
-               message(STATUS "LLVM dir      = ${LLVM_DIRECTORY}")
-               message(STATUS "LLVM lib dir  = ${LLVM_LIB_DIR}")
-               set(LLVM_VERSION ${LLVM_VERSION} CACHE STRING "Version of LLVM to use")
-               set(LLVM_DIRECTORY ${LLVM_DIRECTORY} CACHE PATH "Path to the LLVM installation")
 
-               if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
+               if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIBPATH)
                        if(LLVM_STATIC)
                                # if static LLVM libraries were requested, use llvm-config to generate
                                # the list of what libraries we need, and substitute that in the right
@@ -813,7 +844,7 @@ if(UNIX AND NOT APPLE)
                                execute_process(COMMAND ${LLVM_CONFIG} --libfiles
                                                OUTPUT_VARIABLE LLVM_LIBRARY
                                                OUTPUT_STRIP_TRAILING_WHITESPACE)
-                               string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
+                               string(REPLACE " " ";" LLVM_LIBRARY "${LLVM_LIBRARY}")
                        endif()
                else()
                        message(FATAL_ERROR "LLVM not found.")
@@ -879,8 +910,6 @@ if(UNIX AND NOT APPLE)
 
        if(CMAKE_SYSTEM_NAME MATCHES "Linux")
                if(NOT WITH_PYTHON_MODULE)
-                       # BSD's dont use libdl.so
-               set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -ldl")
                        # binreloc is linux only
                        set(BINRELOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/binreloc/include)
                        set(WITH_BINRELOC ON)
@@ -931,20 +960,26 @@ elseif(WIN32)
        #  include(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
 
        if(CMAKE_COMPILER_IS_GNUCC)
-               set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
                include(CheckCSourceCompiles)
                # Setup 64bit and 64bit windows systems
                CHECK_C_SOURCE_COMPILES("
                        #ifndef __MINGW64__
                        #error
                        #endif
-                       main(){}
+                       int main(void) { return 0; }
                        " 
                        WITH_MINGW64)
                
                if(WITH_MINGW64)
                        message(STATUS "Compiling for 64 bit with MinGW-w64.")
                        set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
+               else()
+                       message(STATUS "Compiling for 32 bit with MinGW-w32.")
+                       set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
+                       
+                       if(WITH_RAYOPTIMIZATION)
+                               message(WARNING "MinGW-w32 is known to be unstable with 'WITH_RAYOPTIMIZATION' option enabled.")
+                       endif()
                endif()
        else()
                # Setup 64bit and 64bit windows systems
@@ -1088,11 +1123,7 @@ elseif(WIN32)
                set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
 
                set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include)
-               if(CMAKE_CL_64)
-                       set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz.lib)
-               else()
-                       set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/zlib.lib)
-               endif()
+               set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz_st.lib)
 
                set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
                set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC2.lib)
@@ -1121,26 +1152,22 @@ elseif(WIN32)
                                ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
                                ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
                        )
-                       set_lib_path(OPENCOLLADA_LIBPATH "opencollada")
 
                        set(OPENCOLLADA_LIBRARIES
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADAFramework.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADABaseUtils.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADAStreamWriter.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/MathMLSolver.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/GeneratedSaxParser.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/xml.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/buffer.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/ftoa.lib
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/UTF.lib
+                               ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib
+                               ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework.lib
+                               ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils.lib
+                               ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter.lib
+                               ${OPENCOLLADA}/lib/opencollada/MathMLSolver.lib
+                               ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser.lib
+                               ${OPENCOLLADA}/lib/opencollada/xml.lib
+                               ${OPENCOLLADA}/lib/opencollada/buffer.lib
+                               ${OPENCOLLADA}/lib/opencollada/ftoa.lib
+                               ${OPENCOLLADA}/lib/opencollada/UTF.lib
                        )
                        set(PCRE_LIBRARIES
-                               ${OPENCOLLADA_LIBPATH}/lib/opencollada/pcre.lib
+                               ${OPENCOLLADA}/lib/opencollada/pcre.lib
                        )
-                       
-                       unset(OPENCOLLADA_LIBPATH)
-                       
                endif()
 
                if(WITH_CODEC_FFMPEG)
@@ -1169,7 +1196,7 @@ elseif(WIN32)
                endif()
 
                if(WITH_IMAGE_OPENEXR)
-                       set_lib_path(OPENEXR "openexr")
+                       set(OPENEXR ${LIBDIR}/openexr)
                        set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
                        set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
                        set(OPENEXR_LIBPATH ${OPENEXR}/lib)
@@ -1196,18 +1223,11 @@ elseif(WIN32)
                endif()
 
                if(WITH_PYTHON)
-                       # normally cached but not since we include them with blender
-                       if(MSVC10)
-                               set(PYTHON_VERSION 3.3) # CACHE STRING)
-                       else()
-                               set(PYTHON_VERSION 3.3) # CACHE STRING)
-                       endif()
+                       set(PYTHON_VERSION 3.3) # CACHE STRING)
 
-                       set_lib_path(PYTHON "python")
                        string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
                        # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs
                        set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib)
-                       # set(PYTHON_LIBRARY ${PYTHON}/lib/python${_PYTHON_VERSION_NO_DOTS}.lib) #CACHE FILEPATH
                        unset(_PYTHON_VERSION_NO_DOTS)
 
                        # Shared includes for both vc2008 and vc2010
@@ -1225,10 +1245,6 @@ elseif(WIN32)
                                set(BOOST_LIBPATH ${BOOST}/lib)
                                set(BOOST_POSTFIX "vc110-mt-s-1_53.lib")
                                set(BOOST_DEBUG_POSTFIX "vc110-mt-sgd-1_53.lib")
-                       elseif(MSVC10)
-                               set(BOOST_LIBPATH ${BOOST}/vc2010/lib)
-                               set(BOOST_POSTFIX "vc100-mt-s-1_49.lib")
-                               set(BOOST_DEBUG_POSTFIX "vc100-mt-sgd-1_49.lib")
                        else()
                                set(BOOST_LIBPATH ${BOOST}/lib)
                                set(BOOST_POSTFIX "vc90-mt-s-1_49.lib")
@@ -1445,7 +1461,7 @@ elseif(WIN32)
                
                if(WITH_LLVM)
                        set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
-                       set(LLVM_LIB_DIR ${LLVM_DIRECTORY}/lib)
+                       set(LLVM_LIBPATH ${LLVM_DIRECTORY}/lib)
                        # Explicitly set llvm lib order.
                        #---- WARNING ON GCC ORDER OF LIBS IS IMPORTANT, DO NOT CHANGE! ---------
                        set(LLVM_LIBRARY LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMAnalysis LLVMArchive
@@ -1634,7 +1650,7 @@ elseif(APPLE)
                endif()
 
        if(WITH_JACK)
-               set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -weak_framework jackmp")
+               set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp")
        endif()
 
        else()
@@ -1739,13 +1755,13 @@ elseif(APPLE)
                                OUTPUT_VARIABLE LLVM_DIRECTORY
                                OUTPUT_STRIP_TRAILING_WHITESPACE)
                execute_process(COMMAND ${LLVM_CONFIG} --libdir
-                               OUTPUT_VARIABLE LLVM_LIB_DIR
+                               OUTPUT_VARIABLE LLVM_LIBPATH
                                OUTPUT_STRIP_TRAILING_WHITESPACE)
                find_library(LLVM_LIBRARY
                             NAMES LLVMAnalysis # first of a whole bunch of libs to get
-                            PATHS ${LLVM_LIB_DIR})
+                            PATHS ${LLVM_LIBPATH})
 
-               if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
+               if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIBPATH)
                        if(LLVM_STATIC)
                                # if static LLVM libraries were requested, use llvm-config to generate
                                # the list of what libraries we need, and substitute that in the right
@@ -1793,6 +1809,15 @@ elseif(APPLE)
                set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
                set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
        endif()
+
+       if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+               if(${CMAKE_GENERATOR} MATCHES "Xcode")
+                       if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
+                               # Xcode 5 has too low template depth of 128 for libmv
+                               set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
+                       endif()
+               endif()
+       endif()
 endif()
 
 #-----------------------------------------------------------------------------
@@ -1810,22 +1835,22 @@ endif()
 
 if(WITH_CYCLES)
        if(NOT WITH_OPENIMAGEIO)
-               message(FATAL_ERROR "Cycles reqires WITH_OPENIMAGEIO, the library may not have been found. Configure OIIO or disable WITH_CYCLES")
+               message(FATAL_ERROR "Cycles requires WITH_OPENIMAGEIO, the library may not have been found. Configure OIIO or disable WITH_CYCLES")
        endif()
        if(NOT WITH_BOOST)
-               message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES")
+               message(FATAL_ERROR "Cycles requires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES")
        endif()
 
        if(WITH_CYCLES_OSL)
                if(NOT WITH_LLVM)
-                       message(FATAL_ERROR "Cycles OSL reqires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL")
+                       message(FATAL_ERROR "Cycles OSL requires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL")
                endif()
        endif()
 endif()
 
 if(WITH_INTERNATIONAL)
        if(NOT WITH_BOOST)
-               message(FATAL_ERROR "Internationalization reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_INTERNATIONAL")
+               message(FATAL_ERROR "Internationalization requires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_INTERNATIONAL")
        endif()
 endif()
 
@@ -1886,16 +1911,6 @@ if(WITH_IMAGE_REDCODE)
        set(REDCODE_INC ${REDCODE})
 endif()
 
-#-----------------------------------------------------------------------------
-# Blender WebPlugin
-
-if(WITH_WEBPLUGIN)
-       set(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
-       set(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
-
-       set(WITH_PLAYER ON)
-endif()
-
 
 #-----------------------------------------------------------------------------
 # Configure OpenGL.
@@ -1989,6 +2004,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_NULL -Wnonnull)  # C only
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
 
        # gcc 4.2 gives annoying warnings on every file with this
        if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -2015,6 +2031,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_TYPE_LIMITS -Wtype-limits)
 
        # gcc 4.2 gives annoying warnings on every file with this
        if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -2065,6 +2082,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
        ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
        ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS    -Wno-unused-macros)
 
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
+
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
+       ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
+
 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
 
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
@@ -2081,13 +2112,6 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
 
 endif()
 
-# MSVC2010 fails to links C++ libs right
-if(MSVC10)
-       if(WITH_OPENCOLLADA)
-               message(WARNING "MSVC 2010 does not support OpenCollada, disabling WITH_OPENCOLLADA. To enable support use Use MSVC 2008")
-       endif()
-endif()
-
 # ensure python header is found since detection can fail, this could happen
 # with _any_ library but since we used a fixed python version this tends to
 # be most problematic.
@@ -2157,6 +2181,23 @@ endif()
 set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
 set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}")
 
+# defined above, platform spesific but shared names
+mark_as_advanced(
+       CYCLES_OSL
+       OSL_LIB_EXEC
+       OSL_COMPILER
+       OSL_LIB_COMP
+       OSL_LIB_QUERY
+       OSL_INCLUDES
+)
+
+mark_as_advanced(
+       LLVM_CONFIG
+       LLVM_DIRECTORY
+       LLVM_LIBRARY
+       LLVM_VERSION
+)
+
 #-------------------------------------------------------------------------------
 # Global Defines
 
@@ -2247,6 +2288,7 @@ if(FIRST_RUN)
        info_cfg_option(WITH_X11_XF86VMODE)
        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_option(WITH_SYSTEM_OPENJPEG)
 
@@ -2258,6 +2300,7 @@ if(FIRST_RUN)
        info_cfg_option(WITH_IMAGE_OPENJPEG)
        info_cfg_option(WITH_IMAGE_REDCODE)
        info_cfg_option(WITH_IMAGE_TIFF)
+       info_cfg_option(WITH_IMAGE_PSD)
 
        info_cfg_text("Audio:")
        info_cfg_option(WITH_OPENAL)