Skip to content

Commit d56b1c8

Browse files
committedDec 22, 2012
Add CMake option for custom Python framework on Mac
1 parent 991666c commit d56b1c8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed
 

‎CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ IF (WITH_BINDINGS)
8282
SET (WITH_PY_COMPILE FALSE CACHE BOOL "Determines whether Python modules in staged or installed locations are byte-compiled")
8383
# concatenate QScintilla2 API files
8484
SET (WITH_QSCIAPI TRUE CACHE BOOL "Determines whether the QScintilla2 API files will be updated and concatenated")
85+
# path to custom Python framework on Mac
86+
IF (APPLE)
87+
SET (PYTHON_CUSTOM_FRAMEWORK "" CACHE PATH "Path to custom Python.framework on Mac. (should not have to specify other Python options)")
88+
ENDIF (APPLE)
8589
ENDIF (WITH_BINDINGS)
8690

8791
#BUILD WITH QtMobility by default on android only. Other platform can force it

‎cmake/FindPythonLibrary.cmake

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ if(EXISTS PYTHON_LIBRARY)
3131
set(PYTHONLIBRARY_FOUND TRUE)
3232
else(EXISTS PYTHON_LIBRARY)
3333

34+
set(_custom_python_fw FALSE)
35+
if(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
36+
if("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
37+
STRING(REGEX REPLACE "(.*Python\\.framework).*$" "\\1" _python_fw "${PYTHON_CUSTOM_FRAMEWORK}")
38+
set(PYTHON_EXECUTABLE "${_python_fw}/Versions/Current/bin/python")
39+
set(PYTHON_INCLUDE_PATH "${_python_fw}/Versions/Current/Headers")
40+
set(PYTHON_LIBRARY "${_python_fw}/Versions/Current/Python")
41+
if(EXISTS "${PYTHON_EXECUTABLE}" AND EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
42+
set(_custom_python_fw TRUE)
43+
endif()
44+
endif("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
45+
endif(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
46+
3447
FIND_PACKAGE(PythonInterp)
3548

3649
if(PYTHONINTERP_FOUND)
@@ -60,7 +73,7 @@ else(EXISTS PYTHON_LIBRARY)
6073
endif(python_config)
6174

6275
# adapted from cmake's builtin FindPythonLibs
63-
if(APPLE)
76+
if(APPLE AND NOT _custom_python_fw)
6477
CMAKE_FIND_FRAMEWORKS(Python)
6578
set(PYTHON_FRAMEWORK_INCLUDES)
6679
if(Python_FRAMEWORKS)
@@ -75,7 +88,7 @@ else(EXISTS PYTHON_LIBRARY)
7588
endif(NOT PYTHON_LIBRARY)
7689
set(PYTHONLIBRARY_FOUND TRUE)
7790
endif(Python_FRAMEWORKS)
78-
endif(APPLE)
91+
endif(APPLE AND NOT _custom_python_fw)
7992
endif(PYTHONINTERP_FOUND)
8093

8194
if(PYTHONLIBRARY_FOUND)

0 commit comments

Comments
 (0)
Please sign in to comment.