فهرست منبع

FindPythonLibs: Prefer libs early in search path regardless of name

Add `NAMES_PER_DIR` to all `find_library` invocations so that we
consider all possible names in each search directory before moving on to
the next directory.  This helps find the package that appears earliest
in the search path regardless of how it names its libraries.

Fixes: #17336
Brad King 8 سال پیش
والد
کامیت
3976a1066a
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      Modules/FindPythonLibs.cmake

+ 3 - 0
Modules/FindPythonLibs.cmake

@@ -122,6 +122,7 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
   if(WIN32)
   if(WIN32)
     find_library(PYTHON_DEBUG_LIBRARY
     find_library(PYTHON_DEBUG_LIBRARY
       NAMES python${_CURRENT_VERSION_NO_DOTS}_d python
       NAMES python${_CURRENT_VERSION_NO_DOTS}_d python
+      NAMES_PER_DIR
       HINTS ${_Python_LIBRARY_PATH_HINT}
       HINTS ${_Python_LIBRARY_PATH_HINT}
       PATHS
       PATHS
       [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
       [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
@@ -145,6 +146,7 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
       python${_CURRENT_VERSION}m
       python${_CURRENT_VERSION}m
       python${_CURRENT_VERSION}u
       python${_CURRENT_VERSION}u
       python${_CURRENT_VERSION}
       python${_CURRENT_VERSION}
+    NAMES_PER_DIR
     HINTS
     HINTS
       ${_Python_LIBRARY_PATH_HINT}
       ${_Python_LIBRARY_PATH_HINT}
     PATHS
     PATHS
@@ -157,6 +159,7 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
   # Look for the static library in the Python config directory
   # Look for the static library in the Python config directory
   find_library(PYTHON_LIBRARY
   find_library(PYTHON_LIBRARY
     NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
     NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
+    NAMES_PER_DIR
     # Avoid finding the .dll in the PATH.  We want the .lib.
     # Avoid finding the .dll in the PATH.  We want the .lib.
     NO_SYSTEM_ENVIRONMENT_PATH
     NO_SYSTEM_ENVIRONMENT_PATH
     # This is where the static library is usually located
     # This is where the static library is usually located