Bugfix: Crash in Sequencer when trying to undo after using Grease Pencil
[blender.git] / CMakeLists.txt
index 6c0b9157dbafa121a37cea4d6f483cc0fd5a2730..191fb61e1b4f593c21f3197f6895ce3aeb6a39dd 100644 (file)
@@ -1,4 +1,3 @@
-# -*- mode: cmake; indent-tabs-mode: t; -*-
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
 # This program is free software; you can redistribute it and/or
@@ -103,8 +102,8 @@ enable_testing()
 #-----------------------------------------------------------------------------
 # Redirect output files
 
-set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE )
-set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
+set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
+set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)
 
 #-----------------------------------------------------------------------------
 # Set default config options
@@ -124,12 +123,12 @@ mark_as_advanced(WITH_PYTHON)  # dont want people disabling this unless they rea
 mark_as_advanced(WITH_PYTHON_SECURITY)  # some distrobutions 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 (experemental, only enable for development)" OFF)
+option(WITH_PYTHON_MODULE "Enable building as a python module (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_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
-option(WITH_GAMEENGINE    "Enable Game Engine" OFF)  # DISABLE FOR BMESH UNTIL NAVMESH IS WORKING
+option(WITH_GAMEENGINE    "Enable Game Engine" ON)
 option(WITH_PLAYER        "Build Player" OFF)
 
 # GHOST Windowing Library Options
@@ -149,17 +148,23 @@ mark_as_advanced(WITH_AUDASPACE)
 
 # (unix defaults to OpenMP On)
 if(UNIX AND NOT APPLE)
-       option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
+       set(PLATFORM_DEFAULT ON)
 else()
-       option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
+       set(PLATFORM_DEFAULT OFF)
 endif()
+option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ${PLATFORM_DEFAULT})
+unset(PLATFORM_DEFAULT)
+
 
 if(UNIX AND NOT APPLE)
        option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)"   ON)
        option(WITH_X11_XF86VMODE "Enable X11 video mode switching"     ON)
        option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
-       option(WITH_XDG_USER_DIRS    "Build with XDG Base Directory Specification (only config and documents for now)" OFF)
-       mark_as_advanced(WITH_XDG_USER_DIRS)
+
+       # freebsd doesn't seems to support XDND
+       if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+               option(WITH_GHOST_XDND   "Enable drag'n'drop support on Linux using XDND protocol" ON)
+       endif()
 else()
        # not an option for other OS's
        set(WITH_BUILTIN_GLEW ON)
@@ -171,7 +176,7 @@ 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 Experemental cloth solver" OFF)
+option(WITH_MOD_CLOTH_ELTOPO           "Enable Experimental cloth solver" OFF)
 mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
 option(WITH_MOD_OCEANSIM        "Enable Ocean Modifier" OFF)
 
@@ -187,6 +192,7 @@ option(WITH_IMAGE_FRAMESERVER   "Enable image FrameServer Support for rendering"
 
 # Audio/Video format support
 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)
 if(APPLE OR (WIN32 AND NOT UNIX))
        option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
@@ -218,13 +224,23 @@ if(UNIX AND NOT APPLE)
        option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
 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)
+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_13 sm_20 sm_21 CACHE STRING "CUDA architectures to build binaries for")
+set(CYCLES_CUDA_BINARIES_ARCH sm_13 sm_20 sm_21 CACHE STRING "CUDA architectures to build binaries for")
 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
+unset(PLATFORM_DEFAULT)
 
 # disable for now, but plan to support on all platforms eventually
 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
@@ -244,26 +260,55 @@ if(APPLE)
                "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
                FORCE)
        endif()
+       
+       execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version
+       if (${MAC_SYS} MATCHES 11)
+               set(OSX_SYSTEM 10.7)
+       elseif(${MAC_SYS} MATCHES 10)
+               set(OSX_SYSTEM 10.6)
+       elseif(${MAC_SYS} MATCHES 9)
+               set(OSX_SYSTEM 10.5)
+       else()
+               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
-               "Choose the minimum OSX version required: 10.4 or 10.5"
-               FORCE)
+                       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" AND (${XCODE_VERSION} VERSION_EQUAL 4 OR ${XCODE_VERSION} VERSION_GREATER 4))
-               # Xcode 4 defaults to the Apple LLVM Compiler.
-               # Override the default compiler selection because Blender only compiles with gcc
-               set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
-               message(STATUS "Setting compiler to: " ${CMAKE_XCODE_ATTRIBUTE_GCC_VERSION})
+
+       if(${CMAKE_GENERATOR} MATCHES "Xcode")
+       
+               ##### workaround for actual official cmake incompatibility with xcode 4.3 ##### 
+               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")
+               endif()
+               ### end workaround for actual official cmake incompatibility with xcode 4.3 ### 
+               
+               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.
+                       # Override the default compiler selection because Blender only compiles with gcc up to xcode 4.2
+                       set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
+                       message(STATUS "Setting compiler to: " ${CMAKE_XCODE_ATTRIBUTE_GCC_VERSION})
+               endif()
+       else() # unix makefile generator does not fill XCODE_VERSION var, so we get it with a command
+               execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE XCODE_VERS_BUILD_NR)
+               string(SUBSTRING "${XCODE_VERS_BUILD_NR}" 6 3 XCODE_VERSION) # truncate away build-nr
+               unset(XCODE_VERS_BUILD_NR)
        endif()
+       
+       message(STATUS "Detected Xcode-version: " ${XCODE_VERSION})
+       
        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)
 endif()
 
+
 #-----------------------------------------------------------------------------
 # Check for conflicting/unsupported configurations
 
-if(NOT WITH_BLENDER AND NOT WITH_PLAYER)
+if(NOT WITH_BLENDER AND NOT WITH_PLAYER AND NOT WITH_CYCLES_TEST)
        message(FATAL_ERROR "At least one of WITH_BLENDER or WITH_PLAYER must be enabled, nothing to do!")
 endif()
 
@@ -271,8 +316,8 @@ 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))
-       message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK/WITH_CODEC_FFMPEG require WITH_AUDASPACE")
+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")
 endif()
 
 if(NOT WITH_SDL AND WITH_GHOST_SDL)
@@ -292,13 +337,6 @@ if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
        message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
 endif()
 
-if(MINGW)
-       if(WITH_CODEC_QUICKTIME)
-               message(FATAL_ERROR "MINGW requires WITH_CODEC_QUICKTIME to be OFF "
-                                                       "because it is currently unsupported, remove this "
-                                                       "line if youre a developer who wants to add support.")
-       endif()
-endif()
 
 if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
        message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
@@ -319,13 +357,47 @@ if(WITH_CYCLES OR WITH_CARVE)
        set(WITH_BOOST ON)
 endif()
 
-TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
-
 # don't store paths to libs for portable distrobution
 if(WITH_INSTALL_PORTABLE)
        set(CMAKE_SKIP_BUILD_RPATH TRUE)
 endif()
 
+if(WITH_GHOST_SDL OR WITH_HEADLESS)
+       set(WITH_GHOST_XDND OFF)
+endif()
+
+if(MINGW)
+       if(WITH_CODEC_QUICKTIME)
+               message(FATAL_ERROR "MINGW requires WITH_CODEC_QUICKTIME to be OFF "
+                                   "because it is currently unsupported, remove this "
+                                   "line if youre a developer who wants to add support.")
+       endif()
+endif()
+
+TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
+
+
+#-----------------------------------------------------------------------------
+# Check for valid directories
+# ... svn extern paths can be missing because of svn-git.
+
+if(WITH_INTERNATIONAL)
+       if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
+               message(WARNING "Translation path '${CMAKE_SOURCE_DIR}/release/datafiles/locale' is missing, "
+                                               "This is an 'svn external', which are known not to work with bridges to other version "
+                                               "control systems, disabling 'WITH_INTERNATIONAL'.")
+               set(WITH_INTERNATIONAL OFF)
+       endif()
+endif()
+
+if(WITH_PYTHON)
+       if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/scripts/addons")
+               message(WARNING "Addons path '${CMAKE_SOURCE_DIR}/release/scripts/addons' is missing, "
+                                               "This is an 'svn external', which are known not to work with bridges to other version "
+                                               "control systems: * CONTINUING WITHOUT ADDONS *")
+       endif()
+endif()
+
 #-----------------------------------------------------------------------------
 # Initialize un-cached vars, avoid unused warning
 
@@ -482,7 +554,7 @@ if(UNIX AND NOT APPLE)
                endif()
 
                mark_as_advanced(FFMPEG)
-               set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
+               set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include ${FFMPEG}/include/ffmpeg)
                mark_as_advanced(FFMPEG_LIBRARIES)
                set(FFMPEG_LIBPATH ${FFMPEG}/lib)
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
@@ -575,10 +647,17 @@ if(UNIX AND NOT APPLE)
 
                find_package(OpenImageIO)
 
-               set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
+               set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
                set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
                set(OPENIMAGEIO_DEFINITIONS)
 
+               if(WITH_IMAGE_TIFF)
+                       list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}")
+               endif()
+               if(WITH_IMAGE_OPENEXR)
+                       list(APPEND OPENIMAGEIO_LIBRARIES "${OPENEXR_LIBRARIES}")
+               endif()
+
                if(NOT OPENIMAGEIO_FOUND)
                        set(WITH_OPENIMAGEIO OFF)
                        set(WITH_CYCLES OFF)
@@ -665,14 +744,24 @@ elseif(WIN32)
        # this file is included anyway when building under Windows with cl.exe
        #  include(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
 
-       set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
+       if(CMAKE_COMPILER_IS_GNUCC)
+               set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
 
-       # Setup 64bit and 64bit windows systems
-       if(CMAKE_CL_64)
-               message("64 bit compiler detected.")
-               set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
-       endif()
+               # Setup 64bit and 64bit windows systems         
+               if(WITH_MINGW64)
+                       message("Set 64 bit compiler for MinGW.")
+                       set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
+               endif()
+       else()
+               set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
 
+               # Setup 64bit and 64bit windows systems
+               if(CMAKE_CL_64)
+                       message("64 bit compiler detected.")
+                       set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
+               endif()
+       endif()
+               
        add_definitions(-DWIN32)
 
        if(WITH_INTERNATIONAL)
@@ -721,33 +810,35 @@ elseif(WIN32)
        endif()
 
        if(MSVC)
-               if(CMAKE_CL_64)
-                       set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
-               else()
-                       set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
-               endif()
+               set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
 
                add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB)
 
-               set(CMAKE_CXX_FLAGS "/nologo /J /W1 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013" CACHE STRING "MSVC MT C++ flags " FORCE)
-               set(CMAKE_C_FLAGS   "/nologo /J /W1 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013 /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
+               set(CMAKE_CXX_FLAGS "/nologo /J /Gd /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
+               set(CMAKE_C_FLAGS   "/nologo /J /Gd"       CACHE STRING "MSVC MT C++ flags " FORCE)
 
                if(CMAKE_CL_64)
-                       set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+                       set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
                else()
-                       set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
+                       set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
                endif()
-               set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
-               set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
-               set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
                if(CMAKE_CL_64)
-                       set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+                       set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
                else()
-                       set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
+                       set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
                endif()
-               set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
-               set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
-               set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
+
+               # most msvc warnings are C & C++
+               set(_WARNINGS "/W3 /wd4018 /wd4244 /wd4305 /wd4800 /wd4181 /wd4065 /wd4267 /we4013 /wd4200")
+               set(C_WARNINGS "${_WARNINGS}")
+               set(CXX_WARNINGS "${_WARNINGS}")
+               unset(_WARNINGS)
 
                if(WITH_INTERNATIONAL)
                        set(GETTEXT ${LIBDIR}/gettext)
@@ -755,6 +846,17 @@ elseif(WIN32)
                        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_lib_path(LAPACK_LIBPATH ${LAPACK}/lib)      
+                       set(LAPACK_LIBRARIES
+                               ${LIBDIR}/lapack/lib/libf2c.lib
+                               ${LIBDIR}/lapack/lib/clapack_nowrap.lib
+                               ${LIBDIR}/lapack/lib/BLAS_nowrap.lib
+                       )
+               endif()
 
                set(PNG_LIBRARIES libpng)
                set(JPEG_LIBRARIES libjpeg)
@@ -920,29 +1022,46 @@ elseif(WIN32)
 
                set(PLATFORM_LINKFLAGS_DEBUG "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
 
-       else()
-               # keep GCC specific stuff here
-               if(CMAKE_COMPILER_IS_GNUCC)
-                       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")
+               # used in many places so include globally, like OpenGL
+               blender_include_dirs("${PTHREADS_INCLUDE_DIRS}")
+
+       elseif(CMAKE_COMPILER_IS_GNUCC)
+       # 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")
 
-                       add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
+               if(WITH_MINGW64)
+                       #We need to take care though not to have these on debug builds because they may play funky with gdb
+                       if(CMAKE_BUILD_TYPE MATCHES "Release")
+                               set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -mmmx -ftree-vectorize")
+                       endif()
+                       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
+                       set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lpthread")
+                       
+                       add_definitions(-DFREE_WINDOWS64 -DMS_WIN64)
                endif()
 
+               add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
+
+
                add_definitions(-DFREE_WINDOWS)
 
                if(WITH_INTERNATIONAL)
-                       set(GETTEXT ${LIBDIR}/gcc/gettext)
+                       set(GETTEXT ${LIBDIR}/gettext)
                        set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
                        set(GETTEXT_LIBPATH ${GETTEXT}/lib)
                        set(GETTEXT_LIBRARIES intl)
                endif()
                
-               set(PNG "${LIBDIR}/gcc/png")
+               set(PNG "${LIBDIR}/png")
                set(PNG_INCLUDE_DIR "${PNG}/include")
                set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
 
-               set(JPEG_LIBRARIES libjpeg)
+               if(WITH_MINGW64)
+                       set(JPEG_LIBRARIES jpeg)
+               else()
+                       set(JPEG_LIBRARIES libjpeg)
+               endif()
                set(PNG_LIBRARIES png)
 
                set(ZLIB ${LIBDIR}/zlib)
@@ -950,53 +1069,64 @@ elseif(WIN32)
                set(ZLIB_LIBPATH ${ZLIB}/lib)
                set(ZLIB_LIBRARIES z)
 
-               set(PTHREADS ${LIBDIR}/pthreads)
-               set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
-               set(PTHREADS_LIBPATH ${PTHREADS}/lib)
-               set(PTHREADS_LIBRARIES pthreadGC2)
-
-               set(FREETYPE ${LIBDIR}/gcc/freetype)
+               #comes with own pthread library
+               if(NOT WITH_MINGW64)
+                       set(PTHREADS ${LIBDIR}/pthreads)
+                       set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
+                       set(PTHREADS_LIBPATH ${PTHREADS}/lib)
+                       set(PTHREADS_LIBRARIES pthreadGC2)
+               endif()
+               
+               set(FREETYPE ${LIBDIR}/freetype)
                set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
                set(FREETYPE_LIBPATH ${FREETYPE}/lib)
                set(FREETYPE_LIBRARY freetype)
 
                if(WITH_FFTW3)
-                       set(FFTW3 ${LIBDIR}/gcc/fftw3)
+                       set(FFTW3 ${LIBDIR}/fftw3)
                        set(FFTW3_LIBRARIES fftw3)
                        set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
                        set(FFTW3_LIBPATH ${FFTW3}/lib)
                endif()
 
                if(WITH_OPENCOLLADA)
-                       set(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
+                       set(OPENCOLLADA ${LIBDIR}/opencollada)
                        set(OPENCOLLADA_INCLUDE_DIRS
-                               ${LIBDIR}/gcc/opencollada/include/COLLADAStreamWriter/include
-                               ${LIBDIR}/gcc/opencollada/include/COLLADABaseUtils/include
-                               ${LIBDIR}/gcc/opencollada/include/COLLADAFramework/include
-                               ${LIBDIR}/gcc/opencollada/include/COLLADASaxFrameworkLoader/include
-                               ${LIBDIR}/gcc/opencollada/include/GeneratedSaxParser/include
+                               ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
+                               ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
+                               ${LIBDIR}/opencollada/include/COLLADAFramework/include
+                               ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
+                               ${LIBDIR}/opencollada/include/GeneratedSaxParser/include
                        )
                        set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
-                       set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
+                       if(WITH_MINGW64)
+                               set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa xml)
+                       else()
+                               set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
+                       endif()
                        set(PCRE_LIBRARIES pcre)
                endif()
 
                if(WITH_CODEC_FFMPEG)
                        set(FFMPEG ${LIBDIR}/ffmpeg)
-                       set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include ${FFMPEG}/include)
-                       set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
+                       set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
+                       if(WITH_MINGW64)
+                               set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll)
+                       else()
+                               set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
+                       endif()
                        set(FFMPEG_LIBPATH ${FFMPEG}/lib)
                endif()
 
                if(WITH_IMAGE_OPENEXR)
-                       set(OPENEXR ${LIBDIR}/gcc/openexr)
+                       set(OPENEXR ${LIBDIR}/openexr)
                        set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
                        set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
                        set(OPENEXR_LIBPATH ${OPENEXR}/lib)
                endif()
 
                if(WITH_IMAGE_TIFF)
-                       set(TIFF ${LIBDIR}/gcc/tiff)
+                       set(TIFF ${LIBDIR}/tiff)
                        set(TIFF_LIBRARY tiff)
                        set(TIFF_INCLUDE_DIR ${TIFF}/include)
                        set(TIFF_LIBPATH ${TIFF}/lib)
@@ -1026,19 +1156,24 @@ elseif(WIN32)
                if(WITH_BOOST)
                        set(BOOST ${LIBDIR}/boost)
                        set(BOOST_INCLUDE_DIR ${BOOST}/include)
-                       set(BOOST_POSTFIX "mgw45-mt-s-1_47")
-                       set(BOOST_DEBUG_POSTFIX "mgw45-mt-sd-1_47")
+                       if(WITH_MINGW64)
+                               set(BOOST_POSTFIX "mgw47-mt-s-1_49")
+                               set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49")
+                       else()
+                               set(BOOST_POSTFIX "mgw46-mt-s-1_47")
+                               set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_47")
+                       endif()         
                        set(BOOST_LIBRARIES
                                optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX}
                                boost_regex-${BOOST_POSTFIX} boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX}
                                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})
-                       set(BOOST_LIBPATH ${BOOST}/lib/gcc)
+                       set(BOOST_LIBPATH ${BOOST}/lib)
                        set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ")
                endif()
                        
                if(WITH_OPENIMAGEIO)
-                       set(OPENIMAGEIO ${LIBDIR}/gcc/openimageio)
+                       set(OPENIMAGEIO ${LIBDIR}/openimageio)
                        set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
                        set(OPENIMAGEIO_LIBRARIES OpenImageIO)
                        set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
@@ -1053,15 +1188,22 @@ elseif(WIN32)
 
        endif()
 
-       # used in many places so include globally, like OpenGL
-       blender_include_dirs("${PTHREADS_INCLUDE_DIRS}")
-
 elseif(APPLE)
 
-       if (${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5")
-               set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE)
+       if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5")
+               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()
@@ -1231,7 +1373,7 @@ elseif(APPLE)
                )
 
                set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
-               set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
+               set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa")
                #pcre is bundled with openCollada
                #set(PCRE ${LIBDIR}/pcre)
                #set(PCRE_LIBPATH ${PCRE}/lib)
@@ -1489,14 +1631,6 @@ if(MSVC10)
        endif()
 endif()
 
-if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-       if(WITH_IK_ITASC)
-               message(WARNING "Using Clang as CXX compiler: disabling WITH_IK_ITASC and WITH_MOD_FLUID, these features will be missing.")
-               set(WITH_IK_ITASC OFF)
-       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.
@@ -1507,6 +1641,50 @@ if(WITH_PYTHON)
                                                        "to a valid python include path. Containing "
                                                        "Python.h for python version \"${PYTHON_VERSION}\"")
        endif()
+
+       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()
+               # not set, so initialize
+               else()
+                       string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}")
+                       list(GET _PY_VER_SPLIT 0 _PY_VER_MAJOR)
+
+                       # re-cache
+                       unset(PYTHON_NUMPY_PATH CACHE)
+                       find_path(PYTHON_NUMPY_PATH
+                         NAMES
+                           numpy
+                         HINTS
+                           "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
+                           "${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
+                         PATH_SUFFIXES
+                           site-packages
+                           dist-packages
+                          NO_DEFAULT_PATH
+                       )
+
+                       if(NOT EXISTS "${PYTHON_NUMPY_PATH}")
+                               message(WARNING "'numpy' path could not be found in:\n"
+                                               "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy', "
+                                               "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/numpy', "
+                                               "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/numpy', "
+                                               "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/numpy', "
+                                               "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
+                               set(WITH_PYTHON_INSTALL_NUMPY OFF)
+                       else()
+                               message(STATUS "numpy found at '${PYTHON_NUMPY_PATH}'")
+                       endif()
+
+                       unset(_PY_VER_SPLIT)
+                       unset(_PY_VER_MAJOR)
+               endif()
+       endif()
 endif()
 
 
@@ -1563,7 +1741,7 @@ if(FIRST_RUN)
                _setting)
                set(_msg "   * ${_setting}")
                string(LENGTH "${_msg}" _len)
-               while("28" GREATER "${_len}")
+               while("32" GREATER "${_len}")
                        set(_msg "${_msg} ")
                         math(EXPR _len "${_len} + 1")
                endwhile()
@@ -1599,6 +1777,7 @@ if(FIRST_RUN)
        info_cfg_option(WITH_X11_XF86VMODE)
        info_cfg_option(WITH_X11_XINPUT)
        info_cfg_option(WITH_BUILTIN_GLEW)
+       info_cfg_option(WITH_MEM_JEMALLOC)
 
        info_cfg_text("Image Formats:")
        info_cfg_option(WITH_IMAGE_CINEON)
@@ -1622,6 +1801,7 @@ if(FIRST_RUN)
 
        info_cfg_text("Python:")
        info_cfg_option(WITH_PYTHON_INSTALL)
+       info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
        info_cfg_option(WITH_PYTHON_MODULE)
        info_cfg_option(WITH_PYTHON_SAFETY)