View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014345CMake(No Category)public2013-08-08 04:562016-06-10 14:31
Reporterhyde 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0014345: pkg_check_modules does not honor link command given by pkg-config: leaves out -L flag
DescriptionSituation: A library is installed in a custom location, and it has pkg-config .pc file installed, `pkg-config --libs ...` gives correct link command. Library is added to project with "pkg-check-modules" in CMakeLists.txt.

Running cmake succeeds and finds the library. Running make, compilation succeeds and correct -I option is added.

Bug: only -l option is given for link command, and -L is not given, so linker does not find the library, and build fails.
Steps To ReproduceMinimal example to reproduce provided in attached .zip (please review all files before running/building, needs root for test lib install!).

Overview of steps:

Have a library in custom location, not in default linker search path.

Have pkg-config file for the library, which gives correct compilation (-I) and linking flags (-l, -L).

Add the library to a project with pkg_check_modules.

Use a symbol from the library in source code.

Build project.

Linking fails, because -L is not added and linker does not find the library.

Additional InformationPossibly related issue: http://www.cmake.org/Bug/view.php?id=8644 [^]

It's possible there is something wrong with the project files (in the uploaded .zip), but they are fine as far as I can see. It's also possible there's something wrong with how cmake is set up in the Linux distro.

Workaround: add to CMakeLists.txt explicit path for the custom library (also sets RPATH, be aware):

link_directories(${XXXXX_LIBRARY_DIRS})

TagsNo tags attached.
Attached Fileszip file icon cmake_Lbug_sscce.zip [^] (2,360 bytes) 2013-08-08 04:56

 Relationships

  Notes
(0033681)
hyde (reporter)
2013-08-08 04:59

Note difference between -<lower case L> and -<upper case I> switches above.
(0033682)
Rolf Eike Beer (developer)
2013-08-08 06:27

The macro should probably call find_library() for every library returned by the .pc file, passing HINTS for the -L flags from the .pc file, so that at the end a list of full paths to the libraries is returned as with any other Find* module.

Is HINTS evaluated before the standard paths? Otherwise this would have to be tweaked also so the stuff from the .pc file has precedence before the standard install stuff.
(0040206)
Sam Thursfield (reporter)
2016-01-12 12:57

https://cmake.org/Bug/view.php?id=15804 [^] is related
(0042346)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2013-08-08 04:56 hyde New Issue
2013-08-08 04:56 hyde File Added: cmake_Lbug_sscce.zip
2013-08-08 04:59 hyde Note Added: 0033681
2013-08-08 06:27 Rolf Eike Beer Note Added: 0033682
2016-01-12 12:57 Sam Thursfield Note Added: 0040206
2016-06-10 14:29 Kitware Robot Note Added: 0042346
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team