Skip to content

Commit

Permalink
Add CMake option for custom Python framework on Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
dakcarto committed Dec 22, 2012
1 parent 991666c commit d56b1c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -82,6 +82,10 @@ IF (WITH_BINDINGS)
SET (WITH_PY_COMPILE FALSE CACHE BOOL "Determines whether Python modules in staged or installed locations are byte-compiled")
# concatenate QScintilla2 API files
SET (WITH_QSCIAPI TRUE CACHE BOOL "Determines whether the QScintilla2 API files will be updated and concatenated")
# path to custom Python framework on Mac
IF (APPLE)
SET (PYTHON_CUSTOM_FRAMEWORK "" CACHE PATH "Path to custom Python.framework on Mac. (should not have to specify other Python options)")
ENDIF (APPLE)
ENDIF (WITH_BINDINGS)

#BUILD WITH QtMobility by default on android only. Other platform can force it
Expand Down
17 changes: 15 additions & 2 deletions cmake/FindPythonLibrary.cmake
Expand Up @@ -31,6 +31,19 @@ if(EXISTS PYTHON_LIBRARY)
set(PYTHONLIBRARY_FOUND TRUE)
else(EXISTS PYTHON_LIBRARY)

set(_custom_python_fw FALSE)
if(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
if("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
STRING(REGEX REPLACE "(.*Python\\.framework).*$" "\\1" _python_fw "${PYTHON_CUSTOM_FRAMEWORK}")
set(PYTHON_EXECUTABLE "${_python_fw}/Versions/Current/bin/python")
set(PYTHON_INCLUDE_PATH "${_python_fw}/Versions/Current/Headers")
set(PYTHON_LIBRARY "${_python_fw}/Versions/Current/Python")
if(EXISTS "${PYTHON_EXECUTABLE}" AND EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
set(_custom_python_fw TRUE)
endif()
endif("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
endif(APPLE AND PYTHON_CUSTOM_FRAMEWORK)

FIND_PACKAGE(PythonInterp)

if(PYTHONINTERP_FOUND)
Expand Down Expand Up @@ -60,7 +73,7 @@ else(EXISTS PYTHON_LIBRARY)
endif(python_config)

# adapted from cmake's builtin FindPythonLibs
if(APPLE)
if(APPLE AND NOT _custom_python_fw)
CMAKE_FIND_FRAMEWORKS(Python)
set(PYTHON_FRAMEWORK_INCLUDES)
if(Python_FRAMEWORKS)
Expand All @@ -75,7 +88,7 @@ else(EXISTS PYTHON_LIBRARY)
endif(NOT PYTHON_LIBRARY)
set(PYTHONLIBRARY_FOUND TRUE)
endif(Python_FRAMEWORKS)
endif(APPLE)
endif(APPLE AND NOT _custom_python_fw)
endif(PYTHONINTERP_FOUND)

if(PYTHONLIBRARY_FOUND)
Expand Down

0 comments on commit d56b1c8

Please sign in to comment.