Am 2016-05-12 14:59, schrieb Brad King:
On 05/11/2016 05:52 PM, Rolf Eike Beer wrote:
It has always nagged me that the FindPkgConfig module requires people to use link_directories(). Now I created a new optional mode for pkg_check_modules() and pkg_search_modules() which will search the absolute paths of the libraries that are returned by pkg-config, and create an imported target from that information that also contains defines and include directories. It restricts searching to the directories returned by pkg-config, if none are given the normal search rules are used. I have manually tested this and it seems to work. Please have a look and tell me if I have missed something before I put
this into next.

Great!  I've long wanted to see this done.

+    if (flag MATCHES "^-l(.*)")
+      set(_pkg_search "${CMAKE_MATCH_1}")
+    else()
+      continue()
+    endif()
+
+    find_library(${_prefix}-${CMAKE_MATCH_1}
+                 NAMES ${CMAKE_MATCH_1}
+                 ${_find_opts})
+    list(APPEND _libs "${${_prefix}-${CMAKE_MATCH_1}}")

Shouldn't these latter ${CMAKE_MATCH_1} references use ${_pkg_search} instead?

The whole _pkg_search thing can go away, it's from an earlier version of the patch. This should work the same:

if (NOT flag MATCHES "^-l(.*)")
  continue()
endif()

find_library(${_prefix}-${CMAKE_MATCH_1}
             NAMES ${CMAKE_MATCH_1}
             ${_find_opts})
list(APPEND _libs "${${_prefix}-${CMAKE_MATCH_1}}")

Eike
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to