diff options
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 106 |
1 files changed, 66 insertions, 40 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index a3e5553..f5f3727 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -34,7 +34,6 @@ #include "cmMessageType.h" #include "cmOutputConverter.h" #include "cmPolicies.h" -#include "cmProperty.h" #include "cmRange.h" #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" @@ -45,6 +44,7 @@ #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cmValue.h" #include "cmake.h" cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) @@ -57,11 +57,13 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) this->LocalGenerator->GetGlobalGenerator()); cmake* cm = this->GlobalGenerator->GetCMakeInstance(); this->NoRuleMessages = false; - if (cmProp ruleStatus = cm->GetState()->GetGlobalProperty("RULE_MESSAGES")) { + if (cmValue ruleStatus = + cm->GetState()->GetGlobalProperty("RULE_MESSAGES")) { this->NoRuleMessages = cmIsOff(*ruleStatus); } switch (this->GeneratorTarget->GetPolicyStatusCMP0113()) { case cmPolicies::WARN: + CM_FALLTHROUGH; case cmPolicies::OLD: this->CMP0113New = false; break; @@ -200,14 +202,14 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() }; // Look for additional files registered for cleaning in this directory. - if (cmProp prop_value = + if (cmValue prop_value = this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) { std::vector<std::string> const files = evaluatedFiles(*prop_value); this->CleanFiles.insert(files.begin(), files.end()); } // Look for additional files registered for cleaning in this target. - if (cmProp prop_value = + if (cmValue prop_value = this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { std::vector<std::string> const files = evaluatedFiles(*prop_value); // For relative path support @@ -287,14 +289,13 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->GeneratorTarget->GetExtraSources(extraSources, this->GetConfigName()); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator.get(), this->GetConfigName()); - cmProp pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); + cmValue pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); std::vector<cmSourceFile const*> externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects, this->GetConfigName()); for (cmSourceFile const* sf : externalObjects) { auto const& objectFileName = sf->GetFullPath(); - if (!cmSystemTools::StringEndsWith(objectFileName, - cmToCStr(pchExtension))) { + if (!cmHasSuffix(objectFileName, pchExtension)) { this->ExternalObjects.push_back(objectFileName); } } @@ -669,12 +670,12 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( cmSystemTools::GetFilenameWithoutLastExtension(objectName); ispcSource = cmSystemTools::GetFilenameWithoutLastExtension(ispcSource); - cmProp ispcSuffixProp = + cmValue ispcSuffixProp = this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX"); assert(ispcSuffixProp); std::string directory = this->GeneratorTarget->GetObjectDirectory(config); - if (cmProp prop = + if (cmValue prop = this->GeneratorTarget->GetProperty("ISPC_HEADER_DIRECTORY")) { directory = cmStrCat(this->LocalGenerator->GetBinaryDirectory(), '/', *prop); @@ -686,7 +687,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Add flags from source file properties. const std::string COMPILE_FLAGS("COMPILE_FLAGS"); - if (cmProp cflags = source.GetProperty(COMPILE_FLAGS)) { + if (cmValue cflags = source.GetProperty(COMPILE_FLAGS)) { const std::string& evaluatedFlags = genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS); this->LocalGenerator->AppendFlags(flags, evaluatedFlags); @@ -696,7 +697,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); - if (cmProp coptions = source.GetProperty(COMPILE_OPTIONS)) { + if (cmValue coptions = source.GetProperty(COMPILE_OPTIONS)) { const std::string& evaluatedOptions = genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS); this->LocalGenerator->AppendCompileOptions(flags, evaluatedOptions); @@ -730,7 +731,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( std::vector<std::string> includes; const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); - if (cmProp cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) { + if (cmValue cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) { const std::string& evaluatedIncludes = genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES); this->LocalGenerator->AppendIncludeDirectories(includes, evaluatedIncludes, @@ -746,7 +747,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Add source-specific preprocessor definitions. const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); - if (cmProp compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) { + if (cmValue compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) { const std::string& evaluatedDefs = genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS); this->LocalGenerator->AppendDefines(defines, evaluatedDefs); @@ -755,7 +756,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( << "\n"; } std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper); - if (cmProp config_compile_defs = source.GetProperty(defPropName)) { + if (cmValue config_compile_defs = source.GetProperty(defPropName)) { const std::string& evaluatedDefs = genexInterpreter.Evaluate(*config_compile_defs, COMPILE_DEFINITIONS); this->LocalGenerator->AppendDefines(defines, evaluatedDefs); @@ -887,7 +888,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( bool lang_has_preprocessor = ((lang == "C") || (lang == "CXX") || (lang == "OBJC") || (lang == "OBJCXX") || (lang == "Fortran") || (lang == "CUDA") || - lang == "ISPC" || lang == "ASM"); + lang == "ISPC" || lang == "HIP" || lang == "ASM"); bool const lang_has_assembly = lang_has_preprocessor; bool const lang_can_export_cmds = lang_has_preprocessor; @@ -945,11 +946,11 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( this->GetIncludes(lang, this->GetConfigName())); } - cmProp eliminate[] = { + cmValue eliminate[] = { this->Makefile->GetDefinition("CMAKE_START_TEMP_FILE"), this->Makefile->GetDefinition("CMAKE_END_TEMP_FILE") }; - for (cmProp el : eliminate) { + for (cmValue el : eliminate) { if (el) { cmSystemTools::ReplaceString(compileCommand, *el, ""); } @@ -966,7 +967,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( lang == "HIP" || lang == "ISPC" || lang == "OBJC" || lang == "OBJCXX")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; - cmProp clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); + cmValue clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); if (cmNonempty(clauncher)) { compilerLauncher = *clauncher; } @@ -976,10 +977,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( if (!compileCommands.empty() && (lang == "C" || lang == "CXX" || lang == "OBJC" || lang == "OBJCXX")) { std::string const tidy_prop = lang + "_CLANG_TIDY"; - cmProp tidy = this->GeneratorTarget->GetProperty(tidy_prop); - cmProp iwyu = nullptr; - cmProp cpplint = nullptr; - cmProp cppcheck = nullptr; + cmValue tidy = this->GeneratorTarget->GetProperty(tidy_prop); + cmValue iwyu = nullptr; + cmValue cpplint = nullptr; + cmValue cppcheck = nullptr; if (lang == "C" || lang == "CXX") { std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE"; iwyu = this->GeneratorTarget->GetProperty(iwyu_prop); @@ -1000,12 +1001,30 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( } if (cmNonempty(iwyu)) { run_iwyu += " --iwyu="; - run_iwyu += this->LocalGenerator->EscapeForShell(*iwyu); + + // Only add --driver-mode if it is not already specified, as adding + // it unconditionally might override a user-specified driver-mode + if (iwyu.Get()->find("--driver-mode=") == std::string::npos) { + cmValue p = this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, "_INCLUDE_WHAT_YOU_USE_DRIVER_MODE")); + std::string driverMode; + + if (cmNonempty(p)) { + driverMode = *p; + } else { + driverMode = lang == "C" ? "gcc" : "g++"; + } + + run_iwyu += this->LocalGenerator->EscapeForShell( + cmStrCat(*iwyu, ";--driver-mode=", driverMode)); + } else { + run_iwyu += this->LocalGenerator->EscapeForShell(*iwyu); + } } if (cmNonempty(tidy)) { run_iwyu += " --tidy="; - cmProp p = this->Makefile->GetDefinition("CMAKE_" + lang + - "_CLANG_TIDY_DRIVER_MODE"); + cmValue p = this->Makefile->GetDefinition("CMAKE_" + lang + + "_CLANG_TIDY_DRIVER_MODE"); std::string driverMode; if (cmNonempty(p)) { driverMode = *p; @@ -1049,7 +1068,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( std::string launcher; { - cmProp val = this->LocalGenerator->GetRuleLauncher( + cmValue val = this->LocalGenerator->GetRuleLauncher( this->GeneratorTarget, "RULE_LAUNCH_COMPILE"); if (cmNonempty(val)) { launcher = cmStrCat(*val, ' '); @@ -1119,7 +1138,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // Check for extra outputs created by the compilation. std::vector<std::string> outputs(1, relativeObj); - if (cmProp extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { + if (cmValue extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { std::string evaluated_outputs = cmGeneratorExpression::Evaluate( *extra_outputs_str, this->LocalGenerator, config); @@ -1174,7 +1193,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( std::string preprocessRuleVar = cmStrCat("CMAKE_", lang, "_CREATE_PREPROCESSED_SOURCE"); - if (cmProp preprocessRule = + if (cmValue preprocessRule = this->Makefile->GetDefinition(preprocessRuleVar)) { std::vector<std::string> preprocessCommands = cmExpandedList(*preprocessRule); @@ -1219,7 +1238,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( std::string assemblyRuleVar = cmStrCat("CMAKE_", lang, "_CREATE_ASSEMBLY_SOURCE"); - if (cmProp assemblyRule = + if (cmValue assemblyRule = this->Makefile->GetDefinition(assemblyRuleVar)) { std::vector<std::string> assemblyCommands = cmExpandedList(*assemblyRule); @@ -1398,6 +1417,13 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << "set(CMAKE_Fortran_TARGET_MODULE_DIR \"" << this->GeneratorTarget->GetFortranModuleDirectory(working_dir) << "\")\n"; + + if (this->GeneratorTarget->IsFortranBuildingInstrinsicModules()) { + *this->InfoFileStream + << "\n" + << "# Fortran compiler is building intrinsic modules.\n" + << "set(CMAKE_Fortran_TARGET_BUILDING_INSTRINSIC_MODULES ON) \n"; + } /* clang-format on */ // and now write the rule to use it @@ -1483,7 +1509,7 @@ void cmMakefileTargetGenerator::WriteObjectDependRules( // Create the list of dependencies known at cmake time. These are // shared between the object file and dependency scanning rule. depends.push_back(source.GetFullPath()); - if (cmProp objectDeps = source.GetProperty("OBJECT_DEPENDS")) { + if (cmValue objectDeps = source.GetProperty("OBJECT_DEPENDS")) { cmExpandList(*objectDeps, depends); } } @@ -1722,10 +1748,10 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( std::string object; const auto& lineContinue = this->GlobalGenerator->LineContinueDirective; - cmProp pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); + cmValue pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); for (std::string const& obj : this->Objects) { - if (cmSystemTools::StringEndsWith(obj, cmToCStr(pchExtension))) { + if (cmHasSuffix(obj, pchExtension)) { continue; } *this->BuildFileStream << " " << lineContinue; @@ -1809,13 +1835,13 @@ private: void cmMakefileTargetGenerator::WriteObjectsStrings( std::vector<std::string>& objStrings, std::string::size_type limit) { - cmProp pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); + cmValue pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); cmMakefileTargetGeneratorObjectStrings helper( objStrings, this->LocalGenerator, this->LocalGenerator->GetStateSnapshot().GetDirectory(), limit); for (std::string const& obj : this->Objects) { - if (cmSystemTools::StringEndsWith(obj, cmToCStr(pchExtension))) { + if (cmHasSuffix(obj, pchExtension)) { continue; } helper.Feed(obj); @@ -1944,7 +1970,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( cmStrCat("CMAKE_", this->GeneratorTarget->GetLinkerLanguage(this->GetConfigName()), "_GNUtoMS_RULE"); - if (cmProp rule = this->Makefile->GetDefinition(ruleVar)) { + if (cmValue rule = this->Makefile->GetDefinition(ruleVar)) { linkRule += *rule; } } @@ -1993,7 +2019,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( // Check for an explicit setting one way or the other. std::string const responseVar = "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_OBJECTS"; - if (cmProp val = this->Makefile->GetDefinition(responseVar)) { + if (cmValue val = this->Makefile->GetDefinition(responseVar)) { if (!val->empty()) { return cmIsOn(val); } @@ -2032,7 +2058,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries( // Check for an explicit setting one way or the other. std::string const responseVar = "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES"; - if (cmProp val = this->Makefile->GetDefinition(responseVar)) { + if (cmValue val = this->Makefile->GetDefinition(responseVar)) { if (!val->empty()) { return cmIsOn(val); } @@ -2096,7 +2122,7 @@ void cmMakefileTargetGenerator::CreateLinkLibs( this->GeneratorTarget->GetLinkerLanguage(this->GetConfigName()), "_RESPONSE_FILE_LINK_FLAG"); std::string responseFlag; - if (cmProp p = this->Makefile->GetDefinition(responseFlagVar)) { + if (cmValue p = this->Makefile->GetDefinition(responseFlagVar)) { responseFlag = *p; } else { responseFlag = "@"; @@ -2136,7 +2162,7 @@ void cmMakefileTargetGenerator::CreateObjectLists( this->GeneratorTarget->GetLinkerLanguage(this->GetConfigName()), "_RESPONSE_FILE_LINK_FLAG"); std::string responseFlag; - if (cmProp p = this->Makefile->GetDefinition(responseFlagVar)) { + if (cmValue p = this->Makefile->GetDefinition(responseFlagVar)) { responseFlag = *p; } else { responseFlag = "@"; @@ -2231,7 +2257,7 @@ void cmMakefileTargetGenerator::GenDefFile( cmd += this->LocalGenerator->ConvertToOutputFormat( this->LocalGenerator->MaybeRelativeToCurBinDir(objlist_file), cmOutputConverter::SHELL); - cmProp nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); + cmValue nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); if (cmNonempty(nm_executable)) { cmd += " --nm="; cmd += this->LocalCommonGenerator->ConvertToOutputFormat( |