[Cmake-commits] CMake branch, master, updated. v3.11.1-792-g99e6582

Kitware Robot kwrobot at kitware.com
Mon May 14 09:55:03 EDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  99e658258e13f444ed935d0240c6a1be1d76d306 (commit)
       via  92ac721a44bcae43ed9ad33d4d0fb22968073a92 (commit)
      from  5a227ce805f06bf8a31cc3a47169bcf1f33bda1b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=99e658258e13f444ed935d0240c6a1be1d76d306
commit 99e658258e13f444ed935d0240c6a1be1d76d306
Merge: 5a227ce 92ac721
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon May 14 13:46:02 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Mon May 14 09:46:31 2018 -0400

    Merge topic 'FindPkgConfig-LINK_LIBRARIES'
    
    92ac721a44 FindPkgConfig: export the list of found libraries also as variable
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2068


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92ac721a44bcae43ed9ad33d4d0fb22968073a92
commit 92ac721a44bcae43ed9ad33d4d0fb22968073a92
Author:     Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Fri May 11 17:17:26 2018 +0200
Commit:     Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Fri May 11 19:35:53 2018 +0200

    FindPkgConfig: export the list of found libraries also as variable

diff --git a/Help/release/dev/FindPkgConfig-LINK_LIBRARIES.rst b/Help/release/dev/FindPkgConfig-LINK_LIBRARIES.rst
new file mode 100644
index 0000000..b915556
--- /dev/null
+++ b/Help/release/dev/FindPkgConfig-LINK_LIBRARIES.rst
@@ -0,0 +1,6 @@
+FindPkgConfig-LINK_LIBRARIES
+----------------------------
+
+* The :module:`FindPkgConfig` module has learned to export the found libraries
+  with full path for direct consumption with the :command:`target_link_libraries`
+  command.
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 5223b1d..5ee703a 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -88,16 +88,9 @@ endif()
 
 if(BLA_PREFER_PKGCONFIG)
   find_package(PkgConfig)
-  pkg_check_modules(PKGC_BLAS IMPORTED_TARGET blas)
+  pkg_check_modules(PKGC_BLAS blas)
   if(PKGC_BLAS_FOUND)
-    # FIXME: We should not interpret the INTERFACE_LINK_LIBRARIES property
-    # because it could have generator expressions and such.  This is a
-    # workaround for pkg_check_modules not providing a first-class way to
-    # get the list of libraries.
-    get_property(BLAS_LIBRARIES TARGET PkgConfig::PKGC_BLAS PROPERTY INTERFACE_LINK_LIBRARIES)
-    find_package_handle_standard_args(BLAS
-                                      REQUIRED_VARS BLAS_LIBRARIES
-                                      VERSION_VAR PKGC_BLAS_VERSION)
+    set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}")
     return()
   endif()
 endif()
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 95af0bf..775a9d7 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -183,8 +183,8 @@ endfunction()
 
 # scan the LDFLAGS returned by pkg-config for library directories and
 # libraries, figure out the absolute paths of that libraries in the
-# given directories, and create an imported target from them
-function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_path)
+# given directories
+function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path)
   unset(_libs)
   unset(_find_opts)
 
@@ -221,18 +221,23 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
     list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}")
   endforeach()
 
+  set(${_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE)
+endfunction()
+
+# create an imported target from all the information returned by pkg-config
+function(_pkg_create_imp_target _prefix)
   # only create the target if it is linkable, i.e. no executables
   if (NOT TARGET PkgConfig::${_prefix}
-      AND ( ${_prefix}_INCLUDE_DIRS OR _libs OR ${_prefix}_CFLAGS_OTHER ))
+      AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_CFLAGS_OTHER ))
     add_library(PkgConfig::${_prefix} INTERFACE IMPORTED)
 
     if(${_prefix}_INCLUDE_DIRS)
       set_property(TARGET PkgConfig::${_prefix} PROPERTY
                    INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}")
     endif()
-    if(_libs)
+    if(${_prefix}_LINK_LIBRARIES)
       set_property(TARGET PkgConfig::${_prefix} PROPERTY
-                   INTERFACE_LINK_LIBRARIES "${_libs}")
+                   INTERFACE_LINK_LIBRARIES "${${_prefix}_LINK_LIBRARIES}")
     endif()
     if(${_prefix}_CFLAGS_OTHER)
       set_property(TARGET PkgConfig::${_prefix} PROPERTY
@@ -241,6 +246,15 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
   endif()
 endfunction()
 
+# recalculate the dynamic output
+# this is a macro and not a function so the result of _pkg_find_libs is automatically propagated
+macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target)
+  _pkg_find_libs(${_prefix} ${_no_cmake_path} ${_no_cmake_environment_path})
+  if(${_imp_target})
+    _pkg_create_imp_target(${_prefix})
+  endif()
+endmacro()
+
 ###
 macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _prefix)
   _pkgconfig_unset(${_prefix}_FOUND)
@@ -460,9 +474,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
       _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS              ""        --cflags )
       _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER        ""        --cflags-only-other )
 
-      if (_imp_target)
-        _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path})
-      endif()
+      _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target})
     endif()
 
     if(NOT "${_extra_paths}" STREQUAL "")
@@ -525,6 +537,7 @@ endmacro()
 
     <XXX>_FOUND          ... set to 1 if module(s) exist
     <XXX>_LIBRARIES      ... only the libraries (without the '-l')
+    <XXX>_LINK_LIBRARIES ... the libraries and their absolute paths
     <XXX>_LIBRARY_DIRS   ... the paths of the libraries (without the '-L')
     <XXX>_LDFLAGS        ... all required linker flags
     <XXX>_LDFLAGS_OTHER  ... all other linker flags
@@ -592,8 +605,10 @@ macro(pkg_check_modules _prefix _module0)
     if (${_prefix}_FOUND)
       _pkgconfig_set(__pkg_config_arguments_${_prefix} "${_module0};${ARGN}")
     endif()
-  elseif (${_prefix}_FOUND AND ${_imp_target})
-    _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path})
+  else()
+    if (${_prefix}_FOUND)
+      _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target})
+    endif()
   endif()
 endmacro()
 
@@ -646,8 +661,8 @@ macro(pkg_search_module _prefix _module0)
     endif()
 
     _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
-  elseif (${_prefix}_FOUND AND ${_imp_target})
-    _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path})
+  elseif (${_prefix}_FOUND)
+    _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target})
   endif()
 endmacro()
 
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
index 606b1df..1150568 100644
--- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
@@ -85,3 +85,15 @@ pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakep
 if (NOT TARGET PkgConfig::FakePackage2)
   message(FATAL_ERROR "No import target for fake package 2 with prefix path")
 endif()
+
+# check that the full library path is also returned
+if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a")
+  message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}")
+endif()
+
+# the information in *_LINK_LIBRARIES is not cached, so ensure is also is present on second run
+unset(FakePackage2_LINK_LIBRARIES)
+pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2)
+if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a")
+  message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on second run: ${FakePackage2_LINK_LIBRARIES}")
+endif()

-----------------------------------------------------------------------

Summary of changes:
 Help/release/dev/FindPkgConfig-LINK_LIBRARIES.rst  |    6 +++
 Modules/FindBLAS.cmake                             |   11 +-----
 Modules/FindPkgConfig.cmake                        |   39 ++++++++++++++------
 .../FindPkgConfig_IMPORTED_TARGET.cmake            |   12 ++++++
 4 files changed, 47 insertions(+), 21 deletions(-)
 create mode 100644 Help/release/dev/FindPkgConfig-LINK_LIBRARIES.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list