diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2018-04-02 15:16:36 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@sap.com> | 2018-04-03 07:41:19 (GMT) |
commit | b1fd2bbe75bac249ce19f5a89ac06ff0bd38741c (patch) | |
tree | f11d24e019041642d8108ec5c3d049250f3518f2 /Modules | |
parent | e3ce4d7a282ba75a4d34aefb0176535bdbe55c36 (diff) | |
download | CMake-b1fd2bbe75bac249ce19f5a89ac06ff0bd38741c.zip CMake-b1fd2bbe75bac249ce19f5a89ac06ff0bd38741c.tar.gz CMake-b1fd2bbe75bac249ce19f5a89ac06ff0bd38741c.tar.bz2 |
FindPython: enhance multiple major versions lookup
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindPython.cmake | 15 | ||||
-rw-r--r-- | Modules/FindPython/Support.cmake | 9 |
2 files changed, 17 insertions, 7 deletions
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index c87f784..8139e53 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -144,18 +144,19 @@ else() set (Python_FIND_QUIETLY TRUE) set (Python_FIND_REQUIRED FALSE) - foreach (_Python_REQUIRED_VERSION_MAJOR IN ITEMS 3 2) + set (_Python_REQUIRED_VERSIONS 3 2) + set (_Python_REQUIRED_VERSION_LAST 2) + + foreach (_Python_REQUIRED_VERSION_MAJOR IN LISTS _Python_REQUIRED_VERSIONS) set (Python_FIND_VERSION ${_Python_REQUIRED_VERSION_MAJOR}) include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake) - if (Python_FOUND) + if (Python_FOUND OR + _Python_REQUIRED_VERSION_MAJOR EQUAL _Python_REQUIRED_VERSION_LAST) break() endif() # clean-up some CACHE variables to ensure look-up restart from scratch - foreach (_Python_ITEM IN ITEMS EXECUTABLE COMPILER - LIBRARY_RELEASE RUNTIME_LIBRARY_RELEASE - LIBRARY_DEBUG RUNTIME_LIBRARY_DEBUG - INCLUDE_DIR) - unset (Python_${_Python_ITEM} CACHE) + foreach (_Python_ITEM IN LISTS _Python_CACHED_VARS) + unset (${_Python_ITEM} CACHE) endforeach() endforeach() diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index be34624..179b394 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -162,12 +162,14 @@ unset (${_PYTHON_PREFIX}_VERSION_MINOR) unset (${_PYTHON_PREFIX}_VERSION_PATCH) unset (_${_PYTHON_PREFIX}_REQUIRED_VARS) +unset (_${_PYTHON_PREFIX}_CACHED_VARS) # first step, search for the interpreter if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter) list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_EXECUTABLE) + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_EXECUTABLE) endif() set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) @@ -305,6 +307,7 @@ endif() if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (${_PYTHON_PREFIX}_FIND_REQUIRED_Compiler) list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_COMPILER) + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_COMPILER) endif() # IronPython specific artifacts @@ -393,6 +396,12 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development) list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARY ${_PYTHON_PREFIX}_INCLUDE_DIR) + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_LIBRARY + ${_PYTHON_PREFIX}_LIBRARY_RELEASE + ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE + ${_PYTHON_PREFIX}_LIBRARY_DEBUG + ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG + ${_PYTHON_PREFIX}_INCLUDE_DIR) endif() # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES |