NMake: Fix problem with empty DEPENDS args (#13392)

add_custom_command can have empty DEPENDS arguments, which
was triggering invalid makefile generation for the NMake
Makefiles generator. We were mistakenly emitting the build
directory appended with "/" plus the empty string... which
was then translated to a string ending in \" in build.make...
which nmake choked on.

The solution is not to emit any dependency when the input
DEPENDS is the empty string. Return early from GetRealDependency
in this empty input case.
This commit is contained in:
David Cole 2012-11-21 11:23:14 -05:00
parent 078e35defb
commit 7ae7d66503
1 changed files with 8 additions and 0 deletions

View File

@ -1875,6 +1875,14 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
// modify the name so stripping down to just the file name should
// produce the target name in this case.
std::string name = cmSystemTools::GetFilenameName(inName);
// If the input name is the empty string, there is no real
// dependency. Short-circuit the other checks:
if(name == "")
{
return false;
}
if(cmSystemTools::GetFilenameLastExtension(name) == ".exe")
{
name = cmSystemTools::GetFilenameWithoutLastExtension(name);