summaryrefslogtreecommitdiff
path: root/Modules/FindPkgConfig.cmake
diff options
context:
space:
mode:
authorAleksandr Mezin <mezin.alexander@gmail.com>2018-05-02 04:16:55 +0600
committerAleksandr Mezin <mezin.alexander@gmail.com>2018-05-02 04:16:55 +0600
commitac5731a7e380349f19dc319e6c31e189b5faba93 (patch)
tree159654bd5c1533a8756d1ca985b9999d06797e27 /Modules/FindPkgConfig.cmake
parent4ac48237a0337a6d36556e0424e44baef38cad9a (diff)
downloadcmake-ac5731a7e380349f19dc319e6c31e189b5faba93.tar.gz
FindPkgConfig: correct library search path for imported targets.
`-L` in LDFLAGS doesn't mean that standard search paths should be excluded. Example: $ pkg-config --libs libmutter-2 -L/usr/lib/mutter -lmutter-2 -lgtk-3 -lgdk-3 -lmutter-clutter-2 -lcairo-gobject -latk-1.0 -lpangocairo-1.0 -lpango-1.0 -lfribidi -ljson-glib-1.0 -lgio-2.0 -lwayland-egl -lwayland-client -lXtst -lXi -lmutter-cogl-2 -lcairo -lgmodule-2.0 -pthread -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lgbm -ldrm -lwayland-server -lEGL -lXext -lXdamage -lXfixes -lXcomposite -lXrandr -lX11 Most of these libraries are located at standard paths, not in `/usr/lib/mutter`. Fixes: #17954
Diffstat (limited to 'Modules/FindPkgConfig.cmake')
-rw-r--r--Modules/FindPkgConfig.cmake8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 415e914297..95af0bf52a 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -200,9 +200,7 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
unset(_search_paths)
foreach (flag IN LISTS ${_prefix}_LDFLAGS)
if (flag MATCHES "^-L(.*)")
- # only look into the given paths from now on
list(APPEND _search_paths ${CMAKE_MATCH_1})
- set(_find_opts HINTS ${_search_paths} NO_DEFAULT_PATH)
continue()
endif()
if (flag MATCHES "^-l(.*)")
@@ -211,6 +209,12 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
continue()
endif()
+ if(_search_paths)
+ # Firstly search in -L paths
+ find_library(pkgcfg_lib_${_prefix}_${_pkg_search}
+ NAMES ${_pkg_search}
+ HINTS ${_search_paths} NO_DEFAULT_PATH)
+ endif()
find_library(pkgcfg_lib_${_prefix}_${_pkg_search}
NAMES ${_pkg_search}
${_find_opts})