Fix CMake Internal Error from cmTarget::GetOutputInfo - triggered by calling GetLocation on a utility target - caused by custom command output file with same name as custom target. The fix is to avoid calling GetLocation unless the target is of a type that is expected to have a location...
This commit is contained in:
parent
9c626d8f68
commit
f199385605
|
@ -1837,12 +1837,17 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName,
|
||||||
// found is part of the inName
|
// found is part of the inName
|
||||||
if(cmSystemTools::FileIsFullPath(inName))
|
if(cmSystemTools::FileIsFullPath(inName))
|
||||||
{
|
{
|
||||||
std::string tLocation = target->GetLocation(config);
|
std::string tLocation;
|
||||||
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
if(target->GetType() >= cmTarget::EXECUTABLE &&
|
||||||
|
target->GetType() <= cmTarget::MODULE_LIBRARY)
|
||||||
|
{
|
||||||
|
tLocation = target->GetLocation(config);
|
||||||
|
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
||||||
|
tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
|
||||||
|
}
|
||||||
std::string depLocation = cmSystemTools::GetFilenamePath(
|
std::string depLocation = cmSystemTools::GetFilenamePath(
|
||||||
std::string(inName));
|
std::string(inName));
|
||||||
depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
|
depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
|
||||||
tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
|
|
||||||
if(depLocation != tLocation)
|
if(depLocation != tLocation)
|
||||||
{
|
{
|
||||||
// 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
|
||||||
|
|
|
@ -1244,17 +1244,21 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
|
||||||
// the fact that the name matched a target was just a coincidence.
|
// the fact that the name matched a target was just a coincidence.
|
||||||
if(cmSystemTools::FileIsFullPath(dep.c_str()))
|
if(cmSystemTools::FileIsFullPath(dep.c_str()))
|
||||||
{
|
{
|
||||||
// This is really only for compatibility so we do not need to
|
if(t->GetType() >= cmTarget::EXECUTABLE &&
|
||||||
// worry about configuration names and output names.
|
t->GetType() <= cmTarget::MODULE_LIBRARY)
|
||||||
std::string tLocation = t->GetLocation(0);
|
|
||||||
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
|
||||||
std::string depLocation = cmSystemTools::GetFilenamePath(dep);
|
|
||||||
depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
|
|
||||||
tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
|
|
||||||
if(depLocation == tLocation)
|
|
||||||
{
|
{
|
||||||
this->Target->AddUtility(util.c_str());
|
// This is really only for compatibility so we do not need to
|
||||||
return true;
|
// worry about configuration names and output names.
|
||||||
|
std::string tLocation = t->GetLocation(0);
|
||||||
|
tLocation = cmSystemTools::GetFilenamePath(tLocation);
|
||||||
|
std::string depLocation = cmSystemTools::GetFilenamePath(dep);
|
||||||
|
depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
|
||||||
|
tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
|
||||||
|
if(depLocation == tLocation)
|
||||||
|
{
|
||||||
|
this->Target->AddUtility(util.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -386,3 +386,30 @@ ADD_CUSTOM_TARGET(pre_check_command_line
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt
|
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt
|
||||||
)
|
)
|
||||||
ADD_DEPENDENCIES(do_check_command_line pre_check_command_line)
|
ADD_DEPENDENCIES(do_check_command_line pre_check_command_line)
|
||||||
|
|
||||||
|
# <SameNameTest>
|
||||||
|
#
|
||||||
|
# Add a custom target called "SameName" -- then add a custom command in a
|
||||||
|
# different target whose output is a full-path file called "SameName" -- then
|
||||||
|
# add a second custom target that depends on the full-path file ".../SameName"
|
||||||
|
#
|
||||||
|
# At first, this reproduces a bug reported by a customer. After fixing it,
|
||||||
|
# having this test here makes sure it stays fixed moving forward.
|
||||||
|
#
|
||||||
|
ADD_CUSTOM_COMMAND(
|
||||||
|
OUTPUT SameName1.txt
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch SameName1.txt
|
||||||
|
)
|
||||||
|
ADD_CUSTOM_TARGET(SameName ALL
|
||||||
|
DEPENDS SameName1.txt
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_CUSTOM_COMMAND(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName
|
||||||
|
)
|
||||||
|
ADD_CUSTOM_TARGET(DifferentName ALL
|
||||||
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/subdir/SameName
|
||||||
|
)
|
||||||
|
#
|
||||||
|
# </SameNameTest>
|
||||||
|
|
Loading…
Reference in New Issue