[cmake-developers] Feature Request: Modify CXX_STANDARD behavior for Xcode Generator: Starting Tips?

Brad King brad.king at kitware.com
Mon Jul 6 14:18:21 EDT 2015


On 07/02/2015 10:22 PM, Jason Felds wrote:
> it places the -std=gnu++11 (or equivalent) calls in the OTHER_CPLUSPLUSFLAGS
> attribute instead of the CLANG_CXX_LANGUAGE_STANDARD attribute.

Yes.  This is just because the generator hasn't been taught to do so.
If this is added it also needs to be made dependent on the version of
Xcode because older versions may not support the explicit attribute.

>   * The flags are coming from either one of cflags[*li] or defFlags. defFlags
>     is filled in via GetDefineFlags() within Source/cmMakefile.h, whereas
>     cflags is filled in with the contents of gflags.
>   * Doing a grep for `gnu++11` gives me either .rst files or .cmake files,
>     but no .h or .cxx files.
[snip]
>   * Is there a proper source location where the standard is defined?
>   * Which variable does it get set to: cflags or defFlags?

The actual content of the flag comes from a platform information variable
populated by Modules/Compiler/*.cmake files for the current toolchain.
The generators use various internal APIs to lookup the flags along with
others.  I don't recall whether it goes through cflags or defFlags for
the Xcode generator in this case, but it doesn't matter which one because
the way to fix this is the same.  See below.

>   * Is there a clean way to remove the std flag and place it in a more
>     Apple friendly location, or would I have to do so?

The Visual Studio generators parse the final set of flags and maps
them to IDE project file property/attribute settings.  The Xcode
generator does this only for a tiny subset of attributes simply
because no one has taken the time to implement full mapping
infrastructure yet.  Therefore many attributes beyond just the
standard level are not properly expressed in Xcode's dialogs.

The code here:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalXCodeGenerator.cxx;hb=v3.3.0-rc3#l2211

does the minimal flag mapping for optimization levels right now.
This is the place to add other mappings.  Ideally it would be done
with a full parser and lookup tables like the VS generators do.

-Brad



More information about the cmake-developers mailing list