| 1801 | } |
| 1802 | |
| 1803 | void 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 | |
| 1853 | bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf) |
| 1854 | { |
no test coverage detected