소스 검색

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
Brad King 6 년 전
부모
커밋
9da1c33cf1
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      Source/cmFileAPICodemodel.cxx

+ 6 - 0
Source/cmFileAPICodemodel.cxx

@@ -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;
   }