Fix blenderplayer build after OpenMP changes.
[blender.git] / source / creator / CMakeLists.txt
index 25dfb25a05cfa081fe8d9f41812fa29b13f2631b..1ce8a8d1c4cba3279295d8bb10003bb97c7700e2 100644 (file)
@@ -26,6 +26,7 @@
 setup_libdirs()
 
 blender_include_dirs(
+       ../../intern/clog
        ../../intern/guardedalloc
        ../../intern/glew-mx
        ../blender/blenlib
@@ -102,6 +103,10 @@ endif()
 # Setup the exe sources and buildinfo
 set(SRC
        creator.c
+       creator_args.c
+       creator_signals.c
+
+       creator_intern.h
 )
 
 # MSVC 2010 gives linking errors with the manifest
@@ -109,24 +114,13 @@ if(WIN32 AND NOT UNIX)
        string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
        string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
        string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
-       if(MINGW)
-               add_definitions(
-                       -DWINDRES
-                       -DBLEN_VER_RC_STR_M=${BLENDER_VERSION}
-                       -DBLEN_VER_RC_1=${bver1}
-                       -DBLEN_VER_RC_2=${bver2}
-                       -DBLEN_VER_RC_3=${bver3}
-                       -DBLEN_VER_RC_4=0
-               )
-       else()
-               add_definitions(
-                       -DBLEN_VER_RC_STR=${BLENDER_VERSION}
-                       -DBLEN_VER_RC_1=${bver1}
-                       -DBLEN_VER_RC_2=${bver2}
-                       -DBLEN_VER_RC_3=${bver3}
-                       -DBLEN_VER_RC_4=0
-               )
-       endif()
+       add_definitions(
+               -DBLEN_VER_RC_STR=${BLENDER_VERSION}
+               -DBLEN_VER_RC_1=${bver1}
+               -DBLEN_VER_RC_2=${bver2}
+               -DBLEN_VER_RC_3=${bver3}
+               -DBLEN_VER_RC_4=0
+       )
 
 
        list(APPEND SRC
@@ -168,27 +162,44 @@ if(WITH_BUILDINFO)
        include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 
-       # XXX, "_buildinfo.h" is used twice here,
+       # XXX, ${buildinfo_h_fake} is used here,
        # because we rely on that file being detected as missing
        # every build so that the real header "buildinfo.h" is updated.
        #
        # Keep this until we find a better way to resolve!
 
+       set(buildinfo_h_real "${CMAKE_CURRENT_BINARY_DIR}/buildinfo.h")
+       set(buildinfo_h_fake "${CMAKE_CURRENT_BINARY_DIR}/buildinfo.h_fake")
+
+       if(EXISTS ${buildinfo_h_fake})
+               message(FATAL_ERROR "File \"${buildinfo_h_fake}\" found, this should never be created, remove!")
+       endif()
+
        # a custom target that is always built
        add_custom_target(buildinfo ALL
-               DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_buildinfo.h)
+               DEPENDS ${buildinfo_h_fake})
 
        # creates buildinfo.h using cmake script
-       add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_buildinfo.h
+       add_custom_command(
+               OUTPUT
+                       ${buildinfo_h_fake}  # ensure we always run
+                       ${buildinfo_h_real}
                COMMAND ${CMAKE_COMMAND}
                -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
+               # overrides only used when non-empty strings
+               -DBUILD_DATE=${BUILDINFO_OVERRIDE_DATE}
+               -DBUILD_TIME=${BUILDINFO_OVERRIDE_TIME}
                -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake)
 
        # buildinfo.h is a generated file
-       set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/buildinfo.h
+       set_source_files_properties(
+               ${buildinfo_h_real}
                PROPERTIES GENERATED TRUE
                HEADER_FILE_ONLY TRUE)
 
+       unset(buildinfo_h_real)
+       unset(buildinfo_h_fake)
+
        # add deps below, after adding blender
        # -------------- done with header values.
 
@@ -201,6 +212,8 @@ if(WITH_BUILDINFO)
        add_dependencies(buildinfoobj buildinfo)
 endif()
 
+add_cc_flags_custom_test(blender)
+
 # message(STATUS "Configuring blender")
 if(WITH_PYTHON_MODULE)
        add_definitions(-DWITH_PYTHON_MODULE)
@@ -223,7 +236,7 @@ if(WITH_PYTHON_MODULE)
                set_target_properties(
                        blender
                        PROPERTIES
-                               MACOSX_BUNDLE
+                               MACOSX_BUNDLE TRUE
                                LINK_FLAGS_RELEASE "${PLATFORM_LINKFLAGS}"
                                LINK_FLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG}"
                )
@@ -240,6 +253,7 @@ if(WITH_PYTHON_MODULE)
 
 else()
        add_executable(blender ${EXETYPE} ${SRC})
+       WINDOWS_SIGN_TARGET(blender)
 endif()
 
 if(WITH_BUILDINFO)
@@ -251,14 +265,30 @@ endif()
 set(BLENDER_TEXT_FILES
        ${CMAKE_SOURCE_DIR}/release/text/GPL-license.txt
        ${CMAKE_SOURCE_DIR}/release/text/GPL3-license.txt
-       ${CMAKE_SOURCE_DIR}/release/text/Python-license.txt
        ${CMAKE_SOURCE_DIR}/release/text/copyright.txt
-       ${CMAKE_SOURCE_DIR}/release/text/jemalloc-license.txt
        # generate this file
        # ${CMAKE_SOURCE_DIR}/release/text/readme.html
        ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-bfont.ttf.txt
 )
 
+if(WITH_PYTHON)
+       list(APPEND BLENDER_TEXT_FILES
+               ${CMAKE_SOURCE_DIR}/release/text/Python-license.txt
+       )
+endif()
+
+if(WITH_OPENCOLORIO)
+       list(APPEND BLENDER_TEXT_FILES
+               ${CMAKE_SOURCE_DIR}/release/text/ocio-license.txt
+       )
+endif()
+
+if(WITH_MEM_JEMALLOC)
+       list(APPEND BLENDER_TEXT_FILES
+               ${CMAKE_SOURCE_DIR}/release/text/jemalloc-license.txt
+       )
+endif()
+
 if(WITH_INTERNATIONAL)
        list(APPEND BLENDER_TEXT_FILES
                ${CMAKE_SOURCE_DIR}/release/datafiles/LICENSE-droidsans.ttf.txt
@@ -311,9 +341,10 @@ install(
 
 if(WITH_PYTHON)
        # install(CODE "message(\"copying blender scripts...\")")
-       
+
        # exclude addons_contrib if release
-       if("${BLENDER_VERSION_CYCLE}" STREQUAL "release")
+       if("${BLENDER_VERSION_CYCLE}" STREQUAL "release" OR
+          "${BLENDER_VERSION_CYCLE}" STREQUAL "rc")
                set(ADDON_EXCLUDE_CONDITIONAL "addons_contrib/*")
        else()
                set(ADDON_EXCLUDE_CONDITIONAL "_addons_contrib/*")  # dummy, wont do anything
@@ -330,11 +361,13 @@ if(WITH_PYTHON)
                DIRECTORY ${CMAKE_SOURCE_DIR}/release/scripts
                DESTINATION ${TARGETDIR_VER}
                PATTERN ".git" EXCLUDE
+               PATTERN ".gitignore" EXCLUDE
+               PATTERN ".arcconfig" EXCLUDE
                PATTERN "__pycache__" EXCLUDE
                PATTERN "${ADDON_EXCLUDE_CONDITIONAL}" EXCLUDE
                PATTERN "${FREESTYLE_EXCLUDE_CONDITIONAL}" EXCLUDE
        )
-       
+
        unset(ADDON_EXCLUDE_CONDITIONAL)
        unset(FREESTYLE_EXCLUDE_CONDITIONAL)
 endif()
@@ -400,7 +433,8 @@ if("${CMAKE_GENERATOR}" MATCHES ".*Makefiles.*")
        # message after building.
        add_custom_command(
                TARGET blender POST_BUILD MAIN_DEPENDENCY blender
-               COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}'
+               COMMAND ${CMAKE_COMMAND} -E
+                       echo 'now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}'
        )
 endif()
 
@@ -506,7 +540,7 @@ if(UNIX AND NOT APPLE)
                if(WITH_PYTHON_INSTALL)
 
                        install(
-                               FILES ${PYTHON_EXECUTABLE}
+                               PROGRAMS ${PYTHON_EXECUTABLE}
                                DESTINATION ${TARGETDIR_VER}/python/bin
                        )
 
@@ -528,12 +562,9 @@ if(UNIX AND NOT APPLE)
                        install(
                                DIRECTORY ${PYTHON_LIBPATH}/python${PYTHON_VERSION}
                                DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}
-                               PATTERN ".svn" EXCLUDE
                                PATTERN "__pycache__" EXCLUDE               # * any cache *
-                               PATTERN "distutils" EXCLUDE                 # ./distutils
+                               PATTERN "config-${PYTHON_VERSION}m/*.a" EXCLUDE  # static lib
                                PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
-                               PATTERN "config" EXCLUDE                    # ./config
-                               PATTERN "config-*" EXCLUDE                  # ./config-*
                                PATTERN "site-packages/*" EXCLUDE           # ./site-packages/*
                                PATTERN "tkinter" EXCLUDE                   # ./tkinter
                                PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
@@ -543,8 +574,14 @@ if(UNIX AND NOT APPLE)
                                PATTERN "turtle.py" EXCLUDE                 # ./turtle.py
                        )
 
-                       # # doesnt work, todo
-                       # install(CODE "execute_process(COMMAND find ${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/python/lib/ -name '*.so' -exec strip -s {} '\;')")
+                       # Needed for distutils/pip
+                       # get the last part of the include dir, will be 'python{version}{abiflag}',
+                       get_filename_component(_py_inc_suffix ${PYTHON_INCLUDE_DIR} NAME)
+                       install(
+                               FILES ${PYTHON_INCLUDE_DIR}/pyconfig.h
+                               DESTINATION ${TARGETDIR_VER}/python/include/${_py_inc_suffix}
+                       )
+                       unset(_py_inc_suffix)
 
                        if(WITH_PYTHON_INSTALL_NUMPY)
                                # Install to the same directory as the source, so debian-like
@@ -560,11 +597,10 @@ if(UNIX AND NOT APPLE)
                                        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 "f2py" EXCLUDE                  # ./f2py - fortran/python interface code, not for blender.
                                        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.
@@ -585,10 +621,9 @@ if(UNIX AND NOT APPLE)
                                        PATTERN "__pycache__" EXCLUDE           # * any cache *
                                        PATTERN "*.pyc" EXCLUDE                 # * any cache *
                                        PATTERN "*.pyo" EXCLUDE                 # * any cache *
-                                       PATTERN "cacert.pem" EXCLUDE            # for now we don't deal with security
                                )
                                # On some platforms requests does have extra dependencies.
-                               set(_requests_deps "chardet" "urllib3")
+                               set(_requests_deps "certifi" "chardet" "idna" "urllib3")
                                foreach(_requests_dep ${_requests_deps})
                                        if(EXISTS ${PYTHON_REQUESTS_PATH}/${_requests_dep})
                                                install(
@@ -606,13 +641,13 @@ if(UNIX AND NOT APPLE)
                                                FILES ${PYTHON_REQUESTS_PATH}/six.py
                                                DESTINATION ${TARGETDIR_VER}/python/${_target_LIB}/python${PYTHON_VERSION}/${_suffix}
                                        )
-                                       endif()
+                               endif()
                                unset(_requests_dep)
                                unset(_requests_deps)
                                unset(_suffix)
                        endif()
                        unset(_target_LIB)
-                       
+
                endif()
        endif()
 elseif(WIN32)
@@ -622,16 +657,15 @@ elseif(WIN32)
        if(WITH_PYTHON)
                string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
 
-               # MinGW TODO: This bit of Python configuration diverges from MSVC
                if(NOT CMAKE_COMPILER_IS_GNUCC)
                        install(
-                               FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll ${LIBDIR}/python/lib/sqlite3.dll
+                               FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll
                                DESTINATION "."
                                CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
                        )
 
                        install(
-                               FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll ${LIBDIR}/python/lib/sqlite3_d.dll
+                               FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll
                                DESTINATION "."
                                CONFIGURATIONS Debug
                        )
@@ -683,17 +717,28 @@ elseif(WIN32)
                        )
 
                        if(WITH_PYTHON_INSTALL_NUMPY)
+                               set(PYTHON_NUMPY_VERSION 1.15)
                                add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
-                                       COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages)
-
-                               add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
-                                       COMMAND ${CMAKE_COMMAND} -E tar xzvf "${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_1.9.tar.gz"
-                                       DEPENDS ${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_1.9.tar.gz
+                                       COMMAND ${CMAKE_COMMAND} -E
+                                               make_directory ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages)
+
+                               add_custom_command(
+                                       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
+                                       COMMAND ${CMAKE_COMMAND} -E
+                                               tar xzvf "${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}$<$<CONFIG:Debug>:d>.tar.gz"
+                                       DEPENDS
+                                               ${LIBDIR}/release/python${_PYTHON_VERSION_NO_DOTS}_numpy_${PYTHON_NUMPY_VERSION}$<$<CONFIG:Debug>:d>.tar.gz
                                                ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
-                                       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages)
-                               add_custom_target(python_numpy ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy)
-                               install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
-                                               DESTINATION ${BLENDER_VERSION}/python/lib/site-packages)
+                                       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages
+                               )
+                               add_custom_target(
+                                       python_numpy ALL
+                                       DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
+                               )
+                               install(
+                                       DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${BLENDER_VERSION}/python/lib/site-packages/numpy
+                                       DESTINATION ${BLENDER_VERSION}/python/lib/site-packages
+                               )
                        endif()
 
 
@@ -708,16 +753,15 @@ elseif(WIN32)
                                DESTINATION ${BLENDER_VERSION}/python/bin
                                CONFIGURATIONS Debug
                        )
-
-                       # MinGW needs Python DLL
-                       if(MINGW)
+                       if(WINDOWS_PYTHON_DEBUG)
                                install(
-                                       FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.dll
+                                       FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.pdb
                                        DESTINATION "."
                                        CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel
                                )
+
                                install(
-                                       FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.dll
+                                       FILES ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.pdb
                                        DESTINATION "."
                                        CONFIGURATIONS Debug
                                )
@@ -741,59 +785,22 @@ elseif(WIN32)
 
        if(MSVC)
                install(
-                       FILES ${LIBDIR}/pthreads/lib/pthreadVC2.dll
+                       FILES ${LIBDIR}/pthreads/lib/pthreadVC3.dll
                        DESTINATION "."
                )
-       else()
-               #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 "."
-                       )
-               elseif(WITH_MINGW64)
-                       install(
-                               FILES 
-                                       ${LIBDIR}/binaries/libgcc_s_sjlj-1.dll
-                                       ${LIBDIR}/binaries/libwinpthread-1.dll
-                                       ${LIBDIR}/binaries/libstdc++-6.dll
-                               DESTINATION "."
-                       )
-                       
-                       if(WITH_OPENMP)
-                               install(
-                                       FILES 
-                                       ${LIBDIR}/binaries/libgomp-1.dll
-                                       DESTINATION "."
-                               )
-                       endif()
-               endif()
        endif()
 
        if(WITH_CODEC_FFMPEG)
-               if(WITH_MINGW64)
-                       install(
-                               FILES
-                                       ${LIBDIR}/ffmpeg/lib/avcodec-53.dll
-                                       ${LIBDIR}/ffmpeg/lib/avformat-53.dll
-                                       ${LIBDIR}/ffmpeg/lib/avdevice-53.dll
-                                       ${LIBDIR}/ffmpeg/lib/avutil-51.dll
-                                       ${LIBDIR}/ffmpeg/lib/swscale-2.dll
-                                       ${LIBDIR}/ffmpeg/lib/swresample-0.dll
-                                       ${LIBDIR}/ffmpeg/lib/xvidcore.dll
-                               DESTINATION "."
-                       )
-               else()
-                       install(
-                               FILES
-                                       ${LIBDIR}/ffmpeg/lib/avcodec-55.dll
-                                       ${LIBDIR}/ffmpeg/lib/avformat-55.dll
-                                       ${LIBDIR}/ffmpeg/lib/avdevice-55.dll
-                                       ${LIBDIR}/ffmpeg/lib/avutil-52.dll
-                                       ${LIBDIR}/ffmpeg/lib/swscale-2.dll
-                               DESTINATION "."
-                       )
-               endif()
+               install(
+                       FILES
+                               ${LIBDIR}/ffmpeg/lib/avcodec-58.dll
+                               ${LIBDIR}/ffmpeg/lib/avformat-58.dll
+                               ${LIBDIR}/ffmpeg/lib/avdevice-58.dll
+                               ${LIBDIR}/ffmpeg/lib/avutil-56.dll
+                               ${LIBDIR}/ffmpeg/lib/swscale-5.dll
+                               ${LIBDIR}/ffmpeg/lib/swresample-3.dll
+                       DESTINATION "."
+               )
        endif()
 
        if(WITH_CODEC_SNDFILE)
@@ -809,32 +816,15 @@ elseif(WIN32)
                                ${LIBDIR}/openal/lib/OpenAL32.dll
                        DESTINATION "."
                )
-               # MinGW TODO: Need to update to a newer OpenAL version
-               # which does not depend on wrap_oal.dll
-               if(CMAKE_COMPILER_IS_GNUCC)
-                       install(
-                               FILES
-                                       ${LIBDIR}/openal/lib/wrap_oal.dll
-                               DESTINATION "."
-                       )
-               endif()
        endif()
 
        if(WITH_SDL)
-               #MinGW TODO: Update to SDL2
-               if(NOT CMAKE_COMPILER_IS_GNUCC)
-                       install(
-                               FILES ${LIBDIR}/sdl/lib/SDL2.dll
-                               DESTINATION "."
-                       )
-               else()
-                       install(
-                               FILES ${LIBDIR}/sdl/lib/SDL.dll
-                               DESTINATION "."
-                       )
-               endif()
+               install(
+                       FILES ${LIBDIR}/sdl/lib/SDL2.dll
+                       DESTINATION "."
+               )
        endif()
-       
+
        if(WITH_SYSTEM_AUDASPACE)
                install(
                        FILES
@@ -851,29 +841,12 @@ elseif(WIN32)
                        DESTINATION "."
                )
        endif()
-               
+
        install( # x86 builds can run on x64 Windows, so this is required at all times
                FILES ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll
                DESTINATION "."
        )
 
-       if(WITH_OPENCOLORIO)
-               set(OCIOBIN ${LIBDIR}/opencolorio/bin)
-               if(NOT MINGW)
-                       install(
-                               FILES
-                                       ${OCIOBIN}/OpenColorIO.dll
-                               DESTINATION "."
-                       )
-               else()
-                       install(
-                               FILES
-                                       ${OCIOBIN}/libOpenColorIO.dll
-                               DESTINATION "."
-                       )
-               endif()
-       endif()
-
 elseif(APPLE)
 
        # handy install macro to exclude files, we use \$ escape for the "to"
@@ -891,6 +864,14 @@ elseif(APPLE)
                        PATTERN "__pycache__" EXCLUDE
                        PATTERN "__MACOSX" EXCLUDE
                        PATTERN ".DS_Store" EXCLUDE
+                       PATTERN "config-${PYTHON_VERSION}m/*.a" EXCLUDE  # static lib
+                       PATTERN "lib2to3" EXCLUDE                   # ./lib2to3
+                       PATTERN "tkinter" EXCLUDE                   # ./tkinter
+                       PATTERN "lib-dynload/_tkinter.*" EXCLUDE    # ./lib-dynload/_tkinter.co
+                       PATTERN "idlelib" EXCLUDE                   # ./idlelib
+                       PATTERN "test" EXCLUDE                      # ./test
+                       PATTERN "turtledemo" EXCLUDE                # ./turtledemo
+                       PATTERN "turtle.py" EXCLUDE                 # ./turtle.py
                )
        endmacro()
 
@@ -903,8 +884,8 @@ elseif(APPLE)
 
        set_target_properties(blender PROPERTIES
                MACOSX_BUNDLE_INFO_PLIST ${OSX_APP_SOURCEDIR}/Contents/Info.plist
-               MACOSX_BUNDLE_SHORT_VERSION_STRING ${BLENDER_VERSION}
-               MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION} ${BLENDER_DATE}")
+               MACOSX_BUNDLE_SHORT_VERSION_STRING "${BLENDER_VERSION}${BLENDER_VERSION_CHAR}"
+               MACOSX_BUNDLE_LONG_VERSION_STRING "${BLENDER_VERSION}${BLENDER_VERSION_CHAR} ${BLENDER_DATE}")
 
        # Gather the date in finder-style
        execute_process(COMMAND date "+%m/%d/%Y/%H:%M"
@@ -912,7 +893,8 @@ elseif(APPLE)
        OUTPUT_STRIP_TRAILING_WHITESPACE)
 
        # Give the bundle actual creation/modification date
-       execute_process(COMMAND SetFile -d ${SETFILE_DATE} -m ${SETFILE_DATE} ${EXECUTABLE_OUTPUT_PATH}/blender.app)
+       execute_process(COMMAND SetFile -d ${SETFILE_DATE} -m ${SETFILE_DATE}
+                       ${EXECUTABLE_OUTPUT_PATH}/blender.app)
 
        install(
                TARGETS blender
@@ -932,15 +914,10 @@ elseif(APPLE)
                blender.app/Contents/
        )
 
-       if(WITH_OPENMP AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT ${CMAKE_C_COMPILER_VERSION} VERSION_LESS '3.4')
+       if(WITH_OPENMP AND OPENMP_CUSTOM)
                install(
-                       FILES ${LIBDIR}/openmp/lib/libiomp5.dylib
-                       DESTINATION blender.app/Contents/Resources/lib/
-               )
-               install(
-                       FILES ${LIBDIR}/openmp/LICENSE.txt
-                       DESTINATION "."
-                       RENAME LICENSE-libiomp5.txt
+                       FILES ${LIBDIR}/openmp/lib/libomp.dylib
+                       DESTINATION blender.app/Contents/Resources/lib
                )
        endif()
 
@@ -953,43 +930,27 @@ elseif(APPLE)
 
        # python
        if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
-               # 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)
-
-               set(PYTHON_ZIP "python_${CMAKE_OSX_ARCHITECTURES}.zip")
-
-               add_custom_command(
-                       OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
-                       COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/python/"
-                       COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/python/"
-                       COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/python/"
-                               ${CMAKE_COMMAND} -E tar xzfv "${LIBDIR}/release/${PYTHON_ZIP}"
-                       DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
-
-               add_dependencies(blender extractpyzip)
-
-               # copy extracted python files
-               install_dir(
-                       ${CMAKE_CURRENT_BINARY_DIR}/python
-                       \${TARGETDIR_VER}
-               )
-               # copy site-packages files
+               # Copy the python libs into the install directory
                install_dir(
-                       ${LIBDIR}/release/site-packages
-                       ${CMAKE_CURRENT_BINARY_DIR}/python/lib/python${PYTHON_VERSION}
+                       ${PYTHON_LIBPATH}
+                       ${TARGETDIR_VER}/python/lib
                )
 
                install(DIRECTORY ${LIBDIR}/python/bin
                        DESTINATION ${TARGETDIR_VER}/python
                        USE_SOURCE_PERMISSIONS
                )
+
+               # Needed for distutils/pip
+               # get the last part of the include dir, will be 'python{version}{abiflag}',
+               get_filename_component(_py_inc_suffix ${PYTHON_INCLUDE_DIR} NAME)
+               install(
+                       FILES ${PYTHON_INCLUDE_DIR}/pyconfig.h
+                       DESTINATION ${TARGETDIR_VER}/python/include/${_py_inc_suffix}
+               )
+               unset(_py_inc_suffix)
        endif()
-       
+
        # install blenderplayer bundle - copy of blender.app above. re-using macros et al
        # note we are using OSX Bundle as base and copying Blender dummy bundle on top of it
        if(WITH_GAMEENGINE AND WITH_PLAYER)
@@ -1005,7 +966,8 @@ elseif(APPLE)
                )
 
                # Give the bundle actual creation/modification date
-               execute_process(COMMAND SetFile -d ${SETFILE_DATE} -m ${SETFILE_DATE} ${EXECUTABLE_OUTPUT_PATH}/blenderplayer.app)
+               execute_process(COMMAND SetFile -d ${SETFILE_DATE} -m ${SETFILE_DATE}
+                               ${EXECUTABLE_OUTPUT_PATH}/blenderplayer.app)
 
                install(
                        FILES ${OSX_APP_PLAYER_SOURCEDIR}/Contents/PkgInfo
@@ -1017,28 +979,19 @@ elseif(APPLE)
                        blenderplayer.app/Contents/
                )
 
-               if(WITH_OPENMP AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT ${CMAKE_C_COMPILER_VERSION} VERSION_LESS '3.4')
-               install(
-               FILES ${LIBDIR}/openmp/lib/libiomp5.dylib
-               DESTINATION blenderplayer.app/Contents/Resources/lib/
-               )
+               if(WITH_OPENMP AND OPENMP_CUSTOM)
+                       install(
+                               FILES ${LIBDIR}/openmp/lib/libomp.dylib
+                               DESTINATION blenderplayer.app/Contents/Resources/lib
+                       )
                endif()
 
-
                # python
                if(WITH_PYTHON AND NOT WITH_PYTHON_FRAMEWORK)
-                       add_custom_command(
-                               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python
-                               COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/python/"
-                               COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/python/"
-                               COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/python/"
-                                       ${CMAKE_COMMAND} -E tar xzfv "${LIBDIR}/release/${PYTHON_ZIP}"
-                               DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
-
-                       # copy extracted python files
+                       # Copy the python libs into the install directory
                        install_dir(
-                               ${CMAKE_CURRENT_BINARY_DIR}/python
-                               \${PLAYER_TARGETDIR_VER}
+                               ${PYTHON_LIBPATH}
+                               ${PLAYER_TARGETDIR_VER}/python/lib
                        )
                endif()
 
@@ -1092,34 +1045,14 @@ setup_liblinks(blender)
 # Setup launcher
 
 if(WIN32 AND NOT WITH_PYTHON_MODULE)
-       set(LAUNCHER_SRC
-               creator_launch_win.c
-               ${CMAKE_SOURCE_DIR}/release/windows/icons/winblender.rc
+       install(
+               TARGETS blender
+               COMPONENT Blender
+               DESTINATION "."
+       )
+       set_target_properties(
+               blender
+               PROPERTIES
+                       VS_USER_PROPS "blender.Cpp.user.props"
        )
-       add_executable(blender-launcher ${LAUNCHER_SRC})
-       target_link_libraries(blender-launcher bf_intern_utfconv ${PLATFORM_LINKLIBS})
-
-       set_target_properties(blender PROPERTIES OUTPUT_NAME blender-app)
-       set_target_properties(blender-launcher PROPERTIES OUTPUT_NAME blender)
-
-       install(TARGETS blender blender-launcher
-                       COMPONENT Blender
-                       DESTINATION ".")
-
-       if(MSVC12_REDIST_DIR)
-               if(CMAKE_CL_64)
-                       set(_WIN_PLATFORM x64)
-               else()
-                       set(_WIN_PLATFORM x86)
-               endif()
-               install(
-                       FILES ${MSVC12_REDIST_DIR}/${_WIN_PLATFORM}/Microsoft.VC120.CRT/msvcp120.dll
-                                 ${MSVC12_REDIST_DIR}/${_WIN_PLATFORM}/Microsoft.VC120.CRT/msvcr120.dll
-               DESTINATION ".")
-               if(WITH_OPENMP)
-                       install(
-                               FILES ${MSVC12_REDIST_DIR}/${_WIN_PLATFORM}/Microsoft.VC120.OpenMP/vcomp120.dll
-                               DESTINATION ".")
-               endif()
-       endif()
 endif()