Browse Source

Xcode: Fix "clean" operation under the "new build system"

Previously we set `SYMROOT` to tell Xcode where to place the build
products.  However, the "clean" operation in the Xcode "new build
system" expects that only Xcode creates the `SYMROOT` directory or
contents inside it.  Since we create that directory, "clean" fails.

We now explicitly set `CONFIGURATION_BUILD_DIR` and `TARGET_TEMP_DIR`
instead of letting Xcode compute their values from `SYMROOT`, so we no
longer need to set the latter.  Drop the now-unnecessary `SYMROOT`.

Fixes: #22550
Brad King 3 years ago
parent
commit
d0a6ebf57b

+ 0 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -2552,7 +2552,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
 
   // Store the product name for all target types.
   buildSettings->AddAttribute("PRODUCT_NAME", this->CreateString(realName));
-  buildSettings->AddAttribute("SYMROOT", this->CreateString(pndir));
 
   // Handle settings for each target type.
   switch (gtgt->GetType()) {

+ 2 - 0
Tests/RunCMake/XcodeProject/Clean.cmake

@@ -0,0 +1,2 @@
+enable_language(C)
+add_subdirectory(Clean)

+ 1 - 0
Tests/RunCMake/XcodeProject/Clean/CMakeLists.txt

@@ -0,0 +1 @@
+add_library(empty empty.c)

+ 0 - 0
Tests/RunCMake/XcodeProject/Clean/empty.c


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

@@ -1,5 +1,13 @@
 include(RunCMake)
 
+function(RunClean)
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Clean-build)
+  run_cmake(Clean)
+  set(RunCMake_TEST_NO_CLEAN 1)
+  run_cmake_command(Clean-build xcodebuild clean)
+endfunction()
+RunClean()
+
 run_cmake(ExplicitCMakeLists)
 run_cmake(ImplicitCMakeLists)
 run_cmake(InterfaceLibSources)