Merging r46495 through r46557 from trunk into soc-2011-tomato
[blender-staging.git] / source / creator / CMakeLists.txt
index 0938798c185b505b452fdd0b743b477a34056ca0..a689dfb1db1d2631f49a319ab8807a32bfc10778 100644 (file)
@@ -40,11 +40,19 @@ blender_include_dirs(
        ../blender/windowmanager
 )
 
+if(WIN32)
+       blender_include_dirs(../../intern/utfconv)
+endif()
+
 if(WITH_LIBMV)
        blender_include_dirs(../../extern/libmv)
        add_definitions(-DWITH_LIBMV)
 endif()
 
+if(WITH_CODEC_FFMPEG)
+       add_definitions(-DWITH_FFMPEG)
+endif()
+
 if(WITH_PYTHON)
        blender_include_dirs(../blender/python)
        add_definitions(-DWITH_PYTHON)
@@ -165,38 +173,36 @@ if(WITH_PYTHON_MODULE)
        add_definitions(-DWITH_PYTHON_MODULE)
 
        # creates ./bin/bpy.so which can be imported as a python module.
+       #
+       # note that 'SHARED' works on Linux and Windows,
+       # but not OSX which _must_ be 'MODULE'
+       add_library(blender MODULE ${SRC})
+       set_target_properties(
+               blender
+               PROPERTIES
+                       PREFIX ""
+                       OUTPUT_NAME bpy
+                       LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+                       RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin  # only needed on windows
+       )
+
        if(APPLE)
-               add_library(blender MODULE ${SRC})
                set_target_properties(
                        blender
                        PROPERTIES
-                               PREFIX ""
-                               OUTPUT_NAME bpy
-                               LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
-                               RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin  # only needed on windows
+                               LINK_FLAGS_RELEASE "${PLATFORM_LINKFLAGS}"
+                               LINK_FLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG}"
                )
-               TARGET_LINK_LIBRARIES(blender -Wl,-undefined -Wl,dynamic_lookup)
+       endif()
 
-       else(APPLE)
-               add_library(blender SHARED ${SRC})
+       if(WIN32)
+               # python modules use this
                set_target_properties(
                        blender
                        PROPERTIES
-                               PREFIX ""
-                               OUTPUT_NAME bpy
-                               LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
-                               RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin  # only needed on windows
+                       SUFFIX ".pyd"
                )
-
-               if(WIN32)
-                       # python modules use this
-                       set_target_properties(
-                               blender
-                               PROPERTIES
-                               SUFFIX ".pyd"
-                       )
-               endif()
-       endif(APPLE)
+       endif()
 
 else()
        add_executable(blender ${EXETYPE} ${SRC})
@@ -228,7 +234,7 @@ set(BLENDER_TEXT_FILES
 
 
 # -----------------------------------------------------------------------------
-# Platform Spesific Var: TARGETDIR_VER
+# Platform Specific Var: TARGETDIR_VER
 
 if(UNIX AND NOT APPLE)
        if(WITH_INSTALL_PORTABLE)
@@ -245,7 +251,11 @@ elseif(WIN32)
        set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
 
 elseif(APPLE)
-       set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
+       if(WITH_PYTHON_MODULE)
+               set(TARGETDIR_VER ${TARGETDIR}/${BLENDER_VERSION})
+       else()
+               set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
+       endif()
 
 endif()
 
@@ -386,7 +396,7 @@ if(UNIX AND NOT APPLE)
                )
        endif()
 
-               # plugins in blender 2.5 don't work at the moment.
+               # plugins in blender 2.6 don't work at the moment.
                #
                # install(
                #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
@@ -396,12 +406,21 @@ if(UNIX AND NOT APPLE)
 
        if(WITH_PYTHON)
                if(WITH_PYTHON_INSTALL)
+                       # on some platforms (like openSUSE) Python is linked
+                       # to be used from lib64 folder.
+                       # determine this from Python's libraries path
+                       if(${PYTHON_LIBPATH} MATCHES "lib64$")
+                               set(_target_LIB "lib64")
+                       else()
+                               set(_target_LIB "lib")
+                       endif()
+
                        # Copy the systems python into the install directory
                        # Scons copy in tools/Blender.py
                        # install(CODE "message(\"copying a subset of the systems python...\")")
                        install(
                                DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
-                               DESTINATION ${TARGETDIR_VER}/python/lib
+                               DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
                                PATTERN ".svn" EXCLUDE
                                PATTERN "__pycache__" EXCLUDE               # * any cache *
                                PATTERN "distutils" EXCLUDE                 # ./distutils
@@ -419,6 +438,28 @@ if(UNIX AND NOT APPLE)
 
                        # # doesnt work, todo
                        # install(CODE "execute_process(COMMAND find ${TARGETDIR}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
+                       
+                       if(WITH_PYTHON_INSTALL_NUMPY)
+                               install(
+                                       DIRECTORY ${PYTHON_NUMPY_PATH}/numpy
+                                       DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/site-packages
+                                       PATTERN ".svn" EXCLUDE
+                                       PATTERN "__pycache__" EXCLUDE           # * any cache *
+                                       PATTERN "*.pyc" EXCLUDE                 # * any cache *
+                                       PATTERN "*.pyo" EXCLUDE                 # * any cache *
+                                       PATTERN "distutils" EXCLUDE             # ./distutils
+                                       PATTERN "oldnumeric" EXCLUDE            # ./oldnumeric
+                                       PATTERN "doc" EXCLUDE                   # ./doc
+                                       PATTERN "tests" EXCLUDE                 # ./tests
+                                       PATTERN "f2py" EXCLUDE                  # ./f2py - fortran/python interface code, not fun for blender devs.
+                                       PATTERN "include" EXCLUDE               # include dirs all over, we wont use NumPy/CAPI
+                                       PATTERN "*.h" EXCLUDE                   # some includes are not in include dirs
+                                       PATTERN "*.a" EXCLUDE                   # ./core/lib/libnpymath.a - for linking, we dont need.
+                               )
+                       endif()
+                       
+                       unset(_target_LIB)
+                       
                endif()
        endif()
 elseif(WIN32)
@@ -428,7 +469,7 @@ elseif(WIN32)
                DESTINATION ${TARGETDIR}
        )
 
-       if(WITH_INTERNATIONAL)
+       if(WITH_INTERNATIONAL AND (NOT WITH_MINGW64))
                install(
                        FILES ${LIBDIR}/gettext/lib/gnu_gettext.dll
                        DESTINATION ${TARGETDIR}
@@ -442,7 +483,7 @@ elseif(WIN32)
                endif()
        endif()
 
-       # plugins in blender 2.5 don't work at the moment.
+       # plugins in blender 2.6 don't work at the moment.
        #
        # install(
        #       DIRECTORY ${CMAKE_SOURCE_DIR}/release/plugins
@@ -503,11 +544,14 @@ elseif(WIN32)
                        DESTINATION ${TARGETDIR}
                )
        else()
-               install(
-                       FILES
-                               ${LIBDIR}/zlib/lib/zlib.dll
-                       DESTINATION ${TARGETDIR}
-               )
+               #not needed since we link statically, maybe also unneeded for MinGW?
+               if(NOT WITH_MINGW64)
+                       install(
+                               FILES
+                                       ${LIBDIR}/zlib/lib/zlib.dll
+                               DESTINATION ${TARGETDIR}
+                       )
+               endif()
        endif()
 
        if(MSVC)
@@ -516,10 +560,18 @@ elseif(WIN32)
                        DESTINATION ${TARGETDIR}
                )
        else()
-               install(
-                       FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
-                       DESTINATION ${TARGETDIR}
-               )
+               #MinGW64 comes with own version. For portable builds it will probaly have to be copied to work
+               if(NOT WITH_MINGW64)
+                       install(
+                               FILES ${LIBDIR}/pthreads/lib/pthreadGC2.dll
+                               DESTINATION ${TARGETDIR}
+                       )
+               elseif(WITH_MINGW64)
+                       install(
+                               FILES ${LIBDIR}/binaries/pthreadGC2-w64.dll
+                               DESTINATION ${TARGETDIR}
+                       )
+               endif()
        endif()
 
        if(WITH_CODEC_FFMPEG)
@@ -532,7 +584,14 @@ elseif(WIN32)
                                ${LIBDIR}/ffmpeg/lib/swscale-2.dll
                        DESTINATION ${TARGETDIR}
                )
-
+               if(WITH_MINGW64)
+               install(
+                       FILES
+                               ${LIBDIR}/ffmpeg/lib/swresample-0.dll
+                               ${LIBDIR}/ffmpeg/lib/xvidcore.dll
+                       DESTINATION ${TARGETDIR}
+               )
+               endif()
        endif()
 
        if(WITH_CODEC_SNDFILE)
@@ -546,6 +605,7 @@ elseif(WIN32)
                install(
                        FILES
                                ${LIBDIR}/openal/lib/OpenAL32.dll
+                               ${LIBDIR}/openal/lib/wrap_oal.dll
                        DESTINATION ${TARGETDIR}
                )
        endif()
@@ -572,12 +632,14 @@ elseif(WIN32)
        )       
 
        if(WITH_OPENIMAGEIO)
-               set_lib_path(OIIOBIN "openimageio/bin")
-               install(
-                       FILES
-                               ${OIIOBIN}/OpenImageIO.dll
-                       DESTINATION ${TARGETDIR}
-               )
+               if(NOT MINGW)
+                       set_lib_path(OIIOBIN "openimageio/bin")
+                       install(
+                               FILES
+                                       ${OIIOBIN}/OpenImageIO.dll
+                               DESTINATION ${TARGETDIR}
+                       )
+               endif()
        endif()
 
 elseif(APPLE)
@@ -627,10 +689,11 @@ elseif(APPLE)
        )
 
        # python
-       if(WITH_PYTHON)
+       if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE)
                # the python zip is first extract as part of the build process,
                # and then later installed as part of make install. this is much
                # quicker, and means we can easily exclude files on copy
+               # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses  Pyhon framework
                add_custom_target(
                        extractpyzip
                        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
@@ -777,14 +840,17 @@ endif()
                bf_editor_sound
                bf_editor_animation
                bf_editor_datafiles
+               bf_editor_mask
 
                bf_render
                bf_intern_opennl
                bf_python
                bf_python_ext
                bf_python_mathutils
+               bf_python_bmesh
                bf_ikplugin
                bf_modifiers
+               bf_bmesh
                bf_blenkernel
                bf_nodes
                bf_gpu
@@ -807,6 +873,7 @@ endif()
                bf_intern_memutil
                bf_intern_guardedalloc
                bf_intern_ctr
+               bf_intern_utfconv
                ge_blen_routines
                ge_converter
                ge_phys_dummy
@@ -844,10 +911,12 @@ endif()
                cycles_kernel
                cycles_util
                cycles_subd
+               bf_intern_raskter
        )
 
        if(WITH_LIBMV)
                list(APPEND BLENDER_SORTED_LIBS extern_libmv)
+               list(APPEND BLENDER_SORTED_LIBS extern_ceres)
        endif()
 
        if(WITH_MOD_CLOTH_ELTOPO)
@@ -874,6 +943,14 @@ endif()
                list(APPEND BLENDER_SORTED_LIBS bf_quicktime)
        endif()
 
+       if(WITH_CARVE)
+               list(APPEND BLENDER_SORTED_LIBS extern_carve)
+       endif()
+
+       if(WITH_GHOST_XDND)
+               list(APPEND BLENDER_SORTED_LIBS extern_xdnd)
+       endif()
+
        foreach(SORTLIB ${BLENDER_SORTED_LIBS})
                set(REMLIB ${SORTLIB})
                foreach(SEARCHLIB ${BLENDER_LINK_LIBS})