fileapi: Fix codemodel v2 target file name for CMP0037 OLD behavior

With CMP0037 OLD behavior, executable and library target names may
contain a slash.  Avoid constructing file names with slashes.

Fixes: #19653
This commit is contained in:
Brad King
2019-08-30 10:18:28 -04:00
parent 40bbe50e23
commit 9da1c33cf1

View File

@@ -502,6 +502,12 @@ Json::Value CodemodelConfig::DumpTarget(cmGeneratorTarget* gt,
{
Target t(gt, this->Config);
std::string prefix = "target-" + gt->GetName();
for (char& c : prefix) {
// CMP0037 OLD behavior allows slashes in target names. Remove them.
if (c == '/' || c == '\\') {
c = '_';
}
}
if (!this->Config.empty()) {
prefix += "-" + this->Config;
}