From 2e293c39da969cc0c39503e1fef6310b4ef85d85 Mon Sep 17 00:00:00 2001 From: Yuriy Khokhulya Date: Thu, 11 May 2017 23:46:21 +0300 Subject: FindPkgConfig: Fix pkg_check_modules() non-standard location search During search of the library file `pkg_check_modules()` attempts to find it in last specified library path in `${_prefix}_LDFLAGS`, that after dependency resolving contains path to standard location. So in case when `${_prefix}_LDFLAGS` has: -L/prefix;-L/usr/local/lib;-llibrary_from_prefix;-ldependency `library_from_prefix` will not be found. As solution need try to find the library in all paths preceding to the library. Fixes: #16873 --- Modules/FindPkgConfig.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 54572f0..12a5ded 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -190,10 +190,12 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat string(APPEND _find_opts " NO_CMAKE_ENVIRONMENT_PATH") endif() + unset(_search_paths) foreach (flag IN LISTS ${_prefix}_LDFLAGS) if (flag MATCHES "^-L(.*)") # only look into the given paths from now on - set(_find_opts HINTS ${CMAKE_MATCH_1} NO_DEFAULT_PATH) + list(APPEND _search_paths ${CMAKE_MATCH_1}) + set(_find_opts HINTS ${_search_paths} NO_DEFAULT_PATH) continue() endif() if (flag MATCHES "^-l(.*)") -- cgit v0.12