Merge topic 'custom-command-depend'
ced1d5e Skip file-level dependencies on custom targets (#11332) e30a775 Improve signature of cmLocalGenerator::GetRealDependency
This commit is contained in:
commit
f7036a1603
@ -1334,11 +1334,13 @@ void cmGlobalXCodeGenerator
|
|||||||
cc.GetDepends().begin();
|
cc.GetDepends().begin();
|
||||||
d != cc.GetDepends().end(); ++d)
|
d != cc.GetDepends().end(); ++d)
|
||||||
{
|
{
|
||||||
std::string dep =
|
std::string dep;
|
||||||
this->CurrentLocalGenerator->GetRealDependency(d->c_str(),
|
if(this->CurrentLocalGenerator
|
||||||
configName);
|
->GetRealDependency(d->c_str(), configName, dep))
|
||||||
makefileStream << "\\\n" << this
|
{
|
||||||
->ConvertToRelativeForMake(dep.c_str());
|
makefileStream << "\\\n" <<
|
||||||
|
this->ConvertToRelativeForMake(dep.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
makefileStream << "\n";
|
makefileStream << "\n";
|
||||||
|
|
||||||
|
@ -1818,8 +1818,9 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmLocalGenerator::GetRealDependency(const char* inName,
|
bool cmLocalGenerator::GetRealDependency(const char* inName,
|
||||||
const char* config)
|
const char* config,
|
||||||
|
std::string& dep)
|
||||||
{
|
{
|
||||||
// Older CMake code may specify the dependency using the target
|
// Older CMake code may specify the dependency using the target
|
||||||
// output file rather than the target name. Such code would have
|
// output file rather than the target name. Such code would have
|
||||||
@ -1855,7 +1856,8 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName,
|
|||||||
// it is a full path to a depend that has the same name
|
// it is a full path to a depend that has the same name
|
||||||
// as a target but is in a different location so do not use
|
// as a target but is in a different location so do not use
|
||||||
// the target as the depend
|
// the target as the depend
|
||||||
return inName;
|
dep = inName;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (target->GetType())
|
switch (target->GetType())
|
||||||
@ -1869,15 +1871,16 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName,
|
|||||||
// Get the location of the target's output file and depend on it.
|
// Get the location of the target's output file and depend on it.
|
||||||
if(const char* location = target->GetLocation(config))
|
if(const char* location = target->GetLocation(config))
|
||||||
{
|
{
|
||||||
return location;
|
dep = location;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cmTarget::UTILITY:
|
case cmTarget::UTILITY:
|
||||||
case cmTarget::GLOBAL_TARGET:
|
case cmTarget::GLOBAL_TARGET:
|
||||||
// Depending on a utility target may not work but just trust
|
// A utility target has no file on which to depend. This was listed
|
||||||
// the user to have given a valid name.
|
// only to get the target-level dependency.
|
||||||
return inName;
|
return false;
|
||||||
case cmTarget::INSTALL_FILES:
|
case cmTarget::INSTALL_FILES:
|
||||||
case cmTarget::INSTALL_PROGRAMS:
|
case cmTarget::INSTALL_PROGRAMS:
|
||||||
case cmTarget::INSTALL_DIRECTORY:
|
case cmTarget::INSTALL_DIRECTORY:
|
||||||
@ -1889,23 +1892,24 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName,
|
|||||||
if(cmSystemTools::FileIsFullPath(inName))
|
if(cmSystemTools::FileIsFullPath(inName))
|
||||||
{
|
{
|
||||||
// This is a full path. Return it as given.
|
// This is a full path. Return it as given.
|
||||||
return inName;
|
dep = inName;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for a source file in this directory that matches the
|
// Check for a source file in this directory that matches the
|
||||||
// dependency.
|
// dependency.
|
||||||
if(cmSourceFile* sf = this->Makefile->GetSource(inName))
|
if(cmSourceFile* sf = this->Makefile->GetSource(inName))
|
||||||
{
|
{
|
||||||
name = sf->GetFullPath();
|
dep = sf->GetFullPath();
|
||||||
return name;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Treat the name as relative to the source directory in which it
|
// Treat the name as relative to the source directory in which it
|
||||||
// was given.
|
// was given.
|
||||||
name = this->Makefile->GetCurrentDirectory();
|
dep = this->Makefile->GetCurrentDirectory();
|
||||||
name += "/";
|
dep += "/";
|
||||||
name += inName;
|
dep += inName;
|
||||||
return name;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -158,14 +158,16 @@ public:
|
|||||||
|
|
||||||
/** Translate a dependency as given in CMake code to the name to
|
/** Translate a dependency as given in CMake code to the name to
|
||||||
appear in a generated build file. If the given name is that of
|
appear in a generated build file. If the given name is that of
|
||||||
|
a utility target, returns false. If the given name is that of
|
||||||
a CMake target it will be transformed to the real output
|
a CMake target it will be transformed to the real output
|
||||||
location of that target for the given configuration. If the
|
location of that target for the given configuration. If the
|
||||||
given name is the full path to a file it will be returned.
|
given name is the full path to a file it will be returned.
|
||||||
Otherwise the name is treated as a relative path with respect to
|
Otherwise the name is treated as a relative path with respect to
|
||||||
the source directory of this generator. This should only be
|
the source directory of this generator. This should only be
|
||||||
used for dependencies of custom commands. */
|
used for dependencies of custom commands. */
|
||||||
std::string GetRealDependency(const char* name, const char* config);
|
bool GetRealDependency(const char* name, const char* config,
|
||||||
|
std::string& dep);
|
||||||
|
|
||||||
/** Translate a command as given in CMake code to the location of the
|
/** Translate a command as given in CMake code to the location of the
|
||||||
executable if the command is the name of a CMake executable target.
|
executable if the command is the name of a CMake executable target.
|
||||||
If that's not the case, just return the original name. */
|
If that's not the case, just return the original name. */
|
||||||
|
@ -902,9 +902,12 @@ cmLocalUnixMakefileGenerator3
|
|||||||
d != cc.GetDepends().end(); ++d)
|
d != cc.GetDepends().end(); ++d)
|
||||||
{
|
{
|
||||||
// Lookup the real name of the dependency in case it is a CMake target.
|
// Lookup the real name of the dependency in case it is a CMake target.
|
||||||
std::string dep = this->GetRealDependency
|
std::string dep;
|
||||||
(d->c_str(), this->ConfigurationName.c_str());
|
if(this->GetRealDependency(d->c_str(), this->ConfigurationName.c_str(),
|
||||||
depends.push_back(dep);
|
dep))
|
||||||
|
{
|
||||||
|
depends.push_back(dep);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,10 +686,12 @@ cmLocalVisualStudio6Generator
|
|||||||
++d)
|
++d)
|
||||||
{
|
{
|
||||||
// Lookup the real name of the dependency in case it is a CMake target.
|
// Lookup the real name of the dependency in case it is a CMake target.
|
||||||
std::string dep = this->GetRealDependency(d->c_str(),
|
std::string dep;
|
||||||
config.c_str());
|
if(this->GetRealDependency(d->c_str(), config.c_str(), dep))
|
||||||
fout << "\\\n\t" <<
|
{
|
||||||
this->ConvertToOptionallyRelativeOutputPath(dep.c_str());
|
fout << "\\\n\t" <<
|
||||||
|
this->ConvertToOptionallyRelativeOutputPath(dep.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fout << "\n";
|
fout << "\n";
|
||||||
|
|
||||||
|
@ -1624,9 +1624,12 @@ WriteCustomRule(std::ostream& fout,
|
|||||||
++d)
|
++d)
|
||||||
{
|
{
|
||||||
// Get the real name of the dependency in case it is a CMake target.
|
// Get the real name of the dependency in case it is a CMake target.
|
||||||
std::string dep = this->GetRealDependency(d->c_str(), i->c_str());
|
std::string dep;
|
||||||
fout << this->ConvertToXMLOutputPath(dep.c_str())
|
if(this->GetRealDependency(d->c_str(), i->c_str(), dep))
|
||||||
<< ";";
|
{
|
||||||
|
fout << this->ConvertToXMLOutputPath(dep.c_str())
|
||||||
|
<< ";";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fout << "\"\n";
|
fout << "\"\n";
|
||||||
|
@ -395,10 +395,12 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
|
|||||||
d != command.GetDepends().end();
|
d != command.GetDepends().end();
|
||||||
++d)
|
++d)
|
||||||
{
|
{
|
||||||
std::string dep = this->LocalGenerator->
|
std::string dep;
|
||||||
GetRealDependency(d->c_str(), i->c_str());
|
if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep))
|
||||||
this->ConvertToWindowsSlash(dep);
|
{
|
||||||
(*this->BuildFileStream ) << ";" << dep;
|
this->ConvertToWindowsSlash(dep);
|
||||||
|
(*this->BuildFileStream ) << ";" << dep;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
(*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
|
(*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
|
||||||
this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
|
this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
|
||||||
|
@ -130,6 +130,7 @@ ADD_CUSTOM_COMMAND(
|
|||||||
################################################################
|
################################################################
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/foo.pre
|
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/foo.pre
|
||||||
DEPENDS ${PROJECT_SOURCE_DIR}/foo.in
|
DEPENDS ${PROJECT_SOURCE_DIR}/foo.in
|
||||||
|
TDocument # Ensure doc1.h generates before this target
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
ARGS -E copy ${PROJECT_SOURCE_DIR}/foo.in
|
ARGS -E copy ${PROJECT_SOURCE_DIR}/foo.in
|
||||||
${PROJECT_BINARY_DIR}/foo.pre
|
${PROJECT_BINARY_DIR}/foo.pre
|
||||||
@ -181,10 +182,6 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/generated.c
|
|||||||
|
|
||||||
TARGET_LINK_LIBRARIES(CustomCommand GeneratedHeader)
|
TARGET_LINK_LIBRARIES(CustomCommand GeneratedHeader)
|
||||||
|
|
||||||
# must add a dependency on TDocument otherwise it might never build and
|
|
||||||
# the CustomCommand executable really needs doc1.h
|
|
||||||
ADD_DEPENDENCIES(CustomCommand TDocument)
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Test for using just the target name as executable in the COMMAND
|
# Test for using just the target name as executable in the COMMAND
|
||||||
# section. Has to be recognized and replaced by CMake with the output
|
# section. Has to be recognized and replaced by CMake with the output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user