MCPcopy Create free account
hub / github.com/Kitware/CMake / ForceLinkerLanguage

Method ForceLinkerLanguage

Source/cmGlobalXCodeGenerator.cxx:1803–1851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1801}
1802
1803void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
1804{
1805 // This matters only for targets that link.
1806 if (gtgt->GetType() != cmStateEnums::EXECUTABLE &&
1807 gtgt->GetType() != cmStateEnums::SHARED_LIBRARY &&
1808 gtgt->GetType() != cmStateEnums::MODULE_LIBRARY) {
1809 return;
1810 }
1811
1812 std::string llang = gtgt->GetLinkerLanguage("NOCONFIG");
1813 if (llang.empty()) {
1814 return;
1815 }
1816
1817 // If the language is compiled as a source trust Xcode to link with it.
1818 for (auto const& Language :
1819 gtgt->GetLinkImplementation("NOCONFIG", cmGeneratorTarget::UseTo::Link)
1820 ->Languages) {
1821 if (Language == llang) {
1822 return;
1823 }
1824 }
1825
1826 // Allow empty source file list for iOS Sticker packs
1827 cm::string_view productType = this->GetTargetProductType(gtgt);
1828 if (productType ==
1829 "com.apple.product-type.app-extension.messages-sticker-pack"_s) {
1830 return;
1831 }
1832
1833 // Add an empty source file to the target that compiles with the
1834 // linker language. This should convince Xcode to choose the proper
1835 // language.
1836 cmMakefile* mf = gtgt->Target->GetMakefile();
1837 std::string fname = cmStrCat(
1838 gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/CMakeFiles/",
1839 gtgt->GetName(), "-CMakeForceLinker.", cmSystemTools::LowerCase(llang));
1840 {
1841 cmGeneratedFileStream fout(fname);
1842 fout << '\n';
1843 }
1844 if (cmSourceFile* sf = mf->GetOrCreateSource(fname)) {
1845 sf->SetSpecialSourceType(
1846 cmSourceFile::SpecialSourceType::XcodeForceLinkerSource);
1847 sf->SetProperty("LANGUAGE", llang);
1848 sf->SetProperty("CXX_SCAN_FOR_MODULES", "0");
1849 gtgt->AddSource(fname);
1850 }
1851}
1852
1853bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
1854{

Callers 1

ForceLinkerLanguagesMethod · 0.95

Calls 13

GetTargetProductTypeMethod · 0.95
GetLinkImplementationMethod · 0.80
GetOrCreateSourceMethod · 0.80
SetSpecialSourceTypeMethod · 0.80
cmStrCatFunction · 0.70
GetTypeMethod · 0.45
GetLinkerLanguageMethod · 0.45
emptyMethod · 0.45
GetMakefileMethod · 0.45
GetLocalGeneratorMethod · 0.45
GetNameMethod · 0.45
SetPropertyMethod · 0.45

Tested by

no test coverage detected