From 3976a1066afc89e23f4f7be2040c1e7835324f03 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Oct 2017 10:58:22 -0400 Subject: 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 --- Modules/FindPythonLibs.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 63ec9a8..986726a 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -122,6 +122,7 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS}) if(WIN32) find_library(PYTHON_DEBUG_LIBRARY NAMES python${_CURRENT_VERSION_NO_DOTS}_d python + NAMES_PER_DIR HINTS ${_Python_LIBRARY_PATH_HINT} PATHS [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}u python${_CURRENT_VERSION} + NAMES_PER_DIR HINTS ${_Python_LIBRARY_PATH_HINT} PATHS @@ -157,6 +159,7 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS}) # Look for the static library in the Python config directory find_library(PYTHON_LIBRARY NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} + NAMES_PER_DIR # Avoid finding the .dll in the PATH. We want the .lib. NO_SYSTEM_ENVIRONMENT_PATH # This is where the static library is usually located -- cgit v0.12 From 192ab741ec65c96945893367bd3d04c08ca0f47a Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Oct 2017 11:04:27 -0400 Subject: FindPythonLibs: Allow find_library to search paths from system environment Drop the `NO_SYSTEM_ENVIRONMENT_PATH` option from our `find_library` calls. No other find modules do this. Also, since commit v3.3.0-rc1~430^2 (Teach find_(library|file|path) to get prefixes from PATH, 2015-02-18) we always search the `lib` directory of each prefix before the `bin` directory and so should prefer the non-`.dll` name. Issue: #17336 --- Modules/FindPythonLibs.cmake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 986726a..341d5d9 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -153,15 +153,11 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS}) ${PYTHON_FRAMEWORK_LIBRARIES} [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs - # Avoid finding the .dll in the PATH. We want the .lib. - NO_SYSTEM_ENVIRONMENT_PATH ) # Look for the static library in the Python config directory find_library(PYTHON_LIBRARY NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} NAMES_PER_DIR - # Avoid finding the .dll in the PATH. We want the .lib. - NO_SYSTEM_ENVIRONMENT_PATH # This is where the static library is usually located PATH_SUFFIXES python${_CURRENT_VERSION}/config ) -- cgit v0.12