Skip to content

Commit b61b5b0

Browse files
committed
make honoring -DPYTHON_LIBRARY more solid.
as cmake --help-module FindPythonLibs states If you'd like to specify the installation of Python to use, you should modify the following cache variables: PYTHON_LIBRARY - path to the python library PYTHON_INCLUDE_PATH - path to where Python.h is found (please note it is PYTHON_INCLUDE_PATH (deprecated) and not PYTHON_INCLUDE_DIR (new in 2.8) since we require cmake >= 2.6.2)
1 parent e703bdf commit b61b5b0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmake/FindPythonLibrary.cmake

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
INCLUDE(CMakeFindFrameworks)
2828

29-
if(EXISTS PYTHON_LIBRARY)
29+
if(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
3030
# Already in cache, be silent
3131
set(PYTHONLIBRARY_FOUND TRUE)
32-
else(EXISTS PYTHON_LIBRARY)
32+
else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
3333

3434
set(_custom_python_fw FALSE)
3535
if(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
@@ -69,6 +69,7 @@ else(EXISTS PYTHON_LIBRARY)
6969
STRING(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR})
7070
endif(WIN32)
7171
FIND_LIBRARY(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH)
72+
set(PYTHON_INCLUDE_PATH ${PYTHON_INCLUDE_PATH} CACHE FILEPATH "Directory holding the python.h include file" FORCE)
7273
set(PYTHONLIBRARY_FOUND TRUE)
7374
endif(python_config)
7475

@@ -109,4 +110,4 @@ else(EXISTS PYTHON_LIBRARY)
109110
endif(PYTHONLIBRARY_FIND_REQUIRED)
110111
endif(PYTHONLIBRARY_FOUND)
111112

112-
endif (EXISTS PYTHON_LIBRARY)
113+
endif (EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")

0 commit comments

Comments
 (0)