MantisBT - CMake
View Issue Details
0008776CMakeCMakepublic2009-03-21 19:572016-06-10 14:30
Daniel Nelson 
Bill Hoffman 
normalminoralways
closedmoved 
CMake-2-6 
 
0008776: Source files should have a modern COMPILE_OPTIONS property.
[Original title: Using set_property() on COMPILE_FLAGS with multiple options results in bad command in Makefiles]

If you have a CMakeLists.txt with a line like this:
set_property(SOURCE main.cpp PROPERTY COMPILE_FLAGS -Werror -Wall)

You will get a build command in build.make:
/usr/bin/c++ $(CXX_DEFINES) $(CXX_FLAGS) -Werror;-Wall -o CMakeFiles/bug.dir/main.cpp.o -c /home/torham/src/cmake/prop_bug/main.cpp

The two options are added with a ; instead of a space, and sh will try to execute the second command '-Wall'

You can avoid this by doing some escaping in the CMakeLists.txt yourself, but it would be nicer if this wasn't necessary:
set_property(SOURCE main.cpp PROPERTY COMPILE_FLAGS "\"-Werror\" \"-Wall\"")

This might effect similar commands too.
No tags attached.
Issue History
2009-03-21 19:57Daniel NelsonNew Issue
2009-03-22 21:54Bill HoffmanNote Added: 0015750
2009-03-22 21:54Bill HoffmanStatusnew => assigned
2009-03-22 21:54Bill HoffmanAssigned To => Bill Hoffman
2009-03-24 18:28Daniel NelsonNote Added: 0015795
2013-11-02 10:22Stephen KellyNote Added: 0034324
2013-11-02 10:22Stephen KellySummaryUsing set_property() on COMPILE_FLAGS with multiple options results in bad command in Makefiles => Source files should have a modern COMPILE_OPTIONS property.
2013-11-02 10:22Stephen KellyDescription Updatedbug_revision_view_page.php?rev_id=1306#r1306
2016-06-10 14:27Kitware RobotNote Added: 0041523
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0015750)
Bill Hoffman   
2009-03-22 21:54   
Or you could do this:

set_property(SOURCE main.cpp PROPERTY COMPILE_FLAGS "-Werror -Wall")
(0015795)
Daniel Nelson   
2009-03-24 18:28   
Yeah that works. I also noticed you have the same problem if you try to do something like this:

set_property(SOURCE main.cpp APPEND PROPERTY COMPILE_FLAGS -Wall)
# ... do other stuff ...
set_property(SOURCE main.cpp APPEND PROPERTY COMPILE_FLAGS -Werror)
(0034324)
Stephen Kelly   
2013-11-02 10:22   
A COMPILE_OPTIONS property should be added so that you don't need APPEND_STRING in that case.
(0041523)
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.