| 2058 | } |
| 2059 | |
| 2060 | void cmLocalGenerator::AddLanguageFlags(std::string& flags, |
| 2061 | cmGeneratorTarget const* target, |
| 2062 | cmBuildStep compileOrLink, |
| 2063 | std::string const& lang, |
| 2064 | std::string const& config) |
| 2065 | { |
| 2066 | // Add language-specific flags. |
| 2067 | this->AddConfigVariableFlags(flags, cmStrCat("CMAKE_", lang, "_FLAGS"), |
| 2068 | config); |
| 2069 | |
| 2070 | // Add the language standard flag for compiling, and sometimes linking. |
| 2071 | if (compileOrLink == cmBuildStep::Compile || |
| 2072 | (compileOrLink == cmBuildStep::Link && |
| 2073 | // Some toolchains require use of the language standard flag |
| 2074 | // when linking in order to use the matching standard library. |
| 2075 | // FIXME: If CMake gains an abstraction for standard library |
| 2076 | // selection, this will have to be reconciled with it. |
| 2077 | this->Makefile->IsOn( |
| 2078 | cmStrCat("CMAKE_", lang, "_LINK_WITH_STANDARD_COMPILE_OPTION")))) { |
| 2079 | cmStandardLevelResolver standardResolver(this->Makefile); |
| 2080 | std::string const& optionFlagDef = |
| 2081 | standardResolver.GetCompileOptionDef(target, lang, config); |
| 2082 | if (!optionFlagDef.empty()) { |
| 2083 | cmValue opt = |
| 2084 | target->Target->GetMakefile()->GetDefinition(optionFlagDef); |
| 2085 | if (opt) { |
| 2086 | cmList optList{ *opt }; |
| 2087 | for (std::string const& i : optList) { |
| 2088 | this->AppendFlagEscape(flags, i); |
| 2089 | } |
| 2090 | } |
| 2091 | } |
| 2092 | } |
| 2093 | |
| 2094 | std::string compilerId = this->Makefile->GetSafeDefinition( |
| 2095 | cmStrCat("CMAKE_", lang, "_COMPILER_ID")); |
| 2096 | |
| 2097 | std::string compilerSimulateId = this->Makefile->GetSafeDefinition( |
| 2098 | cmStrCat("CMAKE_", lang, "_SIMULATE_ID")); |
| 2099 | |
| 2100 | bool const compilerTargetsMsvcABI = |
| 2101 | (compilerId == "MSVC" || compilerSimulateId == "MSVC"); |
| 2102 | bool const compilerTargetsWatcomABI = |
| 2103 | (compilerId == "OpenWatcom" || compilerSimulateId == "OpenWatcom"); |
| 2104 | |
| 2105 | if (lang == "Swift") { |
| 2106 | if (cmValue v = target->GetProperty("Swift_LANGUAGE_VERSION")) { |
| 2107 | if (cmSystemTools::VersionCompare( |
| 2108 | cmSystemTools::OP_GREATER_EQUAL, |
| 2109 | this->Makefile->GetDefinition("CMAKE_Swift_COMPILER_VERSION"), |
| 2110 | "4.2")) { |
| 2111 | this->AppendFlags(flags, "-swift-version " + *v); |
| 2112 | } |
| 2113 | } |
| 2114 | } else if (lang == "CUDA") { |
| 2115 | target->AddCUDAArchitectureFlags(compileOrLink, config, flags); |
| 2116 | target->AddCUDAToolkitFlags(flags); |
| 2117 | } else if (lang == "ISPC") { |
no test coverage detected