MantisBT - CMake
View Issue Details
0015634CMakeCMakepublic2015-06-29 09:132016-06-10 14:31
Heinrich Fink 
Kitware Robot 
normalminoralways
closedmoved 
CMake 3.2.3 
 
0015634: Support for pkgconfig --define-variable
It is often necessary to re-define the prefix variable of pkgconfig scripts to adapt to different compilation environments. This is usually done via "pkg-config --define-variable=prefix=/my/dev/root/libs". Unfortunately this workflow is not support by CMake scripts that use pkgconfig. A simple option to define additional agurments for pkg-config when invoked would be helpful already. Manually redefining the pkg-config executable path, to already contain the additional argument, wouldn't work.
No tags attached.
Issue History
2015-06-29 09:13Heinrich FinkNew Issue
2015-06-29 10:39Heinrich FinkNote Added: 0038996
2015-06-29 10:46Brad KingNote Added: 0038997
2015-06-29 10:57Heinrich FinkNote Added: 0038998
2015-06-29 11:30Brad KingNote Added: 0038999
2015-09-08 20:00danblackNote Added: 0039373
2016-06-10 14:29Kitware RobotNote Added: 0042801
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0038996)
Heinrich Fink   
2015-06-29 10:39   
It should be noted that our current workaround is to set the PKG_CONFIG environment variable to a custom shell script that looks like this:

#!/bin/bash
pkg-config --define-variable=SOME_VAR=SOME_PATH $*
(0038997)
Brad King   
2015-06-29 10:46   
The public pkg_check_modules and pkg_search_module macros provided by the FindPkgConfig module contain many internal invocations of pkg-config. Perhaps some additional/optional argument or variable could be checked by these macros to pass extra options to pkg-config like this.

However, if your goal is just to search additional prefixes, the CMake way to do that is to set CMAKE_PREFIX_PATH as would be done for any other CMake package.
(0038998)
Heinrich Fink   
2015-06-29 10:57   
In my understanding, CMAKE_PREFIX_PATH, wouldn't be enough in our case. That would only allow to search for *.pc files in additional directories, but not actually replace a variable of the *.pc files themselves.

My web search today showed that there was a patch for this a while ago: http://www.cmake.org/pipermail/cmake/2009-February/027404.html [^]

Like you mentioned, this would be one solution, but I couldn't find the actual patch, as it was capped from the mailing archive.
(0038999)
Brad King   
2015-06-29 11:30   
Re 0015634:0038998: Okay. If you want to try to revive that patch, please read CONTRIBUTING.rst for the preferred contribution path.

Since that patch was drafted we now have Tests/RunCMake/FindPkgConfig/ to test the module. The test case will need to be updated to cover the new feature too.
(0039373)
danblack   
2015-09-08 20:00   
along a similar lines I wouldn't mind seeing the pkg-config --variable={VAR} extraction.

Is extracting all variables by default an API break? What CMake interface/macro would you choose for this and --define-variable?

Planned use - grabbing systemd directories: http://www.freedesktop.org/software/systemd/man/systemd.html#System%20unit%20directories [^]
(0042801)
Kitware Robot   
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.