Fix macOS python cmake install to work when switching lib directories.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 25 May 2017 00:34:39 +0000 (02:34 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 25 May 2017 00:34:39 +0000 (02:34 +0200)
It's a bit ugly but I couldn't find a better way to keep fast installs and
correct handling of switching between master and blender2.8 with different
lib directories.

source/creator/CMakeLists.txt

index 504d0de91450c2aa8878e696a80fefcbe2b64001..6d0cbb365b437a4d5d5772d0f56f502005975c29 100644 (file)
@@ -997,21 +997,26 @@ 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,
+               # the python zip is first extracted 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
+               # Not needed for PYTHON_MODULE or WEB_PLUGIN due uses Pyhon framework
+               # use a hash of the .zip path to handle switching between different
+               # lib directories without needing a clean build
+               string(SHA1 PYTHON_ZIP_HASH ${LIBDIR}/release/${PYTHON_ZIP})
+               set(PYTHON_EXTRACT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_ZIP_HASH}/python)
+
                add_custom_target(
                        extractpyzip
-                       DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/python)
+                       DEPENDS ${PYTHON_EXTRACT_DIR})
 
                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/"
+                       OUTPUT ${PYTHON_EXTRACT_DIR}
+                       COMMAND ${CMAKE_COMMAND} -E remove_directory "${PYTHON_EXTRACT_DIR}/"
+                       COMMAND ${CMAKE_COMMAND} -E make_directory "${PYTHON_EXTRACT_DIR}/"
+                       COMMAND ${CMAKE_COMMAND} -E chdir "${PYTHON_EXTRACT_DIR}/"
                                ${CMAKE_COMMAND} -E tar xzfv "${LIBDIR}/release/${PYTHON_ZIP}"
                        DEPENDS ${LIBDIR}/release/${PYTHON_ZIP})
 
@@ -1019,13 +1024,13 @@ elseif(APPLE)
 
                # copy extracted python files
                install_dir(
-                       ${CMAKE_CURRENT_BINARY_DIR}/python
+                       ${PYTHON_EXTRACT_DIR}
                        \${TARGETDIR_VER}
                )
                # copy site-packages files
                install_dir(
                        ${LIBDIR}/release/site-packages
-                       ${CMAKE_CURRENT_BINARY_DIR}/python/lib/python${PYTHON_VERSION}
+                       \${TARGETDIR_VER}/python/lib/python${PYTHON_VERSION}
                )
 
                install(DIRECTORY ${LIBDIR}/python/bin