|
@@ -448,226 +448,6 @@ cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const
|
|
|
return this->StateSnapshot;
|
|
|
}
|
|
|
|
|
|
-void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
|
|
|
- const std::string& lang,
|
|
|
- cmSourceFile& source,
|
|
|
- cmGeneratorTarget& target)
|
|
|
-{
|
|
|
- std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
|
|
|
- objectDir = this->Convert(objectDir,START_OUTPUT,SHELL);
|
|
|
- std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
|
|
|
- std::string sourceFile =
|
|
|
- this->ConvertToOutputFormat(source.GetFullPath(), SHELL);
|
|
|
- std::string varString = "CMAKE_";
|
|
|
- varString += lang;
|
|
|
- varString += "_COMPILE_OBJECT";
|
|
|
- std::vector<std::string> rules;
|
|
|
- rules.push_back(this->Makefile->GetRequiredDefinition(varString));
|
|
|
- varString = "CMAKE_";
|
|
|
- varString += lang;
|
|
|
- varString += "_FLAGS";
|
|
|
- std::string flags;
|
|
|
- flags += this->Makefile->GetSafeDefinition(varString);
|
|
|
- flags += " ";
|
|
|
- {
|
|
|
- std::vector<std::string> includes;
|
|
|
- this->GetIncludeDirectories(includes, &target, lang);
|
|
|
- flags += this->GetIncludeFlags(includes, &target, lang);
|
|
|
- }
|
|
|
- flags += this->Makefile->GetDefineFlags();
|
|
|
-
|
|
|
- // Construct the command lines.
|
|
|
- cmCustomCommandLines commandLines;
|
|
|
- std::vector<std::string> commands;
|
|
|
- cmSystemTools::ExpandList(rules, commands);
|
|
|
- cmLocalGenerator::RuleVariables vars;
|
|
|
- vars.Language = lang.c_str();
|
|
|
- vars.Source = sourceFile.c_str();
|
|
|
- vars.Object = objectFile.c_str();
|
|
|
- vars.ObjectDir = objectDir.c_str();
|
|
|
- vars.Flags = flags.c_str();
|
|
|
- for(std::vector<std::string>::iterator i = commands.begin();
|
|
|
- i != commands.end(); ++i)
|
|
|
- {
|
|
|
- // Expand the full command line string.
|
|
|
- this->ExpandRuleVariables(*i, vars);
|
|
|
-
|
|
|
- // Parse the string to get the custom command line.
|
|
|
- cmCustomCommandLine commandLine;
|
|
|
- std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str());
|
|
|
- commandLine.insert(commandLine.end(), cmd.begin(), cmd.end());
|
|
|
-
|
|
|
- // Store this command line.
|
|
|
- commandLines.push_back(commandLine);
|
|
|
- }
|
|
|
-
|
|
|
- // Check for extra object-file dependencies.
|
|
|
- std::vector<std::string> depends;
|
|
|
- const char* additionalDeps = source.GetProperty("OBJECT_DEPENDS");
|
|
|
- if(additionalDeps)
|
|
|
- {
|
|
|
- cmSystemTools::ExpandListArgument(additionalDeps, depends);
|
|
|
- }
|
|
|
-
|
|
|
- // Generate a meaningful comment for the command.
|
|
|
- std::string comment = "Building ";
|
|
|
- comment += lang;
|
|
|
- comment += " object ";
|
|
|
- comment += this->Convert(ofname, START_OUTPUT);
|
|
|
-
|
|
|
- // Add the custom command to build the object file.
|
|
|
- this->Makefile->AddCustomCommandToOutput(
|
|
|
- ofname,
|
|
|
- depends,
|
|
|
- source.GetFullPath(),
|
|
|
- commandLines,
|
|
|
- comment.c_str(),
|
|
|
- this->StateSnapshot.GetDirectory().GetCurrentBinary()
|
|
|
- );
|
|
|
-}
|
|
|
-
|
|
|
-void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
|
|
|
- cmGeneratorTarget& target)
|
|
|
-{
|
|
|
- std::string objs;
|
|
|
- std::vector<std::string> objVector;
|
|
|
- std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
|
|
- // Add all the sources outputs to the depends of the target
|
|
|
- std::vector<cmSourceFile*> classes;
|
|
|
- target.GetSourceFiles(classes, config);
|
|
|
- for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
|
|
|
- i != classes.end(); ++i)
|
|
|
- {
|
|
|
- cmSourceFile* sf = *i;
|
|
|
- if(!sf->GetCustomCommand() &&
|
|
|
- !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
|
|
|
- !sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
|
|
|
- {
|
|
|
- std::string dir_max;
|
|
|
- dir_max += this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
|
|
- dir_max += "/";
|
|
|
- std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
|
|
|
- if(!obj.empty())
|
|
|
- {
|
|
|
- std::string ofname =
|
|
|
- this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
|
|
- ofname += "/";
|
|
|
- ofname += obj;
|
|
|
- objVector.push_back(ofname);
|
|
|
- this->AddCustomCommandToCreateObject(ofname.c_str(),
|
|
|
- llang, *(*i), target);
|
|
|
- objs += this->Convert(ofname,START_OUTPUT,SHELL);
|
|
|
- objs += " ";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- std::string createRule = target.GetCreateRuleVariable(llang, config);
|
|
|
- bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE");
|
|
|
- std::string targetName = target.Target->GetFullName();
|
|
|
- // Executable :
|
|
|
- // Shared Library:
|
|
|
- // Static Library:
|
|
|
- // Shared Module:
|
|
|
- std::string linkLibs; // should be set
|
|
|
- std::string frameworkPath;
|
|
|
- std::string linkPath;
|
|
|
- std::string flags; // should be set
|
|
|
- std::string linkFlags; // should be set
|
|
|
- this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
|
|
|
- &target, useWatcomQuote);
|
|
|
- linkLibs = frameworkPath + linkPath + linkLibs;
|
|
|
- cmLocalGenerator::RuleVariables vars;
|
|
|
- vars.Language = llang.c_str();
|
|
|
- vars.Objects = objs.c_str();
|
|
|
- vars.ObjectDir = ".";
|
|
|
- vars.Target = targetName.c_str();
|
|
|
- vars.LinkLibraries = linkLibs.c_str();
|
|
|
- vars.Flags = flags.c_str();
|
|
|
- vars.LinkFlags = linkFlags.c_str();
|
|
|
-
|
|
|
- std::string langFlags;
|
|
|
- this->AddLanguageFlags(langFlags, llang, "");
|
|
|
- this->AddArchitectureFlags(langFlags, &target, llang, "");
|
|
|
- vars.LanguageCompileFlags = langFlags.c_str();
|
|
|
-
|
|
|
- cmCustomCommandLines commandLines;
|
|
|
- std::vector<std::string> rules;
|
|
|
- rules.push_back(this->Makefile->GetRequiredDefinition(createRule));
|
|
|
- std::vector<std::string> commands;
|
|
|
- cmSystemTools::ExpandList(rules, commands);
|
|
|
- for(std::vector<std::string>::iterator i = commands.begin();
|
|
|
- i != commands.end(); ++i)
|
|
|
- {
|
|
|
- // Expand the full command line string.
|
|
|
- this->ExpandRuleVariables(*i, vars);
|
|
|
- // Parse the string to get the custom command line.
|
|
|
- cmCustomCommandLine commandLine;
|
|
|
- std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str());
|
|
|
- commandLine.insert(commandLine.end(), cmd.begin(), cmd.end());
|
|
|
-
|
|
|
- // Store this command line.
|
|
|
- commandLines.push_back(commandLine);
|
|
|
- }
|
|
|
- std::string targetFullPath = target.Target->GetFullPath();
|
|
|
- // Generate a meaningful comment for the command.
|
|
|
- std::string comment = "Linking ";
|
|
|
- comment += llang;
|
|
|
- comment += " target ";
|
|
|
- comment += this->Convert(targetFullPath, START_OUTPUT);
|
|
|
- this->Makefile->AddCustomCommandToOutput(
|
|
|
- targetFullPath,
|
|
|
- objVector,
|
|
|
- "",
|
|
|
- commandLines,
|
|
|
- comment.c_str(),
|
|
|
- this->StateSnapshot.GetDirectory().GetCurrentBinary()
|
|
|
- );
|
|
|
- this->Makefile->GetSource(targetFullPath);
|
|
|
- target.Target->AddSource(targetFullPath);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-void cmLocalGenerator
|
|
|
-::CreateCustomTargetsAndCommands(std::set<std::string> const& lang)
|
|
|
-{
|
|
|
- cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets();
|
|
|
- for(cmGeneratorTargetsType::iterator l = tgts.begin();
|
|
|
- l != tgts.end(); l++)
|
|
|
- {
|
|
|
- if (l->first->IsImported())
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- cmGeneratorTarget& target = *l->second;
|
|
|
- switch(target.GetType())
|
|
|
- {
|
|
|
- case cmTarget::STATIC_LIBRARY:
|
|
|
- case cmTarget::SHARED_LIBRARY:
|
|
|
- case cmTarget::MODULE_LIBRARY:
|
|
|
- case cmTarget::EXECUTABLE:
|
|
|
- {
|
|
|
- std::string llang = target.Target->GetLinkerLanguage();
|
|
|
- if(llang.empty())
|
|
|
- {
|
|
|
- cmSystemTools::Error
|
|
|
- ("CMake can not determine linker language for target: ",
|
|
|
- target.Target->GetName().c_str());
|
|
|
- return;
|
|
|
- }
|
|
|
- // if the language is not in the set lang then create custom
|
|
|
- // commands to build the target
|
|
|
- if(lang.count(llang) == 0)
|
|
|
- {
|
|
|
- this->AddBuildTargetRule(llang, target);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
// List of variables that are replaced when
|
|
|
// rules are expanced. These variables are
|
|
|
// replaced in the form <var> with GetSafeDefinition(var).
|
|
@@ -1919,7 +1699,8 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
|
|
|
}
|
|
|
|
|
|
// Look for a CMake target with the given name.
|
|
|
- if(cmTarget* target = this->Makefile->FindTargetToUse(name))
|
|
|
+ if(cmGeneratorTarget* target =
|
|
|
+ this->Makefile->FindGeneratorTargetToUse(name))
|
|
|
{
|
|
|
// make sure it is not just a coincidence that the target name
|
|
|
// found is part of the inName
|