mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-04 06:40:24 +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()) {
|
||||
return false;
|
||||
}
|
||||
if (cmHasSuffix(name, ".exe"_s)) {
|
||||
name = cmSystemTools::GetFilenameWithoutLastExtension(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
|
||||
// found is part of the inName
|
||||
if (cmSystemTools::FileIsFullPath(inName)) {
|
||||
|
||||
Reference in New Issue
Block a user