Descriptions for some of curve operators
[blender.git] / CMakeLists.txt
index 03a61a1a316a1c8b9f06cc8a344797000834be40..b2243e6bd747a3493644d6a516292228a569417d 100644 (file)
@@ -1,3 +1,4 @@
+# -*- mode: cmake; indent-tabs-mode: t; -*-
 # $Id$
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
@@ -27,8 +28,7 @@
 #-----------------------------------------------------------------------------
 # We don't allow in-source builds. This causes no end of troubles because 
 # all out-of-source builds will use the CMakeCache.txt file there and even 
-# build the libs and objects in it. It will also conflict with the current 
-# Makefile system for Blender
+# build the libs and objects in it.
 
 if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
 message(FATAL_ERROR "CMake generation for blender is not allowed within the source directory! 
@@ -38,17 +38,19 @@ Remove the CMakeCache.txt file and try again from another folder, e.g.:
        cd ..
        mkdir cmake-make 
        cd cmake-make
-       cmake -G \"Unix Makefiles\" ../blender
+       cmake ../blender
 ")
 endif()
 
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 2.8)
 
 # quiet output for Makefiles, 'make -s' helps too
 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
 
 project(Blender)
 
+enable_testing()
+
 #-----------------------------------------------------------------------------
 # Redirect output files
 
@@ -65,10 +67,12 @@ include(build_files/cmake/macros.cmake)
 get_blender_version()
 
 # Blender internal features
-option(WITH_INTERNATIONAL "Enable I18N   (International fonts and text)" ON)
-option(WITH_PYTHON        "Enable Embedded Python API" ON)
-option(WITH_BUILDINFO     "Include extra build details" ON)
-option(WITH_IK_ITASC      "Enable ITASC IK solver" ON)
+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_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_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" ON)
@@ -80,6 +84,10 @@ else()
        option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
 endif()
 
+if(UNIX AND NOT APPLE)
+       option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)"     ON)
+endif()
+
 # Modifiers
 option(WITH_MOD_FLUID          "Enable Elbeem Modifier (Fluid Simulation)" ON)
 option(WITH_MOD_DECIMATE               "Enable Decimate Modifier" ON)
@@ -103,11 +111,7 @@ endif()
 
 # 3D format support
 # disable opencollada on non-apple unix because opencollada has no package for debian
-if(UNIX AND NOT APPLE)
-       option(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
-else()
-       option(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
-endif()
+option(WITH_OPENCOLLADA                "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
 
 # Sound output
 option(WITH_SDL           "Enable SDL for sound and joystick support" ON)
@@ -121,17 +125,29 @@ option(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)"
 
 # Misc
 option(WITH_RAYOPTIMIZATION    "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
-option(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
+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)
 
 # Debug
-option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF)
+option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
 
-option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BKE_assert()" OFF)
+option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
 mark_as_advanced(WITH_ASSERT_ABORT)
 
 if(APPLE)
+       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"
+               FORCE)
+       endif()
+       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)
+       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)
@@ -144,10 +160,6 @@ if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
        message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
 endif()
 
-if(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
-       message("WARNING: WITH_PYTHON_INSTALL requires WITH_INSTALL")
-endif()
-
 if(NOT WITH_SAMPLERATE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK))
        message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK require WITH_SAMPLERATE")
 endif()
@@ -156,16 +168,47 @@ if(NOT WITH_IMAGE_OPENJPEG AND WITH_IMAGE_REDCODE)
        message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG")
 endif()
 
+# python module, needs some different options
+if(WITH_PYTHON_MODULE AND WITH_PLAYER)
+       message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PLAYER to be OFF")
+endif()
+
+if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
+       message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
+endif()
+
+# remove old vars
+unset(WITH_INSTALL CACHE)
+
 TEST_SSE_SUPPORT()
 
+#-----------------------------------------------------------------------------
+# Initialize un-cached vars, avoid unused warning
+
+# linux only, not cached
+set(WITH_BINRELOC OFF)
+
+# these are added to later on.
+set(C_WARNINGS "")
+set(CXX_WARNINGS "")
+
+
 # disabled for now, not supported
 # option(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
 
 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
 # On Unix: 
-#   cmake -D PYTHON_LIB=/usr/local/lib/python3.1/config/libpython3.1.so -D PYTHON_INC=/usr/local/include/python3.1 -G "Unix Makefiles" ../blender
+#   cmake ../blender \
+#         -D PYTHON_VERSION=3.2 \
+#         -D PYTHON_INCLUDE_DIRS=/opt/py32/include/python3.2d \
+#         -D PYTHON_LIBPATH=/opt/py32/lib \
+#         -D PYTHON_LIBRARY=python3.2d
+#
 # On Macs: 
-#   cmake -D PYTHON_INC=/System/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/config -G Xcode ../blender
+#   cmake ../blender \
+#         -D PYTHON_INCLUDE_DIRS=/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 \
+#         -G Xcode
 #
 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
 
@@ -173,6 +216,11 @@ TEST_SSE_SUPPORT()
 #Platform specifics
 
 if(UNIX AND NOT APPLE)
+       
+       # needed for ubuntu 11.04
+       if(EXISTS "/usr/lib/x86_64-linux-gnu")
+               set(CMAKE_LIBRARY_PATH "/usr/lib/x86_64-linux-gnu;${CMAKE_LIBRARY_PATH}")
+       endif()
 
        if(WITH_OPENAL)
                find_package(OpenAL)
@@ -220,22 +268,19 @@ if(UNIX AND NOT APPLE)
 
 
        if(WITH_PYTHON)
-               # No way to set py31. remove for now.
+               # No way to set py32. remove for now.
                # find_package(PythonLibs)
-               set(PYTHON /usr)
-               set(PYTHON_VERSION 3.1)
-               set(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
-               mark_as_advanced(PYTHON_INC)
-               # set(PYTHON_BINARY python) # not used yet
-               set(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
-               mark_as_advanced(PYTHON_LIB)
-               set(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
-               mark_as_advanced(PYTHON_LIBPATH)
-               # find_package(PythonInterp) # not used yet
-               # set(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
-
-               set(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
-               mark_as_advanced(PYTHON_LINKFLAGS)
+
+               # defines...
+               
+               #  PYTHON_VERSION
+               #  PYTHON_INCLUDE_DIRS
+               #  PYTHON_LIBRARY
+               #  PYTHON_LIBPATH
+               #  PYTHON_LINKFLAGS
+
+               include(build_files/cmake/FindPythonLibsUnix.cmake)
+
        endif()
 
        if(WITH_SDL)
@@ -243,6 +288,7 @@ if(UNIX AND NOT APPLE)
                mark_as_advanced(SDLMAIN_LIBRARY)
                mark_as_advanced(SDL_INCLUDE_DIR)
                mark_as_advanced(SDL_LIBRARY)
+               mark_as_advanced(SDL_LIBRARY_TEMP)
                # unset(SDLMAIN_LIBRARY CACHE)
                if(NOT SDL_FOUND)
                        set(WITH_SDL OFF)
@@ -334,17 +380,26 @@ if(UNIX AND NOT APPLE)
        endif()
 
        find_package(X11 REQUIRED)
+       find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
+       mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
 
        # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
-       set(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB} ${X11_Xinput_LIB}")
+       set(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB}")
 
-       if(CMAKE_SYSTEM_NAME MATCHES "Linux")
-               # BSD's dont use libdl.so
-               list(APPEND LLIBS -ldl)
+       if(WITH_X11_XINPUT)
+               list(APPEND LLIBS ${X11_Xinput_LIB})
+       endif()
 
-               # binreloc is linux only
-               set(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
-               set(BINRELOC_INC ${BINRELOC}/include)
+       if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+               if(NOT WITH_PYTHON_MODULE)
+                       # BSD's dont use libdl.so
+                       list(APPEND LLIBS -ldl)
+
+                       # binreloc is linux only
+                       set(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
+                       set(BINRELOC_INC ${BINRELOC}/include)
+                       set(WITH_BINRELOC ON)
+               endif()
        endif()
 
        set(PLATFORM_LINKFLAGS "-pthread")
@@ -355,12 +410,6 @@ if(UNIX AND NOT APPLE)
        # GNU Compiler
        if(CMAKE_COMPILER_IS_GNUCC)
                set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
-       
-               # Better warnings
-               # note: -Wunused-parameter is added below for all GCC compilers
-               set(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
-               set(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
-
        # Intel C++ Compiler
        elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
                # think these next two are broken
@@ -379,13 +428,8 @@ if(UNIX AND NOT APPLE)
                set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel")
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel")
 
-               set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
-
                # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3")
-
-               set(C_WARNINGS "-Wall -Wpointer-arith -Wno-unknown-pragmas")
-               set(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
-
+               set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
                set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel")
        endif()
 
@@ -419,12 +463,12 @@ elseif(WIN32)
        endif()
 
        set(PNG "${LIBDIR}/png")
-       set(PNG_INC "${PNG}/include")
-       set(PNG_LIBPATH ${PNG}/lib)
+       set(PNG_INCLUDE_DIR "${PNG}/include")
+       set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
 
        set(JPEG "${LIBDIR}/jpeg")
-       set(JPEG_INC "${JPEG}/include")
-       set(JPEG_LIBPATH ${JPEG}/lib)
+       set(JPEG_INCLUDE_DIR "${JPEG}/include")
+       set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
 
        set(WINTAB_INC ${LIBDIR}/wintab/include) 
 
@@ -503,10 +547,10 @@ elseif(WIN32)
                else()
                        set(PNG_LIBRARIES libpng_st)
                endif()
-               set(JPEG_LIBRARY libjpeg)
+               set(JPEG_LIBRARIES libjpeg)
 
                set(ZLIB ${LIBDIR}/zlib)
-               set(ZLIB_INC ${ZLIB}/include)
+               set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
                set(ZLIB_LIBPATH ${ZLIB}/lib)
                if(CMAKE_CL_64)
                        set(ZLIB_LIBRARIES libz)
@@ -535,7 +579,7 @@ elseif(WIN32)
                        set(OPENCOLLADA ${LIBDIR}/opencollada)
                        set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
                        set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
-                       set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
+                       set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa UTF)
                        set(PCRE_LIB pcre)
                endif()
                
@@ -554,17 +598,24 @@ elseif(WIN32)
                endif()
 
                if(WITH_IMAGE_OPENEXR)
-                       set(OPENEXR ${LIBDIR}/openexr)
-                       set(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
-                       set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
                        if(MSVC80)
-                               set(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
+                               set(MSVC_LIB _vs2005)
+                               set(MSVC_INC)
+                       elseif(MSVC90)
+                               set(MSVC_LIB _vs2008)
+                               set(MSVC_INC)
+                       elseif(MSVC10)
+                               set(MSVC_LIB _vs2010)
+                               set(MSVC_INC _vs2010)
                        else()
-                               set(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
-                       endif()
-                       if(MSVC90)
-                               set(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
+                               set(MSVC_LIB msvc)
+                               set(MSVC_INC)
                        endif()
+                       set(OPENEXR ${LIBDIR}/openexr)                  
+                       set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
+                       set(OPENEXR_LIBPATH ${OPENEXR}/lib${MSVC_LIB})
+                       set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC})
+                       set(OPENEXR_INC ${OPENEXR_INCUDE}/ ${OPENEXR_INCUDE}/IlmImf ${OPENEXR_INCUDE}/Iex ${OPENEXR_INCUDE}/Imath)
                endif()
 
                if(WITH_IMAGE_TIFF)
@@ -583,18 +634,18 @@ elseif(WIN32)
 
                if(WITH_PYTHON)
                        set(PYTHON ${LIBDIR}/python)
-                       set(PYTHON_VERSION 3.1)
-                       set(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
+                       set(PYTHON_VERSION 3.2)
+                       set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
                        # set(PYTHON_BINARY python) # not used yet
-                       set(PYTHON_LIB python31)
+                       set(PYTHON_LIBRARY python32)
                        set(PYTHON_LIBPATH ${PYTHON}/lib)
                endif()
 
                # MSVC only, Mingw doesnt need
                if(CMAKE_CL_64)
-                       set(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib ")
+                       set(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib /STACK:2097152 ")
                else()
-                       set(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
+                       set(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib /STACK:2097152 ")
                endif()
 
                set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
@@ -605,10 +656,6 @@ elseif(WIN32)
                        set(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
                        set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
 
-                       # Better warnings
-                       set(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
-                       set(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
-
                        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
                        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
                endif()
@@ -625,11 +672,11 @@ elseif(WIN32)
                        set(GETTEXT_LIB intl)
                endif()
 
-               set(JPEG_LIBRARY libjpeg)
+               set(JPEG_LIBRARIES libjpeg)
                set(PNG_LIBRARIES png)
 
                set(ZLIB ${LIBDIR}/zlib)
-               set(ZLIB_INC ${ZLIB}/include)
+               set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
                set(ZLIB_LIBPATH ${ZLIB}/lib)
                set(ZLIB_LIBRARIES z)
 
@@ -694,20 +741,26 @@ elseif(WIN32)
 
                if(WITH_PYTHON)
                        set(PYTHON ${LIBDIR}/python)
-                       set(PYTHON_VERSION 3.1)
-                       set(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
+                       set(PYTHON_VERSION 3.2)
+                       set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
                        # set(PYTHON_BINARY python) # not used yet
-                       set(PYTHON_LIB python31mw)
+                       set(PYTHON_LIBRARY python32mw)
                        set(PYTHON_LIBPATH ${PYTHON}/lib)
                endif()
 
+               set(PLATFORM_LINKFLAGS "--stack,2097152")
+
        endif()
 
        # used in many places so include globally, like OpenGL
-       include_directories(${PTHREADS_INC})
+       blender_include_dirs("${PTHREADS_INC}")
 
 elseif(APPLE)
 
+       if (${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5")
+               set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE)
+       endif()
+
        if(WITH_LIBS10.5)
                set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
        else()
@@ -743,25 +796,25 @@ elseif(APPLE)
                set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
        endif()
 
-       set(PYTHON_VERSION 3.1)
+       set(PYTHON_VERSION 3.2)
 
-       if(PYTHON_VERSION MATCHES 3.1)
-               # we use precompiled libraries for py 3.1 and up by default
+       if(PYTHON_VERSION MATCHES 3.2)
+               # we use precompiled libraries for py 3.2 and up by default
 
                set(PYTHON ${LIBDIR}/python)
-               set(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
+               set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
                # set(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
-               set(PYTHON_LIB python${PYTHON_VERSION})
+               set(PYTHON_LIBRARY python${PYTHON_VERSION})
                set(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
                # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
        else()
                # otherwise, use custom system framework
 
                set(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
-               set(PYTHON_VERSION 3.1)
-               set(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
+               set(PYTHON_VERSION 3.2)
+               set(PYTHON_INCLUDE_DIRS "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
                # set(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
-               set(PYTHON_LIB "")
+               set(PYTHON_LIBRARY "")
                set(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
                set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
        endif()
@@ -781,10 +834,10 @@ elseif(APPLE)
        endif()
 
        set(PNG_LIBRARIES png)
-       set(JPEG_LIBRARY jpeg)
+       set(JPEG_LIBRARIES jpeg)
 
        set(ZLIB /usr)
-       set(ZLIB_INC "${ZLIB}/include")
+       set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
        set(ZLIB_LIBRARIES z bz2)
 
        set(FREETYPE ${LIBDIR}/freetype)
@@ -864,11 +917,11 @@ elseif(APPLE)
        endif()
 
        set(PNG "${LIBDIR}/png")
-       set(PNG_INC "${PNG}/include")
+       set(PNG_INCLUDE_DIR "${PNG}/include")
        set(PNG_LIBPATH ${PNG}/lib)
 
        set(JPEG "${LIBDIR}/jpeg")
-       set(JPEG_INC "${JPEG}/include")
+       set(JPEG_INCLUDE_DIR "${JPEG}/include")
        set(JPEG_LIBPATH ${JPEG}/lib)
 
        if(WITH_IMAGE_TIFF)
@@ -892,35 +945,8 @@ elseif(APPLE)
                set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
                set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
        endif()
-
-       # Better warnings
-       set(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
-       set(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
-
 endif()
 
-
-# buildinfo
-if(WITH_BUILDINFO)
-       # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
-       if(UNIX)
-               EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
-               EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
-               EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
-               if(BUILD_REV_RETURN)
-                       set(BUILD_REV "unknown")
-               endif()
-       endif()
-       
-       if(WIN32)
-               EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
-               EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
-               EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
-               if(BUILD_REV_RETURN)
-                       set(BUILD_REV "unknown")
-               endif()
-       endif()
-endif()
 #-----------------------------------------------------------------------------
 # Common.
 
@@ -941,8 +967,15 @@ if(WITH_RAYOPTIMIZATION)
 endif()
 
 if(WITH_IMAGE_OPENJPEG)
-       set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
-       set(OPENJPEG_INC ${OPENJPEG})
+       if(UNIX AND NOT APPLE)
+               set(OPENJPEG /usr)
+               set(OPENJPEG_INC ${OPENJPEG}/include)
+               set(OPENJPEG_LIB openjpeg)
+               set(OPENJPEG_LIBPATH ${OPENJPEG}/lib)
+       else()
+               set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
+               set(OPENJPEG_INC ${OPENJPEG})
+       endif()
 endif()
 
 if(WITH_IMAGE_REDCODE)
@@ -964,7 +997,7 @@ endif()
 #-----------------------------------------------------------------------------
 # Configure OpenGL.
 find_package(OpenGL)
-include_directories(${OPENGL_INCLUDE_DIR})
+blender_include_dirs("${OPENGL_INCLUDE_DIR}")
 # unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
 # unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
 
@@ -982,6 +1015,16 @@ if(WITH_OPENMP)
        else()
                set(WITH_OPENMP OFF)
        endif()
+
+       mark_as_advanced(OpenMP_C_FLAGS)
+       mark_as_advanced(OpenMP_CXX_FLAGS)
+endif() 
+
+#-----------------------------------------------------------------------------
+# Configure Python.
+
+if(WITH_PYTHON_MODULE)
+       add_definitions(-DPy_ENABLE_SHARED)
 endif() 
 
 #-----------------------------------------------------------------------------
@@ -1003,12 +1046,53 @@ if((NOT WIN32) AND (NOT MSVC))
 endif()
 
 if(CMAKE_COMPILER_IS_GNUCC)
-       set(C_WARNINGS "${C_WARNINGS} -Wunused-parameter -Wwrite-strings -Werror=strict-prototypes -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=return-type")
+
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
+       # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
+       # 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)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
+
+       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)
+
+elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
+
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
+
+       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)
+
+endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+       if(WITH_IK_ITASC OR WITH_MOD_FLUID)
+               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)
+               set(WITH_MOD_FLUID OFF)
+       endif()
 endif()
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
 
+#-------------------------------------------------------------------------------
+# Global Defines
+
 # better not define flags here but this is a debugging option thats off by default.
 if(WITH_CXX_GUARDEDALLOC)
        set(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
@@ -1018,6 +1102,9 @@ if(WITH_ASSERT_ABORT)
        add_definitions(-DWITH_ASSERT_ABORT)
 endif()
 
+# message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
+# message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
+
 #-----------------------------------------------------------------------------
 # Libraries
 
@@ -1036,3 +1123,7 @@ add_subdirectory(source/creator)
 if(WITH_PLAYER)
        add_subdirectory(source/blenderplayer)
 endif()
+
+#-----------------------------------------------------------------------------
+# CPack for generating packages
+include(build_files/cmake/packaging.cmake)