mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-08 16:50:48 +00:00
add_custom_command: Update dependency search heuristics
Search for a target with the `.exe` suffix stripped from its name only if a target by the original name doesn't exist. Fixes: #27612
This commit is contained in:
@@ -2331,12 +2331,21 @@ bool cmLocalGenerator::GetRealDependency(std::string const& inName,
|
|||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (cmHasSuffix(name, ".exe"_s)) {
|
|
||||||
name = cmSystemTools::GetFilenameWithoutLastExtension(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for a CMake target with the given name.
|
// Look for a CMake target with the given name.
|
||||||
if (cmGeneratorTarget* target = this->FindGeneratorTargetToUse(name)) {
|
cmGeneratorTarget* target = this->FindGeneratorTargetToUse(name);
|
||||||
|
if (!target && cmHasSuffix(name, ".exe"_s)) {
|
||||||
|
// If it doesn't exist, try to strip the `.exe` suffix.
|
||||||
|
std::string strippedName =
|
||||||
|
cmSystemTools::GetFilenameWithoutLastExtension(name);
|
||||||
|
if (cmGeneratorTarget* strippedTarget =
|
||||||
|
this->FindGeneratorTargetToUse(strippedName)) {
|
||||||
|
name = strippedName;
|
||||||
|
target = strippedTarget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target) {
|
||||||
// make sure it is not just a coincidence that the target name
|
// make sure it is not just a coincidence that the target name
|
||||||
// found is part of the inName
|
// found is part of the inName
|
||||||
if (cmSystemTools::FileIsFullPath(inName)) {
|
if (cmSystemTools::FileIsFullPath(inName)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user