cmGlobalGenerator: Add method to compute "cmake --build" command line
Create a GenerateCMakeBuildCommand method to generate a command-line string invoking "cmake --build" for a given target and configuration. Optionally allow the "-i" make flag and additional native options.
This commit is contained in:
parent
1befbfad3d
commit
05923172f9
|
@ -1707,6 +1707,46 @@ int cmGlobalGenerator::Build(
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
|
||||||
|
const char* target, const char* config, const char* native,
|
||||||
|
bool ignoreErrors)
|
||||||
|
{
|
||||||
|
std::string makeCommand = cmSystemTools::GetCMakeCommand();
|
||||||
|
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
|
||||||
|
makeCommand += " --build .";
|
||||||
|
if(config && *config)
|
||||||
|
{
|
||||||
|
makeCommand += " --config \"";
|
||||||
|
makeCommand += config;
|
||||||
|
makeCommand += "\"";
|
||||||
|
}
|
||||||
|
if(target && *target)
|
||||||
|
{
|
||||||
|
makeCommand += " --target \"";
|
||||||
|
makeCommand += target;
|
||||||
|
makeCommand += "\"";
|
||||||
|
}
|
||||||
|
const char* sep = " -- ";
|
||||||
|
if(ignoreErrors)
|
||||||
|
{
|
||||||
|
const char* iflag = this->GetBuildIgnoreErrorsFlag();
|
||||||
|
if(iflag && *iflag)
|
||||||
|
{
|
||||||
|
makeCommand += sep;
|
||||||
|
makeCommand += iflag;
|
||||||
|
sep = " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(native && *native)
|
||||||
|
{
|
||||||
|
makeCommand += sep;
|
||||||
|
makeCommand += native;
|
||||||
|
}
|
||||||
|
return makeCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg)
|
void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg)
|
||||||
{
|
{
|
||||||
this->LocalGenerators.push_back(lg);
|
this->LocalGenerators.push_back(lg);
|
||||||
|
|
|
@ -134,6 +134,11 @@ public:
|
||||||
const char *targetName, const char* config,
|
const char *targetName, const char* config,
|
||||||
bool ignoreErrors, bool fast);
|
bool ignoreErrors, bool fast);
|
||||||
|
|
||||||
|
/** Generate a "cmake --build" call for a given target and config. */
|
||||||
|
std::string GenerateCMakeBuildCommand(const char* target,
|
||||||
|
const char* config,
|
||||||
|
const char* native,
|
||||||
|
bool ignoreErrors);
|
||||||
|
|
||||||
///! Set the CMake instance
|
///! Set the CMake instance
|
||||||
void SetCMakeInstance(cmake *cm);
|
void SetCMakeInstance(cmake *cm);
|
||||||
|
@ -422,6 +427,8 @@ private:
|
||||||
|
|
||||||
void ClearGeneratorMembers();
|
void ClearGeneratorMembers();
|
||||||
|
|
||||||
|
virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; }
|
||||||
|
|
||||||
// Cache directory content and target files to be built.
|
// Cache directory content and target files to be built.
|
||||||
struct DirectoryContent: public std::set<cmStdString>
|
struct DirectoryContent: public std::set<cmStdString>
|
||||||
{
|
{
|
||||||
|
|
|
@ -188,6 +188,7 @@ protected:
|
||||||
|
|
||||||
cmGeneratedFileStream *CommandDatabase;
|
cmGeneratedFileStream *CommandDatabase;
|
||||||
private:
|
private:
|
||||||
|
virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; }
|
||||||
virtual std::string GetEditCacheCommand() const;
|
virtual std::string GetEditCacheCommand() const;
|
||||||
virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
|
virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue