The following issue has been SUBMITTED. ====================================================================== https://cmake.org/Bug/view.php?id=15804 ====================================================================== Reported By: Sam Thursfield Assigned To: ====================================================================== Project: CMake Issue ID: 15804 Category: Modules Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2015-10-20 05:32 EDT Last Modified: 2015-10-20 05:32 EDT ====================================================================== Summary: FindPkgConfig pkg_check_modules command should return full path to shared libraries in _LIBRARIES variable Description: CMake seems to encourage using absolute paths to shared libraries.
>From link_directories() documentation: Note that this command is rarely necessary. Library locations returned by find_package() and find_library() are absolute paths. Pass these absolute library file paths directly to the target_link_libraries() command. CMake will ensure the linker finds them. However, the FindPkgConfig module doesn't follow this, and instead returns just the names of libraries, plus a linker path. Since CMake makes it awkward to propagate the linker path, so the end result is that if you have a package installed in a non-standard library path, things break. Steps to Reproduce: An example pkg-config file: cmake_minimum_required(VERSION 3.3.2) find_package(PkgConfig REQUIRED) pkg_check_modules(ZLIB zlib REQUIRED) message("ZLIB_LIBRARIES: ${ZLIB_LIBRARIES}") message("ZLIB_LIBRARY_DIRS: ${ZLIB_LIBRARY_DIRS}") Output: ZLIB_LIBRARIES: z ZLIB_LIBRARY_DIRS: /usr/lib64 Expected output: ZLIB_LIBRARIES: /usr/lib64/libz.so Additional Information: I'm aware that in the case of Zlib there is a FindZLib module, and /usr/lib64 is in my library search path in any case. This is just an example. The painful case is where I had to build a library from source myself and then install it into a non-standard prefix. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2015-10-20 05:32 Sam Thursfield New Issue ====================================================================== -- 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