فهرست منبع

Merge topic 'xcode-restore-CMakeLists'

0ce8a5c08d Xcode: Fix generated references to CMakeLists.txt files
9457c95aa0 cmGlobalXCodeGenerator: Mark known source locations

Acked-by: Kitware Robot <[email protected]>
Merge-request: !3999
Brad King 6 سال پیش
والد
کامیت
30908fa0ee

+ 14 - 10
Source/cmGlobalXCodeGenerator.cxx

@@ -779,7 +779,7 @@ public:
           "Xcode does not support per-config per-source " << property << ":\n"
           "  " << expression << "\n"
           "specified for source:\n"
-          "  " << this->SourceFile->GetFullPath() << "\n";
+          "  " << this->SourceFile->ResolveFullPath() << "\n";
       /* clang-format on */
       this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str());
     }
@@ -853,7 +853,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
   lg->AppendFlags(flags, lg->GetIncludeFlags(includes, gtgt, lang, true));
 
   cmXCodeObject* buildFile =
-    this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), gtgt, lang, sf);
+    this->CreateXCodeSourceFileFromPath(sf->ResolveFullPath(), gtgt, lang, sf);
 
   cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
   settings->AddAttributeIfNotEmpty("COMPILER_FLAGS",
@@ -899,7 +899,8 @@ void cmGlobalXCodeGenerator::AddXCodeProjBuildRule(
   std::string listfile =
     cmStrCat(target->GetLocalGenerator()->GetCurrentSourceDirectory(),
              "/CMakeLists.txt");
-  cmSourceFile* srcCMakeLists = target->Makefile->GetOrCreateSource(listfile);
+  cmSourceFile* srcCMakeLists = target->Makefile->GetOrCreateSource(
+    listfile, false, cmSourceFileLocationKind::Known);
   if (!cmContains(sources, srcCMakeLists)) {
     sources.push_back(srcCMakeLists);
   }
@@ -1032,7 +1033,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReference(
 {
   std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
 
-  return this->CreateXCodeFileReferenceFromPath(sf->GetFullPath(), target,
+  return this->CreateXCodeFileReferenceFromPath(sf->ResolveFullPath(), target,
                                                 lang, sf);
 }
 
@@ -1067,7 +1068,7 @@ struct cmSourceFilePathCompare
 {
   bool operator()(cmSourceFile* l, cmSourceFile* r)
   {
-    return l->GetFullPath() < r->GetFullPath();
+    return l->ResolveFullPath() < r->ResolveFullPath();
   }
 };
 
@@ -1142,7 +1143,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget(
   // Add the Info.plist we are about to generate for an App Bundle.
   if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
     std::string plist = this->ComputeInfoPListLocation(gtgt);
-    cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(plist, true);
+    cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
+      plist, true, cmSourceFileLocationKind::Known);
     classes.push_back(sf);
   }
 
@@ -2858,15 +2860,17 @@ bool cmGlobalXCodeGenerator::CreateGroups(
         std::string listfile =
           cmStrCat(gtgt->GetLocalGenerator()->GetCurrentSourceDirectory(),
                    "/CMakeLists.txt");
-        cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(listfile);
-        addSourceToGroup(sf->GetFullPath());
+        cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
+          listfile, false, cmSourceFileLocationKind::Known);
+        addSourceToGroup(sf->ResolveFullPath());
       }
 
       // Add the Info.plist we are about to generate for an App Bundle.
       if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
         std::string plist = this->ComputeInfoPListLocation(gtgt);
-        cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(plist, true);
-        addSourceToGroup(sf->GetFullPath());
+        cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
+          plist, true, cmSourceFileLocationKind::Known);
+        addSourceToGroup(sf->ResolveFullPath());
       }
     }
   }

+ 20 - 0
Tests/RunCMake/XcodeProject/ImplicitCMakeLists-check.cmake

@@ -0,0 +1,20 @@
+set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/ImplicitCMakeLists.xcodeproj/project.pbxproj")
+if(NOT EXISTS "${xcProjectFile}")
+  set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.")
+  return()
+endif()
+
+set(foundCMakeLists 0)
+file(STRINGS "${xcProjectFile}" lines)
+foreach(line IN LISTS lines)
+  if(line MATCHES "PBXFileReference.*CMakeLists.txt")
+    if(foundCMakeLists)
+      set(RunCMake_TEST_FAILED "CMakeLists.txt referenced multiple times")
+      return()
+    endif()
+    set(foundCMakeLists 1)
+  endif()
+endforeach()
+if(NOT foundCMakeLists)
+  set(RunCMake_TEST_FAILED "CMakeLists.txt not referenced")
+endif()

+ 0 - 0
Tests/RunCMake/XcodeProject/ImplicitCMakeLists.cmake


+ 1 - 0
Tests/RunCMake/XcodeProject/RunCMakeTest.cmake

@@ -1,6 +1,7 @@
 include(RunCMake)
 
 run_cmake(ExplicitCMakeLists)
+run_cmake(ImplicitCMakeLists)
 
 run_cmake(XcodeFileType)
 run_cmake(XcodeAttributeLocation)