summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-05-15 17:50:26 (GMT)
committerBrad King <brad.king@kitware.com>2014-05-15 18:01:16 (GMT)
commitae80cb9f28c8c278a6897f331f65a1be77058897 (patch)
tree134eaa3bb2d9dd41583a2d56c152d13ddf1daf8b /Source/cmGlobalXCodeGenerator.cxx
parent032961c6ac81d82270a7b1986935111aa5e32a56 (diff)
downloadCMake-ae80cb9f28c8c278a6897f331f65a1be77058897.zip
CMake-ae80cb9f28c8c278a6897f331f65a1be77058897.tar.gz
CMake-ae80cb9f28c8c278a6897f331f65a1be77058897.tar.bz2
Xcode: Refactor internal source file type selection
Choose the attribute name and file type and send them through a single attribute generation code path. Compute the file extension only when needed. Leave the file type selection logic indented in a block so it can be made conditional later.
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx52
1 files changed, 26 insertions, 26 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index d44da37..ac75fc2 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -848,36 +848,36 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
}
fileRef->AddAttribute("fileEncoding", this->CreateString("4"));
- // Compute the extension.
- std::string ext;
- std::string realExt =
- cmSystemTools::GetFilenameLastExtension(fullpath);
- if(!realExt.empty())
+ bool useLastKnownFileType = false;
+ std::string fileType;
{
- // Extension without the leading '.'.
- ext = realExt.substr(1);
- }
+ // If fullpath references a directory, then we need to specify
+ // lastKnownFileType as folder in order for Xcode to be able to
+ // open the contents of the folder.
+ // (Xcode 4.6 does not like explicitFileType=folder).
+ if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
+ {
+ fileType = "folder";
+ useLastKnownFileType = true;
+ }
+ else
+ {
+ // Compute the extension without leading '.'.
+ std::string ext = cmSystemTools::GetFilenameLastExtension(fullpath);
+ if(!ext.empty())
+ {
+ ext = ext.substr(1);
+ }
- // If fullpath references a directory, then we need to specify
- // lastKnownFileType as folder in order for Xcode to be able to open the
- // contents of the folder (Xcode 4.6 does not like explicitFileType=folder).
- if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
- {
- fileRef->AddAttribute("lastKnownFileType",
- this->CreateString("folder"));
- }
- else
- {
- bool keepLastKnownFileType = false;
- std::string sourcecode = GetSourcecodeValueFromFileExtension(ext,
- lang, keepLastKnownFileType);
- const char* attribute = keepLastKnownFileType ?
- "lastKnownFileType" :
- "explicitFileType";
- fileRef->AddAttribute(attribute,
- this->CreateString(sourcecode.c_str()));
+ fileType = GetSourcecodeValueFromFileExtension(
+ ext, lang, useLastKnownFileType);
+ }
}
+ fileRef->AddAttribute(useLastKnownFileType? "lastKnownFileType"
+ : "explicitFileType",
+ this->CreateString(fileType));
+
// Store the file path relative to the top of the source tree.
std::string path = this->RelativeToSource(fullpath.c_str());
std::string name = cmSystemTools::GetFilenameName(path.c_str());