The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=12390 ====================================================================== Reported By: Martin von Gagern Assigned To: ====================================================================== Project: CMake Issue ID: 12390 Category: Modules Reproducibility: always Severity: feature Priority: normal Status: new ====================================================================== Date Submitted: 2011-08-07 09:04 EDT Last Modified: 2011-08-07 09:04 EDT ====================================================================== Summary: Parse output from <pkgname>-config binaries for -I/-L/-l flags Description: There 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 Information: The 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. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2011-08-07 09:04 Martin von GagernNew Issue ====================================================================== _______________________________________________ cmake-developers mailing list [email protected] http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
