diff options
author | Harry Mallon <hjmallon@gmail.com> | 2020-07-02 12:49:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-07-03 11:30:50 (GMT) |
commit | 258c8734a9116c807d25c1453d9ecae15dad581d (patch) | |
tree | c1c26275835551a37a9dcbc13262a8263076f20e | |
parent | b028e8c50ea337a7a0b505881cf0fa9675459de6 (diff) | |
download | CMake-258c8734a9116c807d25c1453d9ecae15dad581d.zip CMake-258c8734a9116c807d25c1453d9ecae15dad581d.tar.gz CMake-258c8734a9116c807d25c1453d9ecae15dad581d.tar.bz2 |
Xcode: Fix LANGUAGE property on .m/.mm files
When OBJC or OBJCXX is enabled as a language, prefer that for .m and .mm
source file language selection.
Fixes: #20257
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 17 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 1 |
2 files changed, 11 insertions, 7 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index bb422eb..074d981 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -468,6 +468,9 @@ void cmGlobalXCodeGenerator::Generate() } } + // cache the enabled languages for source file type queries + this->GetEnabledLanguages(this->EnabledLangs); + this->SetGenerationRoot(root); // now create the project this->OutputXCodeProject(root, keyVal.second); @@ -922,9 +925,9 @@ void cmGlobalXCodeGenerator::AddXCodeProjBuildRule( } } -std::string GetSourcecodeValueFromFileExtension(const std::string& _ext, - const std::string& lang, - bool& keepLastKnownFileType) +std::string GetSourcecodeValueFromFileExtension( + const std::string& _ext, const std::string& lang, + bool& keepLastKnownFileType, const std::vector<std::string>& enabled_langs) { std::string ext = cmSystemTools::LowerCase(_ext); std::string sourcecode = "sourcecode"; @@ -939,9 +942,9 @@ std::string GetSourcecodeValueFromFileExtension(const std::string& _ext, } else if (ext == "storyboard") { keepLastKnownFileType = true; sourcecode = "file.storyboard"; - } else if (ext == "mm") { + } else if (ext == "mm" && !cm::contains(enabled_langs, "OBJCXX")) { sourcecode += ".cpp.objcpp"; - } else if (ext == "m") { + } else if (ext == "m" && !cm::contains(enabled_langs, "OBJC")) { sourcecode += ".c.objc"; } else if (ext == "swift") { sourcecode += ".swift"; @@ -1028,8 +1031,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( fileType = (ext == "xcassets" ? "folder.assetcatalog" : "folder"); useLastKnownFileType = true; } else { - fileType = - GetSourcecodeValueFromFileExtension(ext, lang, useLastKnownFileType); + fileType = GetSourcecodeValueFromFileExtension( + ext, lang, useLastKnownFileType, this->EnabledLangs); } } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 0fc6558..11b9312 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -301,6 +301,7 @@ private: std::string ObjectDirArch; std::string GeneratorToolset; std::map<cmGeneratorTarget const*, size_t> TargetOrderIndex; + std::vector<std::string> EnabledLangs; }; #endif |