View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012390CMakeModulespublic2011-08-07 09:042016-06-10 14:31
ReporterMartin von Gagern 
Assigned ToKitware Robot 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake 2.8.5 
Target VersionFixed in Version 
Summary0012390: Parse output from <pkgname>-config binaries for -I/-L/-l flags
DescriptionThere are many packages that install a <name>-conf of <name>-config binary which will generate cppflags/cflags and libs output, intended for use by depending packages in their configure or make phase. In cases where the package doesn't install a pkgconfig file as well, parsing the output of these commands is the most portable way to correctly use these packages.

CMake doesn't deal directly in compiler flags, though. So in order to turn this output into something cmake can handle properly, some parsing is required. Therefore I'd like to see a function that can turn the string
" -O2 -I\"/usr/include\"/foo -DFOO_VERSION=1.1 -I'/usr/include/some bar' \n"
into the CMake list
"/usr/include/foo;/usr/include/some bar"

So given a specific flag, -I in this case, it should filter out all arguments not starting with this flag, it should strip the flag from the remaining arguments, and it should combine the resulting items to a ;-separated list. It should remove quotes and preserve quoted spaces. The handling of spaces is particularly tricky, and probably broken in most ad-hoc solutions out there.

I'm not sure whether executing the binary and parsing its output should be a single step. Probably not, as the output for --libs should usually be parsed twice, once for -L library directories and once for -l library names. So a single command to do the parsing would be better. The flag to search for should be an argument to that command. But for the common cases -I,-L and -l you might want to add additional commands. That way, if you are running on a system which conventionally uses other flags instead of these well-known ones, you might search for these in addition to or instead of the common ones.

I guess the quotes-aware word splitting thing could be useful in other places as well, so having it as a separate function might be useful.
Additional InformationThe following CMake modules already do something like outlined above:
FindFLTK.cmake
FindFLTK2.cmake
FindGDAL.cmake
FindwxWidgets.cmake
FindXMLRPC.cmake

CMakeParseImplicitLinkInfo.cmake also does some parsing of linker command lines

Most of the above use something like STRING(REGEX REPLACE " +" ";" ...), and therefore won't handle quoted spaces properly.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0030293)
David Cole (manager)
2012-08-11 11:38

Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0041883)
Kitware Robot (administrator)
2016-06-10 14:28

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
2011-08-07 09:04 Martin von Gagern New Issue
2012-08-11 11:38 David Cole Status new => backlog
2012-08-11 11:38 David Cole Note Added: 0030293
2016-06-10 14:28 Kitware Robot Note Added: 0041883
2016-06-10 14:28 Kitware Robot Status backlog => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:28 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team