Translation of 'text' parameter of UI functions: disables context search in RNA prope...
[blender.git] / CMakeLists.txt
index b39390c..d208d73 100644 (file)
@@ -120,20 +120,21 @@ 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)
 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 distrobutions see this as a security issue, rather than have them patch it, make a build option.
+mark_as_advanced(WITH_PYTHON_SECURITY)  # some distributions see this as a security issue, rather than have them patch it, make a build option.
 
 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)
 option(WITH_BUILDINFO     "Include extra build details (only disable for development & faster builds)" ON)
 option(WITH_IK_ITASC      "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
 option(WITH_IK_SOLVER     "Enable Legacy IK solver (only disable for development)" ON)
-option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
+option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" ON)
 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
+option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
+mark_as_advanced(WITH_SYSTEM_BULLET)
 option(WITH_GAMEENGINE    "Enable Game Engine" ON)
 option(WITH_PLAYER        "Build Player" OFF)
 option(WITH_OPENCOLORIO   "Enable OpenColorIO color management" ON)
 option(WITH_COMPOSITOR    "Enable the tile based nodal compositor" ON)
-option(WITH_COMPOSITOR_LEGACY "Enable legacy compositor" OFF)
 
 # GHOST Windowing Library Options
 option(WITH_GHOST_DEBUG   "Enable debugging output for the GHOST library" OFF)
@@ -149,6 +150,9 @@ mark_as_advanced(WITH_HEADLESS)
 option(WITH_AUDASPACE    "Build with blenders audio library (only disable if you know what you're doing!)" ON)
 mark_as_advanced(WITH_AUDASPACE)
 
+option(WITH_BOOL_COMPAT "Continue defining \"TRUE\" and \"FALSE\" until these can be replaced with \"true\" and \"false\" from stdbool.h" ON)
+mark_as_advanced(WITH_BOOL_COMPAT)
+
 
 # (unix defaults to OpenMP On)
 if((UNIX AND NOT APPLE) OR (MINGW))
@@ -186,13 +190,12 @@ unset(PLATFORM_DEFAULT)
 
 
 # Modifiers
-option(WITH_MOD_FLUID          "Enable Elbeem Modifier (Fluid Simulation)" ON)
-option(WITH_MOD_SMOKE          "Enable Smoke Modifier (Smoke Simulation)" ON)
-option(WITH_MOD_DECIMATE               "Enable Decimate Modifier" ON)
-option(WITH_MOD_BOOLEAN                "Enable Boolean Modifier" ON)
-option(WITH_MOD_REMESH         "Enable Remesh Modifier" ON)
-option(WITH_MOD_CLOTH_ELTOPO           "Enable Experimental cloth solver" OFF)
-mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
+option(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
+option(WITH_MOD_SMOKE           "Enable Smoke Modifier (Smoke Simulation)" ON)
+option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
+option(WITH_MOD_REMESH          "Enable Remesh Modifier" ON)
+# option(WITH_MOD_CLOTH_ELTOPO    "Enable Experimental cloth solver" OFF)  # this is now only available in a branch
+# mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
 option(WITH_MOD_OCEANSIM        "Enable Ocean Modifier" OFF)
 
 # Image format support
@@ -206,6 +209,7 @@ option(WITH_IMAGE_REDCODE       "Enable RedCode Image Support" OFF)
 option(WITH_IMAGE_FRAMESERVER   "Enable image FrameServer Support for rendering" ON)
 
 # Audio/Video format support
+option(WITH_CODEC_AVI           "Enable Blenders own AVI file support (raw/jpeg)" ON)
 option(WITH_CODEC_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.org)" OFF)
 
 option(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
@@ -234,17 +238,13 @@ option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)"
 option(WITH_RAYOPTIMIZATION    "Enable use of SIMD (SSE) optimizations for the raytracer" ON)
 if(UNIX AND NOT APPLE)
        option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
+       option(WITH_STATIC_LIBS "Try to link with static libraries, as much as possible, to make blender more portable across distributions" OFF)
 endif()
 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
 option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder"  ON)
 set(PYTHON_NUMPY_PATH            "" CACHE PATH "Python to python site-packages or dist-packages containing 'numpy' module")
 mark_as_advanced(PYTHON_NUMPY_PATH)
 
-if(MINGW)
-       option(WITH_MINGW64                   "Use the 64-bit version of MinGW" OFF)
-       mark_as_advanced(WITH_MINGW64)
-endif()
-
 # Cycles
 option(WITH_CYCLES                                     "Enable cycles Render Engine" ON)
 option(WITH_CYCLES_TEST                                "Build cycles test application" OFF)
@@ -254,6 +254,9 @@ set(CYCLES_CUDA_BINARIES_ARCH sm_13 sm_20 sm_21 sm_30 CACHE STRING "CUDA archite
 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
 unset(PLATFORM_DEFAULT)
 
+# LLVM
+option(WITH_LLVM                                       "Use LLVM" OFF)
+
 # disable for now, but plan to support on all platforms eventually
 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
 mark_as_advanced(WITH_MEM_JEMALLOC)
@@ -265,8 +268,13 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC)
 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
 mark_as_advanced(WITH_ASSERT_ABORT)
 
+option(WITH_BOOST                                      "Enable features depending no boost" ON)
+
 
 if(APPLE)
+       cmake_minimum_required(VERSION 2.8.8)
+       cmake_policy(VERSION 2.8.8)
+
        if(NOT CMAKE_OSX_ARCHITECTURES)
                set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
                "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
@@ -286,18 +294,14 @@ if(APPLE)
                set(OSX_SYSTEM unsupported)
        endif()
        message(STATUS "Detected system-version: " ${OSX_SYSTEM})
-       
-       if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
-                       set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "" FORCE) # 10.5 is our minimum target, if you have higher sdk, weak linking happens
-       endif()
 
        if(${CMAKE_GENERATOR} MATCHES "Xcode")
        
-               ##### workaround for actual official cmake incompatibility with xcode 4.3 ##### 
+               ##### 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("Official cmake does not yet support Xcode 4.3, get a patched version here: http://www.jensverwiebe.de/Blender/CMake%202.8-7patched.zip")
+                       message(FATAL_ERROR "Xcode 4.3 and higher must be used with cmake 2.8-8 or higher")
                endif()
-               ### end workaround for actual official cmake incompatibility with xcode 4.3 ### 
+               ### end cmake incompatibility with xcode 4.3 and higher ###
                
                if(${XCODE_VERSION} VERSION_EQUAL 4 OR ${XCODE_VERSION} VERSION_GREATER 4 AND ${XCODE_VERSION} VERSION_LESS 4.3)
                        # Xcode 4 defaults to the Apple LLVM Compiler.
@@ -312,10 +316,34 @@ if(APPLE)
        endif()
        
        message(STATUS "Detected Xcode-version: " ${XCODE_VERSION})
+
+       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)
+               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
+       endif()
        
+       if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
+               # force CMAKE_OSX_DEPLOYMENT_TARGET for makefiles, will not work else ( cmake bug ? )
+               set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
+               set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
+               add_definitions ("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
+       endif()
+
        option(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
        option(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
        option(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
+       if(CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
+               set(USE_QTKIT ON CACHE BOOL "ON" FORCE) # no Quicktime in 64bit
+       endif()
 endif()
 
 
@@ -330,12 +358,20 @@ if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
        message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
 endif()
 
-if(NOT WITH_AUDASPACE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK OR WITH_GAMEENGINE))
-       message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK/WITH_CODEC_FFMPEG/WITH_GAMEENGINE require WITH_AUDASPACE")
+if(NOT WITH_AUDASPACE)
+       if(WITH_OPENAL)
+               message(FATAL_ERROR "WITH_OPENAL requires WITH_AUDASPACE")
+       endif()
+       if(WITH_JACK)
+               message(FATAL_ERROR "WITH_JACK requires WITH_AUDASPACE")
+       endif()
+       if(WITH_GAMEENGINE)
+               message(FATAL_ERROR "WITH_GAMEENGINE requires WITH_AUDASPACE")
+       endif()
 endif()
 
 if(NOT WITH_SDL AND WITH_GHOST_SDL)
-       message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL to be ON")
+       message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL")
 endif()
 
 if(WITH_IMAGE_REDCODE AND ((NOT WITH_IMAGE_OPENJPEG) OR (NOT WITH_CODEC_FFMPEG)))
@@ -352,10 +388,6 @@ if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
 endif()
 
 
-if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
-       message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
-endif()
-
 # may as well build python module without a UI
 if(WITH_PYTHON_MODULE)
        set(WITH_HEADLESS ON)
@@ -366,12 +398,30 @@ if(WITH_CYCLES)
        set(WITH_OPENIMAGEIO ON)
 endif()
 
-# auto enable boost for cycles and booleans
-if(WITH_CYCLES OR WITH_MOD_BOOLEAN)
-       set(WITH_BOOST ON)
+# enable boost for cycles, booleans, audaspace or i18n
+# otherwise if the user disabled
+if(NOT WITH_BOOST)
+       # Explicitly disabled. so disable all deps.
+       set(WITH_CYCLES         OFF)
+       set(WITH_MOD_BOOLEAN    OFF)
+       set(WITH_AUDASPACE      OFF)
+       set(WITH_INTERNATIONAL  OFF)
+
+       set(WITH_OPENAL         OFF)  # depends on AUDASPACE
+       set(WITH_GAMEENGINE     OFF)  # depends on AUDASPACE
+elseif(WITH_CYCLES OR WITH_MOD_BOOLEAN OR WITH_AUDASPACE OR WITH_INTERNATIONAL)
+       # Keep enabled
+else()
+       # Enabled but we don't need it
+       set(WITH_BOOST OFF)
+endif()
+
+# auto enable llvm for cycles_osl
+if(WITH_CYCLES_OSL)
+       set(WITH_LLVM ON CACHE BOOL "ON" FORCE)
 endif()
 
-# don't store paths to libs for portable distrobution
+# don't store paths to libs for portable distribution
 if(WITH_INSTALL_PORTABLE)
        set(CMAKE_SKIP_BUILD_RPATH TRUE)
 endif()
@@ -392,6 +442,13 @@ endif()
 
 TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
 
+TEST_STDBOOL_SUPPORT()
+if(HAVE_STDBOOL_H)
+       add_definitions(-DHAVE_STDBOOL_H)
+endif()
+if(WITH_BOOL_COMPAT)
+       add_definitions(-DWITH_BOOL_COMPAT)
+endif()
 
 #-----------------------------------------------------------------------------
 # Check for valid directories
@@ -450,14 +507,14 @@ 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.2 \
-#         -D PYTHON_INCLUDE_DIR=/opt/py32/include/python3.2d \
-#         -D PYTHON_LIBRARY=/opt/py32/lib/libpython3.2d.so
+#         -D PYTHON_VERSION=3.3 \
+#         -D PYTHON_INCLUDE_DIR=/opt/py33/include/python3.3d \
+#         -D PYTHON_LIBRARY=/opt/py33/lib/libpython3.3d.so
 #
 # On Macs:
 #   cmake ../blender \
-#         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2 \
-#         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config \
+#         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3 \
+#         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config \
 #         -G Xcode
 #
 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
@@ -466,50 +523,52 @@ set(PLATFORM_LINKFLAGS_DEBUG "")
 #Platform specifics
 
 if(UNIX AND NOT APPLE)
-
-       # set lib directory if it exists
-       if(CMAKE_SYSTEM_NAME MATCHES "Linux")
-               if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
-                       set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/linux64)
-               else()
-                       set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/linux)
+       macro(find_package_wrapper)
+               STRING(TOUPPER ${ARGV0} _NAME_UPPER)
+               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()
-
-               if(NOT EXISTS ${LIBDIR})
-                       unset(LIBDIR)
+               find_package(${ARGV})
+               if(${WITH_STATIC_LIBS})
+                       set(CMAKE_FIND_LIBRARY_SUFFIXES ${_cmake_find_library_suffixes_back})
+                       unset(_cmake_find_library_suffixes_back)
                endif()
-       endif()
+       endmacro()
 
-       find_package(JPEG REQUIRED)
-       find_package(PNG REQUIRED)
-       find_package(ZLIB REQUIRED)
-       find_package(Freetype REQUIRED)
+       find_package_wrapper(JPEG REQUIRED)
+       find_package_wrapper(PNG REQUIRED)
+       find_package_wrapper(ZLIB REQUIRED)
+       find_package_wrapper(Freetype REQUIRED)
 
        if(WITH_PYTHON)
-               # No way to set py32. remove for now.
+               # No way to set py33. remove for now.
                # find_package(PythonLibs)
 
                # Use our own instead, since wothout py is such a rare case,
                # require this package
+               # XXX Linking errors with debian static python :/
+#              find_package_wrapper(PythonLibsUnix REQUIRED)
                find_package(PythonLibsUnix REQUIRED)
        endif()
 
-
        if(WITH_IMAGE_OPENEXR)
-               find_package(OpenEXR)  # our own module
+               find_package_wrapper(OpenEXR)  # our own module
                if(NOT OPENEXR_FOUND)
                        set(WITH_IMAGE_OPENEXR OFF)
                endif()
        endif()
 
        if(WITH_IMAGE_OPENJPEG)
-               find_package(OpenJPEG)
+               find_package_wrapper(OpenJPEG)
                if(NOT OPENJPEG_FOUND)
                        set(WITH_IMAGE_OPENJPEG OFF)
                endif()
        endif()
 
        if(WITH_IMAGE_TIFF)
+               # XXX Linking errors with debian static tiff :/
+#              find_package_wrapper(TIFF)
                find_package(TIFF)
                if(NOT TIFF_FOUND)
                        set(WITH_IMAGE_TIFF OFF)
@@ -518,14 +577,14 @@ if(UNIX AND NOT APPLE)
 
        # Audio IO
        if(WITH_OPENAL)
-               find_package(OpenAL)
+               find_package_wrapper(OpenAL)
                if(NOT OPENAL_FOUND)
                        set(WITH_OPENAL OFF)
                endif()
        endif()
 
        if(WITH_SDL)
-               find_package(SDL)
+               find_package_wrapper(SDL)
                mark_as_advanced(
                        SDLMAIN_LIBRARY
                        SDL_INCLUDE_DIR
@@ -539,7 +598,7 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_JACK)
-               find_package(Jack)
+               find_package_wrapper(Jack)
                if(NOT JACK_FOUND)
                        set(WITH_JACK OFF)
                endif()
@@ -547,29 +606,22 @@ if(UNIX AND NOT APPLE)
 
        # Codecs
        if(WITH_CODEC_SNDFILE)
-               find_package(SndFile)
+               find_package_wrapper(SndFile)
                if(NOT SNDFILE_FOUND)
                        set(WITH_CODEC_SNDFILE OFF)
                endif()
        endif()
 
        if(WITH_CODEC_FFMPEG)
-               # use lib dir if available and nothing else specified
-               if(LIBDIR AND NOT FFMPEG)
-                       set(FFMPEG ${LIBDIR}/ffmpeg CACHE PATH "FFMPEG Directory")
-                       # XXX, some distros might need 'theoraenc theoradec' too
-                       set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale dirac_encoder mp3lame ogg orc-0.4 schroedinger-1.0 theora vorbis vorbisenc vpx x264 xvidcore faad asound CACHE STRING "FFMPEG Libraries")
-               else()
-                       set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
-                       set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
-               endif()
+               set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
+               set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
 
                mark_as_advanced(FFMPEG)
 
-               # lame, but until we have propper find module for ffmpeg
+               # lame, but until we have proper find module for ffmpeg
                set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
                if(EXISTS "${FFMPEG}/include/ffmpeg/")
-                       set(FFMPEG_INCLUDE_DIRS "${FFMPEG_INCLUDE_DIRS} ${FFMPEG}/include/ffmpeg")
+                       list(APPEND FFMPEG_INCLUDE_DIRS "${FFMPEG}/include/ffmpeg")
                endif()
                # end lameness
 
@@ -578,54 +630,32 @@ if(UNIX AND NOT APPLE)
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
        endif()
 
-       if(WITH_INTERNATIONAL)
-               find_library(INTL_LIBRARY
-                       NAMES intl
-                       PATHS
-                       /sw/lib
-               )
-
-               find_library(ICONV_LIBRARY
-                       NAMES iconv
-                       PATHS
-                       /sw/lib
-               )
-               mark_as_advanced(
-                       ICONV_LIBRARY
-                       INTL_LIBRARY
-               )
-
-               if(INTL_LIBRARY AND ICONV_LIBRARY)
-                       set(GETTEXT_LIBRARIES ${INTL_LIBRARY} ${ICONV_LIBRARY})
-               endif()
-       endif()
-
        if(WITH_FFTW3)
-               find_package(Fftw3)
+               find_package_wrapper(Fftw3)
                if(NOT FFTW3_FOUND)
                        set(WITH_FFTW3 OFF)
                endif()
        endif()
 
        if(WITH_OPENCOLLADA)
-               find_package(OpenCOLLADA)
+               find_package_wrapper(OpenCOLLADA)
                if(OPENCOLLADA_FOUND)
-                       find_package(XML2)
-                       find_package(PCRE)
+                       find_package_wrapper(XML2)
+                       find_package_wrapper(PCRE)
                else()
                        set(WITH_OPENCOLLADA OFF)
                endif()
        endif()
 
        if(WITH_MEM_JEMALLOC)
-               find_package(JeMalloc)
+               find_package_wrapper(JeMalloc)
                if(NOT JEMALLOC_FOUND)
                        set(WITH_MEM_JEMALLOC OFF)
                endif()
        endif()
 
        if (WITH_INPUT_NDOF)
-               find_package(Spacenav)
+               find_package_wrapper(Spacenav)
                if(NOT SPACENAV_FOUND)
                        set(WITH_INPUT_NDOF OFF)
                endif()
@@ -640,17 +670,17 @@ if(UNIX AND NOT APPLE)
        if(WITH_BOOST)
                # uses in build instructions to override include and library variables
                if(NOT BOOST_CUSTOM)
-                       # use lib dir if available and nothing else specified
-                       if(LIBDIR AND NOT BOOST_ROOT)
-                               set(BOOST_ROOT ${LIBDIR}/boost)
-                               set(Boost_USE_MULTITHREADED OFF)
-                       else()
-                               set(Boost_USE_MULTITHREADED ON)
+                       if(${WITH_STATIC_LIBS})
+                               set(Boost_USE_STATIC_LIBS ON)
                        endif()
-                       if(WITH_CYCLES_OSL)
-                               find_package(Boost 1.34 COMPONENTS filesystem python3 regex system thread) # osl_nodes uses boost_python
-                       else()
-                               find_package(Boost 1.34 COMPONENTS filesystem regex system thread)
+                       set(Boost_USE_MULTITHREADED ON)
+                       set(__boost_packages filesystem regex system thread date_time)
+                       if (WITH_INTERNATIONAL)
+                               list(APPEND __boost_packages locale)
+                       endif()
+                       find_package(Boost 1.48 COMPONENTS ${__boost_packages})
+                       if(Boost_USE_STATIC_LIBS AND Boost_USE_ICU)
+                               find_package(IcuLinux)
                        endif()
                        mark_as_advanced(Boost_DIR)  # why doesnt boost do this?
                endif()
@@ -662,12 +692,7 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_OPENIMAGEIO)
-               # use lib dir if available and nothing else specified
-               if(LIBDIR AND NOT OPENIMAGEIO_ROOT_DIR)
-                       set(OPENIMAGEIO_ROOT_DIR ${LIBDIR}/oiio)
-               endif()
-
-               find_package(OpenImageIO)
+               find_package_wrapper(OpenImageIO)
 
                set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
                set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
@@ -687,12 +712,7 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_OPENCOLORIO)
-               # use lib dir if available and nothing else specified
-               if(LIBDIR AND NOT OPENCOLORIO_ROOT_DIR)
-                       set(OPENCOLORIO_ROOT_DIR ${LIBDIR}/ocio)
-               endif()
-
-               find_package(OpenColorIO)
+               find_package_wrapper(OpenColorIO)
 
                set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES})
                set(OPENCOLORIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
@@ -704,6 +724,60 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
+       # XXX Maybe most of this section should go into an llvm module?
+       if(WITH_LLVM)
+               # Set llvm version if not specified
+               if(NOT LLVM_VERSION)
+                       set(LLVM_VERSION "3.0")
+               endif()
+               set(LLVM_STATIC YES)
+               if(LLVM_DIRECTORY)
+                       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)
+                       endif()
+               else()
+                       FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION})
+                       if(NOT 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)
+               find_library(LLVM_LIBRARY
+                            NAMES LLVMAnalysis # first of a whole bunch of libs to get
+                            PATHS ${LLVM_LIB_DIR})
+               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_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
+                               # way for LLVM_LIBRARY.
+                               execute_process(COMMAND ${LLVM_CONFIG} --libfiles
+                                               OUTPUT_VARIABLE LLVM_LIBRARY
+                                               OUTPUT_STRIP_TRAILING_WHITESPACE)
+                               string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
+                       endif()
+               else()
+                       message(FATAL_ERROR "LLVM not found.")
+               endif()
+
+               # Fix for conflict with Mesa llvmpipe
+               set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/source/creator/blender.map")
+       endif()
+
        if(WITH_CYCLES_OSL)
                set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
        
@@ -712,8 +786,9 @@ if(UNIX AND NOT APPLE)
                find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
-               # WARNING! depends on correct order of OSL libs linking
-               list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
+               # Note: --whole-archive is needed to force loading of all symbols in liboslexec,
+               # otherwise LLVM is missing the osl_allocate_closure_component function
+               list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -Wl,--whole-archive ${OSL_LIB_EXEC} -Wl,--no-whole-archive ${OSL_LIB_QUERY})
                find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
                find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
        
@@ -725,8 +800,6 @@ if(UNIX AND NOT APPLE)
                else()
                        message(STATUS "OSL not found")
                endif()
-       
-               include_directories(${OSL_INCLUDES})
        endif()
 
        # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
@@ -740,7 +813,11 @@ if(UNIX AND NOT APPLE)
                set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_X11_LIB}")
 
                if(WITH_X11_XINPUT)
-                       set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_Xinput_LIB}")
+                       if(X11_Xinput_LIB)
+                               set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_Xinput_LIB}")
+                       else()
+                               set(WITH_X11_XINPUT OFF)
+                       endif()
                endif()
 
                if(WITH_X11_XF86VMODE)
@@ -765,7 +842,7 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
-       set(PLATFORM_LINKFLAGS "-pthread")
+       set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -pthread")
 
        # lfs on glibc, all compilers should use
        add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
@@ -777,7 +854,7 @@ if(UNIX AND NOT APPLE)
        elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
                set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
        # Solaris CC
-       elseif(CMAKE_CXX_COMPILER_ID MATCHES "SunPro") 
+       elseif(CMAKE_CXX_COMPILER_ID MATCHES "SunPro")
                set(PLATFORM_CFLAGS "-pipe -features=extensions -fPIC -D__FUNCTION__=__func__")
                
        # Intel C++ Compiler
@@ -810,10 +887,18 @@ elseif(WIN32)
 
        if(CMAKE_COMPILER_IS_GNUCC)
                set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
-
-               # Setup 64bit and 64bit windows systems         
+               INCLUDE (CheckCSourceCompiles) 
+               # Setup 64bit and 64bit windows systems
+               CHECK_C_SOURCE_COMPILES("
+                       #ifndef __MINGW64__
+                       #error
+                       #endif
+                       main(){}
+                       " 
+                       WITH_MINGW64)
+               
                if(WITH_MINGW64)
-                       message("Set 64 bit compiler for MinGW.")
+                       message("Compiling for 64 bit with MinGW-w64.")
                        set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
                endif()
        else()
@@ -828,13 +913,6 @@ elseif(WIN32)
                
        add_definitions(-DWIN32)
 
-       if(WITH_INTERNATIONAL)
-               set(ICONV ${LIBDIR}/iconv)
-               set(ICONV_INCLUDE_DIRS ${ICONV}/include)
-               set(ICONV_LIBRARIES iconv)
-               set(ICONV_LIBPATH ${ICONV}/lib)
-       endif()
-
        set(JPEG "${LIBDIR}/jpeg")
        set(JPEG_INCLUDE_DIR "${JPEG}/include")
        set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
@@ -876,30 +954,22 @@ elseif(WIN32)
        if(WITH_CYCLES_OSL)
                set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
        
-               message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
-       
                find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
-               # WARNING! depends on correct order of OSL libs linking
                list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
                find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
                find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
        
                if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
                        set(OSL_FOUND TRUE)
-                       message(STATUS "OSL includes = ${OSL_INCLUDES}")
-                       message(STATUS "OSL library = ${OSL_LIBRARIES}")
-                       message(STATUS "OSL compiler = ${OSL_COMPILER}")
                else()
                        message(STATUS "OSL not found")
                endif()
-       
-               include_directories(${OSL_INCLUDES})
        endif()
 
        if(MSVC)
-               set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
+               set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid psapi)
 
                add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB)
 
@@ -929,17 +999,10 @@ elseif(WIN32)
                set(CXX_WARNINGS "${_WARNINGS}")
                unset(_WARNINGS)
 
-               if(WITH_INTERNATIONAL)
-                       set(GETTEXT ${LIBDIR}/gettext)
-                       set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
-                       set(GETTEXT_LIBPATH ${GETTEXT}/lib)
-                       set(GETTEXT_LIBRARIES gnu_gettext)
-               endif()
-               
                if(WITH_MOD_CLOTH_ELTOPO)
                        set(LAPACK ${LIBDIR}/lapack)
                        # set(LAPACK_INCLUDE_DIR ${LAPACK}/include)
-                       set(LAPACK_LIBPATH ${LAPACK}/lib)       
+                       set(LAPACK_LIBPATH ${LAPACK}/lib)
                        set(LAPACK_LIBRARIES
                                ${LIBDIR}/lapack/lib/libf2c.lib
                                ${LIBDIR}/lapack/lib/clapack_nowrap.lib
@@ -1027,6 +1090,7 @@ elseif(WIN32)
                if(WITH_IMAGE_OPENEXR)
                        set_lib_path(OPENEXR "openexr")
                        set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
+                       set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
                        set(OPENEXR_LIBPATH ${OPENEXR}/lib)
                        set(OPENEXR_LIBRARIES
                                ${OPENEXR_LIBPATH}/Iex.lib
@@ -1035,12 +1099,6 @@ elseif(WIN32)
                                ${OPENEXR_LIBPATH}/Imath.lib
                                ${OPENEXR_LIBPATH}/IlmThread.lib
                        )
-                       set(OPENEXR_INCLUDE_DIRS
-                               ${OPENEXR_INCLUDE_DIR}
-                               ${OPENEXR_INCLUDE_DIR}/IlmImf
-                               ${OPENEXR_INCLUDE_DIR}/Iex
-                               ${OPENEXR_INCLUDE_DIR}/Imath
-                       )
                endif()
 
                if(WITH_IMAGE_TIFF)
@@ -1058,9 +1116,19 @@ elseif(WIN32)
 
                if(WITH_PYTHON)
                        # normally cached but not since we include them with blender
-                       set(PYTHON_VERSION 3.2) # CACHE STRING)
+                       if(MSVC10)
+                               set(PYTHON_VERSION 3.3) # CACHE STRING)
+                       else()
+                               set(PYTHON_VERSION 3.3) # CACHE STRING)
+                       endif()
+
                        set_lib_path(PYTHON "python")
-                       set(PYTHON_LIBRARY ${PYTHON}/lib/python32.lib) #CACHE FILEPATH
+                       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
                        set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION})
 
@@ -1073,13 +1141,13 @@ elseif(WIN32)
                        set(BOOST ${LIBDIR}/boost)
                        set(BOOST_INCLUDE_DIR ${BOOST}/include)
                        if(MSVC10)
-                               set(BOOST_LIBPATH ${BOOST}/lib/vc_10)
+                               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")
-                               set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib")                                 
+                               set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib")
                        endif()
                        set(BOOST_LIBRARIES
                                optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX}
@@ -1088,23 +1156,33 @@ elseif(WIN32)
                                debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX}
                                debug libboost_regex-${BOOST_DEBUG_POSTFIX}
                                debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX})
-                               if(WITH_CYCLES_OSL)
-                                       set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
-                                               optimized libboost_python3-${BOOST_POSTFIX}
-                                               debug libboost_python3-${BOOST_DEBUG_POSTFIX})
-                               endif(WITH_CYCLES_OSL)
-                               
+                       if(WITH_CYCLES_OSL)
+                               set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
+                                       optimized libboost_wave-${BOOST_POSTFIX}
+                                       debug libboost_wave-${BOOST_DEBUG_POSTFIX})
+                       endif()
+                       if(WITH_INTERNATIONAL)
+                               set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
+                                       optimized libboost_locale-${BOOST_POSTFIX}
+                                       debug libboost_locale-${BOOST_DEBUG_POSTFIX})
+                       endif()
                        set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
                endif()
                        
                if(WITH_OPENIMAGEIO)
                        set(OPENIMAGEIO ${LIBDIR}/openimageio)
                        set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
-                       set(OPENIMAGEIO_LIBRARIES OpenImageIO)
+                       set(OPENIMAGEIO_LIBRARIES optimized OpenImageIO debug OpenImageIO_d)
                        set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
-                       set(OPENIMAGEIO_DEFINITIONS)
+                       set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
                endif()
 
+               if(WITH_LLVM)
+                       set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
+                       file(GLOB LLVM_LIBRARY ${LLVM_DIRECTORY}/lib/*.lib)
+                       set(LLVM_STATIC YES)
+               endif()
+       
                if(WITH_OPENCOLORIO)
                        set(OPENCOLORIO ${LIBDIR}/opencolorio)
                        set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
@@ -1113,6 +1191,7 @@ elseif(WIN32)
                        set(OPENCOLORIO_DEFINITIONS)
                endif()
 
+
                set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
 
                # MSVC only, Mingw doesnt need
@@ -1128,7 +1207,7 @@ elseif(WIN32)
                blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
 
        elseif(CMAKE_COMPILER_IS_GNUCC)
-       # keep GCC specific stuff here          
+       # keep GCC specific stuff here
                set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi")
                set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
 
@@ -1147,16 +1226,8 @@ elseif(WIN32)
 
                add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
 
-
                add_definitions(-DFREE_WINDOWS)
 
-               if(WITH_INTERNATIONAL)
-                       set(GETTEXT ${LIBDIR}/gettext)
-                       set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
-                       set(GETTEXT_LIBPATH ${GETTEXT}/lib)
-                       set(GETTEXT_LIBRARIES intl)
-               endif()
-               
                set(PNG "${LIBDIR}/png")
                set(PNG_INCLUDE_DIR "${PNG}/include")
                set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
@@ -1176,7 +1247,7 @@ elseif(WIN32)
                #comes with own pthread library
                if(NOT WITH_MINGW64)
                        set(PTHREADS ${LIBDIR}/pthreads)
-                       set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
+                       #set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
                        set(PTHREADS_LIBPATH ${PTHREADS}/lib)
                        set(PTHREADS_LIBRARIES pthreadGC2)
                endif()
@@ -1224,6 +1295,7 @@ elseif(WIN32)
 
                if(WITH_IMAGE_OPENEXR)
                        set(OPENEXR ${LIBDIR}/openexr)
+                       set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
                        set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
                        set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
                        set(OPENEXR_LIBPATH ${OPENEXR}/lib)
@@ -1248,9 +1320,9 @@ elseif(WIN32)
 
                if(WITH_PYTHON)
                        # normally cached but not since we include them with blender
-                       set(PYTHON_VERSION 3.2) #  CACHE STRING)
+                       set(PYTHON_VERSION 3.3) #  CACHE STRING)
                        set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
-                       set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32mw.lib")  # CACHE FILEPATH)
+                       set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python33mw.lib")  # CACHE FILEPATH)
 
                        # uncached vars
                        set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
@@ -1266,7 +1338,7 @@ elseif(WIN32)
                        else()
                                set(BOOST_POSTFIX "mgw46-mt-s-1_49")
                                set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_49")
-                       endif()         
+                       endif()
                        set(BOOST_LIBRARIES
                                optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX}
                                boost_regex-${BOOST_POSTFIX}
@@ -1274,12 +1346,16 @@ elseif(WIN32)
                                debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX}
                                boost_regex-${BOOST_DEBUG_POSTFIX}
                                boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX})
-                               if(WITH_CYCLES_OSL)
-                                       set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
-                                               optimized libboost_python3-${BOOST_POSTFIX}
-                                               debug libboost_python3-${BOOST_DEBUG_POSTFIX}) 
-                               endif(WITH_CYCLES_OSL)
-                                       
+                       if(WITH_INTERNATIONAL)
+                               set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
+                                       optimized boost_locale-${BOOST_POSTFIX}
+                                       debug boost_locale-${BOOST_DEBUG_POSTFIX}) 
+                       endif()
+                       if(WITH_CYCLES_OSL)
+                               set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
+                                       optimized boost_wave-${BOOST_POSTFIX}
+                                       debug boost_wave-${BOOST_DEBUG_POSTFIX}) 
+                       endif()
                        set(BOOST_LIBPATH ${BOOST}/lib)
                        set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ")
                endif()
@@ -1292,6 +1368,34 @@ elseif(WIN32)
                        set(OPENIMAGEIO_DEFINITIONS)
                endif()
                
+               if(WITH_LLVM)
+                       set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
+                       set(LLVM_LIB_DIR ${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
+                               LLVMAsmParser LLVMAsmPrinter
+                               LLVMBitReader LLVMBitWriter
+                               LLVMDebugInfo LLVMExecutionEngine
+                               LLVMInstCombine LLVMInstrumentation
+                               LLVMInterpreter LLVMJIT
+                               LLVMLinker LLVMMC
+                               LLVMMCDisassembler LLVMMCJIT
+                               LLVMMCParser LLVMObject
+                               LLVMRuntimeDyld 
+                               LLVMSupport
+                               LLVMTableGen LLVMTarget
+                               LLVMTransformUtils LLVMVectorize
+                               LLVMX86AsmParser LLVMX86AsmPrinter
+                               LLVMX86CodeGen LLVMX86Desc
+                               LLVMX86Disassembler LLVMX86Info
+                               LLVMX86Utils LLVMipa
+                               LLVMipo LLVMCore)
+                               #imagehelp is needed by LLVM 3.1 on MinGW, check lib\Support\Windows\Signals.inc
+                               set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -limagehlp")
+                       set(LLVM_STATIC YES)
+               endif()
+               
                if(WITH_OPENCOLORIO)
                        set(OPENCOLORIO ${LIBDIR}/opencolorio)
                        set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
@@ -1303,7 +1407,7 @@ elseif(WIN32)
                set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152")
 
                ## DISABLE - causes linking errors 
-               ## for re-distrobution, so users dont need mingw installed
+               ## for re-distribution, so users dont need mingw installed
                # set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-libgcc -static-libstdc++")
 
        endif()
@@ -1314,16 +1418,6 @@ elseif(APPLE)
                set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/10.7
        endif()
 
-       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)
-               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(WITH_LIBS10.5)
                set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
        else()
@@ -1346,10 +1440,13 @@ elseif(APPLE)
        endif()
 
        if(WITH_JACK)
-               set(JACK /usr)
-               set(JACK_INCLUDE_DIRS ${JACK}/include/jack)
-               set(JACK_LIBRARIES jack)
-               set(JACK_LIBPATH ${JACK}/lib)
+               find_library(JACK_FRAMEWORK
+                       NAMES jackmp
+               )
+               set(JACK_INCLUDE_DIRS ${JACK_FRAMEWORK}/headers)
+               if(NOT JACK_FRAMEWORK)
+                       set(WITH_JACK OFF)
+               endif()
        endif()
 
        if(WITH_CODEC_SNDFILE)
@@ -1361,24 +1458,24 @@ elseif(APPLE)
 
        if(WITH_PYTHON)
                if(NOT WITH_PYTHON_MODULE)
-                       # we use precompiled libraries for py 3.2 and up by default
+                       # we use precompiled libraries for py 3.3 and up by default
 
                        # normally cached but not since we include them with blender
-                       set(PYTHON_VERSION 3.2)
-                       set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")
+                       set(PYTHON_VERSION 3.3)
+                       set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
                        # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
-                       set(PYTHON_LIBRARY python${PYTHON_VERSION})
+                       set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
                        set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
                        # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
                else()
                        # module must be compiled against Python framework
 
                        # normally cached but not since we include them with blender
-                       set(PYTHON_VERSION 3.2)
+                       set(PYTHON_VERSION 3.3)
                        set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
                        set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
                        #set(PYTHON_LIBRARY python${PYTHON_VERSION})
-                       set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-3.2m")
+                       set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m")
                        #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python")  # won't  build with this enabled
                endif()
                
@@ -1387,13 +1484,6 @@ elseif(APPLE)
                set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
        endif()
 
-       if(WITH_INTERNATIONAL)
-               set(GETTEXT ${LIBDIR}/gettext)
-               set(GETTEXT_INCLUDE_DIRS "${GETTEXT}/include")
-               set(GETTEXT_LIBRARIES intl iconv)
-               set(GETTEXT_LIBPATH ${GETTEXT}/lib)
-       endif()
-
        if(WITH_FFTW3)
                set(FFTW3 ${LIBDIR}/fftw3)
                set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
@@ -1415,6 +1505,7 @@ elseif(APPLE)
 
        if(WITH_IMAGE_OPENEXR)
                set(OPENEXR ${LIBDIR}/openexr)
+               set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
                set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
                set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread)
                set(OPENEXR_LIBPATH ${OPENEXR}/lib)
@@ -1459,18 +1550,23 @@ elseif(APPLE)
                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(3D_CONNEXION_CLIENT_LIBRARY
+                       find_library(3DCONNEXION_CLIENT_FRAMEWORK
                                NAMES 3DconnexionClient
                        )
-                       if(NOT 3D_CONNEXION_CLIENT_LIBRARY)
+                       if(NOT 3DCONNEXION_CLIENT_FRAMEWORK)
                                set(WITH_INPUT_NDOF OFF)
                        endif()
 
                        if(WITH_INPUT_NDOF)
-                               set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -weak_framework 3DconnexionClient")
+                               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} -weak_framework jackmp")
+       endif()
+
        else()
                set(PLATFORM_CFLAGS "-pipe -funsigned-char")
                set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
@@ -1533,11 +1629,11 @@ elseif(APPLE)
        if(WITH_BOOST)
                set(BOOST ${LIBDIR}/boost)
                set(BOOST_INCLUDE_DIR ${BOOST}/include)
-               if(WITH_CYCLES_OSL)
-                       set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_python3-mt boost_regex-mt boost_system-mt boost_thread-mt)
-               else(WITH_CYCLES_OSL)
-                       set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
-               endif(WITH_CYCLES_OSL)
+               set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt)
+               if (WITH_INTERNATIONAL)
+                       list(APPEND BOOST_LIBRARIES boost_locale-mt)
+                       set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale needs it !
+               endif()
                set(BOOST_LIBPATH ${BOOST}/lib)
                set(BOOST_DEFINITIONS)
        endif()
@@ -1545,7 +1641,7 @@ elseif(APPLE)
        if(WITH_OPENIMAGEIO)
                set(OPENIMAGEIO ${LIBDIR}/openimageio)
                set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
-               set(OPENIMAGEIO_LIBRARIES -force_load ${OPENIMAGEIO}/lib/libOpenImageIO.a ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
+               set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO}/lib/libOpenImageIO.a ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
                set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
                set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
        endif()
@@ -1558,11 +1654,46 @@ elseif(APPLE)
                set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
        endif()
 
+       if(WITH_LLVM)
+               set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
+               set(LLVM_VERSION "3.1" CACHE STRING     "Version of LLVM to use")
+               set(LLVM_STATIC YES)
+               if(EXISTS "${LLVM_DIRECTORY}/bin/llvm-config")
+                       set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
+               else()
+                       set(LLVM_CONFIG llvm-config)
+               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)
+               find_library(LLVM_LIBRARY
+                            NAMES LLVMAnalysis # first of a whole bunch of libs to get
+                            PATHS ${LLVM_LIB_DIR})
+
+               if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
+                       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
+                               # way for LLVM_LIBRARY.
+                               execute_process(COMMAND ${LLVM_CONFIG} --libfiles
+                                               OUTPUT_VARIABLE LLVM_LIBRARY
+                                               OUTPUT_STRIP_TRAILING_WHITESPACE)
+                               string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
+                       endif()
+               else()
+                       message(FATAL_ERROR "LLVM not found.")
+               endif()
+       endif()
+
        if(WITH_CYCLES_OSL)
                set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
        
-               message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
-       
                find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
                find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
@@ -1573,86 +1704,22 @@ elseif(APPLE)
        
                if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
                        set(OSL_FOUND TRUE)
-                       message(STATUS "OSL includes = ${OSL_INCLUDES}")
-                       message(STATUS "OSL library = ${OSL_LIBRARIES}")
-                       message(STATUS "OSL compiler = ${OSL_COMPILER}")
                else()
                        message(STATUS "OSL not found")
                endif()
-       
-               include_directories(${OSL_INCLUDES})
-               
-
-               # LLVM library setup, needed for osl 
-               
-               set(LLVM_DIRECTORY "${LIBDIR}/llvm")
-               set(LLVM_STATIC YES)
-               if (LLVM_DIRECTORY)
-                       set (LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
-               else ()
-                       set (LLVM_CONFIG llvm-config)
-               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)
-               execute_process (COMMAND ${LLVM_CONFIG} --includedir
-                                                OUTPUT_VARIABLE LLVM_INCLUDES
-                                        OUTPUT_STRIP_TRAILING_WHITESPACE)
-               find_library ( LLVM_LIBRARY
-                                          NAMES libLLVMAnalysis.a # first of a whole bunch of libs to get
-                                          PATHS ${LLVM_LIB_DIR})
-               message (STATUS "LLVM version  = ${LLVM_VERSION}")
-               message (STATUS "LLVM dir      = ${LLVM_DIRECTORY}")
-               message (STATUS "LLVM includes = ${LLVM_INCLUDES}")
-               message (STATUS "LLVM lib dir  = ${LLVM_LIB_DIR}")
-
-               if (LLVM_LIBRARY AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
-                 # ensure include directory is added (in case of non-standard locations
-                 include_directories (BEFORE "${LLVM_INCLUDES}")
-                 string (REGEX REPLACE "\\." "" OSL_LLVM_VERSION ${LLVM_VERSION})
-                 message (STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}")
-                 add_definitions ("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}")
-                 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
-                       # way for LLVM_LIBRARY.
-                       set (LLVM_LIBRARY "")
-                       execute_process (COMMAND ${LLVM_CONFIG} --libs
-                                                OUTPUT_VARIABLE llvm_library_list
-                                        OUTPUT_STRIP_TRAILING_WHITESPACE)
-                       string (REPLACE "-l" "" llvm_library_list ${llvm_library_list})
-                       string (REPLACE " " ";" llvm_library_list ${llvm_library_list})
-                       foreach (f ${llvm_library_list})
-                         list (APPEND LLVM_LIBRARY "${LLVM_LIB_DIR}/lib${f}.a")
-                       endforeach ()
-                 endif ()
-                 string (REPLACE ";" " " LLVM_LIBRARY "${LLVM_LIBRARY}")
-                 message (STATUS "LLVM library  = ${LLVM_LIBRARY}")
-               else ()
-                 message (FATAL_ERROR "LLVM not found.")
-               endif ()
-               set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${LLVM_LIBRARY}")
-               
-               # end LLVM library setup
-
        endif()
 
        set(EXETYPE MACOSX_BUNDLE)
 
        set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
        set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
-       if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
-               set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
-               set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
-       elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
-               set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
-               set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
+       if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386")
+               set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
+               set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic  -msse -msse2 -msse3 -mssse3")
+               if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+                       set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
+                       set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
+               endif()
        else()
                set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
                set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
@@ -1668,6 +1735,10 @@ if(APPLE OR WIN32)
        endif()
 endif()
 
+if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
+       message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
+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")
@@ -1675,8 +1746,19 @@ if(WITH_CYCLES)
        if(NOT WITH_BOOST)
                message(FATAL_ERROR "Cycles reqires 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")
+               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")
+       endif()
+endif()
 
 # See TEST_SSE_SUPPORT() for how this is defined.
 
@@ -1793,6 +1875,20 @@ else()
        set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
 endif()
 
+
+#-----------------------------------------------------------------------------
+# Configure Bullet
+
+if(WITH_BULLET AND WITH_SYSTEM_BULLET)
+       find_package(Bullet)
+       if(NOT BULLET_FOUND)
+               set(WITH_BULLET OFF)
+       endif()
+else()
+       set(BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src")
+       # set(BULLET_LIBRARIES "")
+endif()
+
 #-----------------------------------------------------------------------------
 # Configure Python.
 
@@ -1820,14 +1916,15 @@ if(CMAKE_COMPILER_IS_GNUCC)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_LOGICAL_OP -Wlogical-op)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEF -Wundef)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
        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)
 
-       # # this causes too many warnings, disable
-       # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEFINED -Wundef)
+       # gcc 4.2 gives annoying warnings on every file with this
+       if (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
+               ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
+       endif()
 
        # disable because it gives warnings for printf() & friends.
        # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
@@ -1839,14 +1936,21 @@ if(CMAKE_COMPILER_IS_GNUCC)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op)
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
        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_UNDEFINED -Wundef)
+
+       # gcc 4.2 gives annoying warnings on every file with this
+       if (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
+               ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
+       endif()
+
+       # causes too many warnings
+       if(NOT APPLE)
+               ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
+               ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
+       endif()
 
        # flags to undo strict flags
        ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
@@ -1911,12 +2015,13 @@ if(WITH_PYTHON)
 
        if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
                # set but invalid
-               if(NOT ${PYTHON_NUMPY_PATH} STREQUAL "")
-                       if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy")
-                               message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' "
-                                               "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
-                               set(WITH_PYTHON_INSTALL_NUMPY OFF)
-                       endif()
+        # -- disabled until we make numpy bundled with blender - campbell
+               if((NOT ${PYTHON_NUMPY_PATH} STREQUAL "") AND (NOT ${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
+#                      if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy")
+#                              message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' "
+#                                              "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
+#                              set(WITH_PYTHON_INSTALL_NUMPY OFF)
+#                      endif()
                # not set, so initialize
                else()
                        string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}")
@@ -1954,9 +2059,10 @@ if(WITH_PYTHON)
        endif()
 endif()
 
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
+# Include warnings first, so its possible to disable them with user defined flags
+# eg: -Wno-uninitialized
+set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
+set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}")
 
 #-------------------------------------------------------------------------------
 # Global Defines
@@ -2063,6 +2169,7 @@ if(FIRST_RUN)
        info_cfg_option(WITH_OPENAL)
        info_cfg_option(WITH_SDL)
        info_cfg_option(WITH_JACK)
+       info_cfg_option(WITH_CODEC_AVI)
        info_cfg_option(WITH_CODEC_FFMPEG)
        info_cfg_option(WITH_CODEC_SNDFILE)
 
@@ -2079,10 +2186,12 @@ if(FIRST_RUN)
        info_cfg_text("Modifiers:")
        info_cfg_option(WITH_MOD_BOOLEAN)
        info_cfg_option(WITH_MOD_REMESH)
-       info_cfg_option(WITH_MOD_DECIMATE)
        info_cfg_option(WITH_MOD_FLUID)
        info_cfg_option(WITH_MOD_OCEANSIM)
 
+       # debug
+       message(STATUS "HAVE_STDBOOL_H = ${HAVE_STDBOOL_H}")
+
        info_cfg_text("")
 
        message("${_config_msg}")