summaryrefslogtreecommitdiffstats
path: root/Modules/FindPkgConfig.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/FindPkgConfig.cmake')
-rw-r--r--Modules/FindPkgConfig.cmake20
1 files changed, 13 insertions, 7 deletions
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index e822b9c..4f50e38 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -238,8 +238,8 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
if(NOT "${_extra_paths}" STREQUAL "")
# Save the PKG_CONFIG_PATH environment variable, and add paths
# from the CMAKE_PREFIX_PATH variables
- set(_pkgconfig_path_old $ENV{PKG_CONFIG_PATH})
- set(_pkgconfig_path ${_pkgconfig_path_old})
+ set(_pkgconfig_path_old "$ENV{PKG_CONFIG_PATH}")
+ set(_pkgconfig_path "${_pkgconfig_path_old}")
if(NOT "${_pkgconfig_path}" STREQUAL "")
file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path)
endif()
@@ -263,6 +263,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
endif()
endif()
list(APPEND _lib_dirs "lib/pkgconfig")
+ list(APPEND _lib_dirs "share/pkgconfig")
# Check if directories exist and eventually append them to the
# pkgconfig path list
@@ -284,7 +285,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}")
string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}")
endif()
- set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path})
+ set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}")
endif()
# Unset variables
@@ -328,7 +329,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
if (_pkg_check_modules_pkg_op)
list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}")
else()
- list(APPEND _pkg_check_modules_exist_query --exists)
+ list(APPEND _pkg_check_modules_exist_query --exists --print-errors --short-errors)
endif()
_pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
@@ -342,12 +343,14 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
# execute the query
execute_process(
COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query}
- RESULT_VARIABLE _pkgconfig_retval)
+ RESULT_VARIABLE _pkgconfig_retval
+ ERROR_VARIABLE _pkgconfig_error
+ ERROR_STRIP_TRAILING_WHITESPACE)
# evaluate result and tell failures
if (_pkgconfig_retval)
if(NOT ${_is_silent})
- message(STATUS " Package '${_pkg_check_modules_pkg}' not found")
+ message(STATUS " ${_pkgconfig_error}")
endif()
set(_pkg_check_modules_failed 1)
@@ -379,6 +382,9 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
pkg_get_variable("${_pkg_check_prefix}_PREFIX" ${_pkg_check_modules_pkg} "prefix")
pkg_get_variable("${_pkg_check_prefix}_INCLUDEDIR" ${_pkg_check_modules_pkg} "includedir")
pkg_get_variable("${_pkg_check_prefix}_LIBDIR" ${_pkg_check_modules_pkg} "libdir")
+ foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR)
+ _pkgconfig_set("${_pkg_check_modules_pkg}_${variable}" "${${_pkg_check_modules_pkg}_${variable}}")
+ endforeach ()
if (NOT ${_is_silent})
message(STATUS " Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
@@ -398,7 +404,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
if(NOT "${_extra_paths}" STREQUAL "")
# Restore the environment variable
- set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path})
+ set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}")
endif()
unset(_extra_paths)