MantisBT - CMake
View Issue Details
0008644CMakeModulespublic2009-02-28 18:082016-06-10 14:30
Johannes Wienke 
Bill Hoffman 
normaltweakalways
closedmoved 
CMake-2-6 
 
0008644: Imcompatible output of pkg_check_modules for flags
The pkg_check_modules macro returns semicolon separated lists of flags. These lists cannot be directly used for any of the compiler flag varibale (e.g. in set_target_properties) because here a whitespace separated string is required. It would be much easier if the package config macro returns a string that can be used directly.
No tags attached.
Issue History
2009-02-28 18:08Johannes WienkeNew Issue
2009-09-14 15:24Bill HoffmanNote Added: 0017480
2009-09-14 15:24Bill HoffmanStatusnew => assigned
2009-09-14 15:24Bill HoffmanAssigned To => Bill Hoffman
2009-09-14 15:36Johannes WienkeNote Added: 0017482
2010-02-10 05:01Igor BaldachiniNote Added: 0019505
2010-08-29 10:39Kovarththanan RajaratnamCategoryCMake => Modules
2016-06-10 14:27Kitware RobotNote Added: 0041506
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0017480)
Bill Hoffman   
2009-09-14 15:24   
But, that would make it harder to parse them and manipulate them in Cmake.
(0017482)
Johannes Wienke   
2009-09-14 15:36   
Hm, that's true. What about providing two separate variables, one with the list as it is now and one that can be used as compiler flags? Or another solution would be to provide a macro that directly transforms the list into a string.
(0019505)
Igor Baldachini   
2010-02-10 05:01   
In CMake FAQ there is:

  Why do I have unwanted semicolons ; in my compiler flags?

CMake has a list data type. A list is stored as a string of semicolon-separated list elements. Whitespace separated arguments to a SET statement are interpreted as list elements. For instance, SET(var a b c d e) will give "var" a value of a;b;c;d;e and this list can be used by other CMake commands. However, if you pass ${var} to a non-CMake external tool, such as a compiler's command line, you are passing a;b;c;d;e which is not what you want. Instead you either need to pass "${var}", so that the list will be converted to a whitespace-separated string, or you need to SET(var "a b c d e") in the 1st place so that you're working with a string, not a list.

Then I expect that:

pkg_check_modules(ELEMENTARY elementary)
message(${ELEMENTARY_CFLAGS})
message("${ELEMENTARY_CFLAGS}")

1. prints a list with semicolon -> message(${ELEMENTARY_CFLAGS})
2. prints a list with whitespace -> message("${ELEMENTARY_CFLAGS}")

But the output result is

1. a list without semicolon and without whitespace -> message(${ELEMENTARY_CFLAGS})
-I/usr/local/include-I/usr/local/include/elementary-I/usr/local/include/eina-0-I/usr/local/include/eina-0/eina-I/usr/include/glib-2.0-I/usr/lib/glib-2.0/include-I/usr/include/lua5.1-I/usr/include/freetype2

2. a list with semicolon -> message("${ELEMENTARY_CFLAGS}")
-I/usr/local/include;-I/usr/local/include/elementary;-I/usr/local/include/eina-0;-I/usr/local/include/eina-0/eina;-I/usr/include/glib-2.0;-I/usr/lib/glib-2.0/include;-I/usr/include/lua5.1;-I/usr/include/freetype2

So the conversion dos not take place and the use of variable without quotation marks removes the semi-colon.
(0041506)
Kitware Robot   
2016-06-10 14:27   
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.