summaryrefslogtreecommitdiff
path: root/Modules/FindPythonLibs.cmake
diff options
context:
space:
mode:
authorFrancois Budin <francois.budin@gmail.com>2016-12-13 22:29:46 -0500
committerBrad King <brad.king@kitware.com>2016-12-15 09:34:48 -0500
commita12d8a03af8430d0a570c97deb200e16830568eb (patch)
tree7fd7df72fcc1a1d3b606ee6f3ec1ab10329d3288 /Modules/FindPythonLibs.cmake
parent61001557d44fef7b98a4bab463bf66797f927197 (diff)
downloadcmake-a12d8a03af8430d0a570c97deb200e16830568eb.tar.gz
FindPythonLibs: Tolerate call with PYTHON_LIBRARY already a list
`PYTHON_LIBRARY` may contain a list because of `SelectLibraryConfigurations`. If it is the case, the list can be: optimized;<FILEPATH_TO_RELEASE_LIBRARY>;debug;<FILEPATH_TO_DEBUG_LIBRARY> Instead of directly using the value of `PYTHON_LIBRARY` in the CMake function `get_filename_component()`, we loop over the content of the relevant parts of `PYTHON_LIBRARY` and `PYTHON_DEBUG_LIBRARY` whether they are lists or not. Suggested-by: Brad King <brad.king@kitware.com>
Diffstat (limited to 'Modules/FindPythonLibs.cmake')
-rw-r--r--Modules/FindPythonLibs.cmake19
1 files changed, 13 insertions, 6 deletions
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index cd623cf8f8..63ec9a84e2 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -168,12 +168,19 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
# Use the library's install prefix as a hint
set(_Python_INCLUDE_PATH_HINT)
- get_filename_component(_Python_PREFIX ${PYTHON_LIBRARY} PATH)
- get_filename_component(_Python_PREFIX ${_Python_PREFIX} PATH)
- if(_Python_PREFIX)
- set(_Python_INCLUDE_PATH_HINT ${_Python_PREFIX}/include)
- endif()
- unset(_Python_PREFIX)
+ # PYTHON_LIBRARY may contain a list because of SelectLibraryConfigurations
+ # which may have been run previously. If it is the case, the list can be:
+ # optimized;<FILEPATH_TO_RELEASE_LIBRARY>;debug;<FILEPATH_TO_DEBUG_LIBRARY>
+ foreach(lib ${PYTHON_LIBRARY} ${PYTHON_DEBUG_LIBRARY})
+ if(IS_ABSOLUTE "${lib}")
+ get_filename_component(_Python_PREFIX "${lib}" PATH)
+ get_filename_component(_Python_PREFIX "${_Python_PREFIX}" PATH)
+ if(_Python_PREFIX)
+ list(APPEND _Python_INCLUDE_PATH_HINT ${_Python_PREFIX}/include)
+ endif()
+ unset(_Python_PREFIX)
+ endif()
+ endforeach()
# Add framework directories to the search paths
set(PYTHON_FRAMEWORK_INCLUDES)