MantisBT - CMake
View Issue Details
0015224CMakeCMakepublic2014-10-28 13:292015-04-06 09:07
Ilya 
Brad King 
normalmajoralways
closedfixed 
AppleMac OS X10.10
CMake 3.0.2 
CMake 3.2CMake 3.2 
0015224: CMake unconditionally sets WARNING_CFLAGS for each targets overriding project-level option.
CMake not just sets WARNING_CFLAGS to the following:

    -Wmost
    -Wno-four-char-constants
    -Wno-unknown-pragmas

but also overrides higher-level options e.g. set via CMAKE_XCODE_ATTRIBUTE.

It should remove these 3 definitions, replace them with appropriate Xcode attributes or prepand WARNINGS_CFLAGS with "$(inherited)" so top-level attributes will be respected.
No tags attached.
Issue History
2014-10-28 13:29IlyaNew Issue
2014-10-28 13:30IlyaNote Added: 0037087
2014-10-28 14:07Brad KingNote Added: 0037088
2014-10-28 16:26IlyaNote Added: 0037091
2014-10-28 16:28IlyaNote Edited: 0037091bug_revision_view_page.php?bugnote_id=37091#r1599
2014-10-29 09:30Brad KingNote Added: 0037099
2014-10-29 09:31Brad KingNote Added: 0037100
2014-10-29 13:26IlyaNote Added: 0037102
2014-10-30 13:35Brad KingNote Added: 0037109
2014-10-30 13:36Brad KingAssigned To => Brad King
2014-10-30 13:36Brad KingStatusnew => assigned
2014-10-30 13:36Brad KingTarget Version => CMake 3.2
2014-10-31 10:23Ruslan BaratovNote Added: 0037115
2014-10-31 11:31Brad KingNote Edited: 0037109bug_revision_view_page.php?bugnote_id=37109#r1610
2014-11-03 09:33Brad KingStatusassigned => resolved
2014-11-03 09:33Brad KingResolutionopen => fixed
2014-11-03 09:33Brad KingFixed in Version => CMake 3.2
2015-04-06 09:07Robert MaynardNote Added: 0038437
2015-04-06 09:07Robert MaynardStatusresolved => closed

Notes
(0037087)
Ilya   
2014-10-28 13:30   
This is only relevant for the Xcode generator.
(0037088)
Brad King   
2014-10-28 14:07   
Historically the goal of the Xcode generator in CMake has been to make projects that use CMake build with Xcode, not to generate pretty projects like a human might. Lots more work would be needed to make each flag go to the right project attribute instead of putting them all in OTHER_CFLAGS. (The VS generator does this already, but the Xcode generator does not.) However, the build should work.

CMAKE_XCODE_ATTRIBUTE_ is meant for settings that CMake doesn't otherwise know how to generate. CMake does have a place to put the value of CMAKE_C_FLAGS, which should be used for any warning flags you need. They will go in OTHER_CFLAGS and the build should work.
(0037091)
Ilya   
2014-10-28 16:26   
(edited on: 2014-10-28 16:28)
Can you explain why CMake uncoditionally sets these flags to WARNING_CFLAGS?

I believe that in this particular case CMake should at least inherit unless user specifically overrides thi attributes by either using variable or target property.

(0037099)
Brad King   
2014-10-29 09:30   
Re 0015224:0037091: From the history it looks like it was part of the generator when it was first created. Perhaps it was trying to duplicate something Xcode generated in new projects back then.

Try this patch (untested):
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 13e6988..5e7a898 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2314,6 +2314,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
     group->AddObject(this->CreateString("-Wmost"));
     group->AddObject(this->CreateString("-Wno-four-char-constants"));
     group->AddObject(this->CreateString("-Wno-unknown-pragmas"));
+    group->AddObject(this->CreateString("$(inherited)"));
     buildSettings->AddAttribute("WARNING_CFLAGS", group);
     }
   else
(0037100)
Brad King   
2014-10-29 09:31   
As discussed in 0015225 you should be able to do just

 add_compile_options(
     -Wno-long-long
 )

prior to creating targets and the options will end up on the compilation line.
(0037102)
Ilya   
2014-10-29 13:26   
Brad, this patch works :) Will you apply it to mainstream?
(0037109)
Brad King   
2014-10-30 13:35   
(edited on: 2014-10-31 11:31)
Thanks for testing. Applied here:

 Xcode: Inherit global settings in per-target WARNING_CFLAGS
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=820e95d0 [^]

(0037115)
Ruslan Baratov   
2014-10-31 10:23   
> Lots more work would be needed to make each flag go to the right project attribute instead of putting them all in OTHER_CFLAGS

If anybody interested - here is the mapping between xcode attributes and warning flags: https://github.com/ruslo/leathers/wiki/List#xcodeclang-table [^]
I'm using it to generate cross-platform warnings: https://github.com/ruslo/sugar/wiki/Cross-platform-warning-suppression [^]
(0038437)
Robert Maynard   
2015-04-06 09:07   
Closing resolved issues that have not been updated in more than 4 months.