From 3d9dc6a2e488cd47eafb716b65f479831c4bcd9f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 22 Feb 2013 22:24:38 +0000 Subject: [PATCH] WITH_PYTHON_FRAMEWORK cmake option for OSX This option allow Blender to be linked against the Framework python It's useful if you want to have blenderplayer and bpy in the same application and need to avoid PyThread problems. patch reviewed by Jens Verwiebe before 2.66. He may want to change something though. (also small: I changed: /Library/Frameworks/Python.framework/Versions//python by /Library/Frameworks/Python.framework/Versions//Python as the latter seems to be the norm) --- CMakeLists.txt | 21 ++++++++++++--------- source/creator/CMakeLists.txt | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6a0fa4e016..8b225af07e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,6 +124,10 @@ mark_as_advanced(WITH_PYTHON_SECURITY) # some distributions see this as a secur 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 which runs without a user interface, like running regular blender in background mode (experimental, only enable for development)" OFF) +if (APPLE) + option(WITH_PYTHON_FRAMEWORK "Enable building using the Python available in the framework (OSX only)" OFF) +endif() + 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_IK_SOLVER "Enable Legacy IK solver (only disable for development)" ON) @@ -1457,11 +1461,10 @@ elseif(APPLE) endif() if(WITH_PYTHON) - if(NOT WITH_PYTHON_MODULE) - # we use precompiled libraries for py 3.3 and up by default - + # we use precompiled libraries for py 3.3 and up by default + set(PYTHON_VERSION 3.3) + if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK) # normally cached but not since we include them with blender - set(PYTHON_VERSION 3.3) set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m") # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet set(PYTHON_LIBRARY python${PYTHON_VERSION}m) @@ -1469,9 +1472,6 @@ elseif(APPLE) # set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled else() # module must be compiled against Python framework - - # normally cached but not since we include them with blender - set(PYTHON_VERSION 3.3) set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m") set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}") #set(PYTHON_LIBRARY python${PYTHON_VERSION}) @@ -1573,8 +1573,8 @@ elseif(APPLE) set(WITH_INPUT_NDOF OFF) # unsupported endif() - if(WITH_PYTHON_MODULE) - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/python")# force cmake to link right framework + if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK) + set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python")# force cmake to link right framework endif() if(WITH_OPENCOLLADA) @@ -2182,6 +2182,9 @@ if(FIRST_RUN) info_cfg_option(WITH_PYTHON_INSTALL_NUMPY) info_cfg_option(WITH_PYTHON_MODULE) info_cfg_option(WITH_PYTHON_SAFETY) + if(APPLE) + info_cfg_option(WITH_PYTHON_FRAMEWORK) + endif() info_cfg_text("Modifiers:") info_cfg_option(WITH_MOD_BOOLEAN) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index bb5f34167bc..69bad2b8cce 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -689,7 +689,7 @@ elseif(APPLE) ) # python - if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE) + 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 @@ -742,7 +742,7 @@ elseif(APPLE) ) # python - if(WITH_PYTHON) + if(WITH_PYTHON AND NOT WITH_PYTHON_FRAMEWORK) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/python/