Lock-free memory allocator
[blender.git] / CMakeLists.txt
index 17ae5b3857d6c5e5ebf6ee25e1f1485fb1952317..6eb8ec097b4ccc28bc6416f0dc1a72fdbc8b047d 100644 (file)
@@ -206,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)
@@ -261,7 +262,8 @@ 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 sm_35 CACHE STRING "CUDA architectures to build binaries for")
@@ -277,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)
 
@@ -305,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)
@@ -317,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")
@@ -343,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")
@@ -373,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()
 
@@ -416,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)
@@ -435,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
@@ -538,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 \
@@ -770,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
@@ -814,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.")
@@ -880,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)
@@ -1433,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
@@ -1622,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()
@@ -1727,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
@@ -1781,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()
 
 #-----------------------------------------------------------------------------
@@ -1798,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()
 
@@ -1874,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.
@@ -2154,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
 
@@ -2244,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)
 
@@ -2255,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)