From 811f6c825271320259ed0ccdbe3c2d577ccbdcd4 Mon Sep 17 00:00:00 2001 From: James Touton Date: Fri, 3 Jun 2016 18:51:18 -0700 Subject: [PATCH] Xcode: Add XCODE_FILE_ATTRIBUTES source file property This adds values to the ATTRIBUTES list in PBXBuildFile settings. --- Help/manual/cmake-properties.7.rst | 1 + Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst | 11 +++++++++++ Source/cmGlobalXCodeGenerator.cxx | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 3403dcd86..1c64d6363 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -344,6 +344,7 @@ Properties on Source Files /prop_sf/VS_XAML_TYPE /prop_sf/WRAP_EXCLUDE /prop_sf/XCODE_EXPLICIT_FILE_TYPE + /prop_sf/XCODE_FILE_ATTRIBUTES /prop_sf/XCODE_LAST_KNOWN_FILE_TYPE .. _`Cache Entry Properties`: diff --git a/Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst b/Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst new file mode 100644 index 000000000..39e69665a --- /dev/null +++ b/Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst @@ -0,0 +1,11 @@ +XCODE_FILE_ATTRIBUTES +--------------------- + +Add values to the Xcode ``ATTRIBUTES`` setting on its reference to a +source file. Among other things, this can be used to set the role on +a mig file:: + + set_source_files_properties(defs.mig + PROPERTIES + XCODE_FILE_ATTRIBUTES "Client;Server" + ) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b43901849..8eefb196b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -714,6 +714,20 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( } } + // Add user-specified file attributes. + const char* extraFileAttributes = sf->GetProperty("XCODE_FILE_ATTRIBUTES"); + if (extraFileAttributes) { + // Expand the list of attributes. + std::vector attributes; + cmSystemTools::ExpandListArgument(extraFileAttributes, attributes); + + // Store the attributes. + for (std::vector::const_iterator ai = attributes.begin(); + ai != attributes.end(); ++ai) { + attrs->AddObject(this->CreateString(*ai)); + } + } + settings->AddAttributeIfNotEmpty("ATTRIBUTES", attrs); // Add the fileRef to the top level Resources group/folder if it is not