summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-02-16 16:53:52 -0500
committerBrad King <brad.king@kitware.com>2023-02-17 18:02:45 -0500
commit841272eb35cbc76e18609d1b447aaabf1ffd6cda (patch)
tree6d6ef273b5e04a44eb8838fb0cec2621b84eb2e1
parent2a758e34ea7fc28d085460b575a5640a6e18232d (diff)
downloadcmake-841272eb35cbc76e18609d1b447aaabf1ffd6cda.tar.gz
Xcode: Restore suppression of header maps
In commit 8527f42b96 (Xcode: Explicitly disable deprecated user include path feature, 2023-01-31, v3.26.0-rc1~7^2) we dropped the Xcode build setting `USE_HEADERMAP = NO` because Xcode 14's "Build Documentation" feature (`xcodebuild RUN_DOCUMENTATION_COMPILER=YES`) fails in some cases without header maps. However, enabling header maps causes Xcode to add `-iquote .../foo.hmap` and `-I .../bar.hmap` flags that can change the intended header file search order based on the contents of the header maps. This can break existing projects. Restore the `USE_HEADERMAP = NO` setting to fix the header file search order. Further investigation will be needed to resolve the problematic cases with the Xcode 14 "Build Documentation" feature. Meanwhile projects encountering such cases can set the `XCODE_ATTRIBUTE_USE_HEADERMAP` target property to `YES` themselves. Fixes: #24418 Issue: #24379
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx1
-rw-r--r--Tests/CMakeCommands/target_include_directories/CMakeLists.txt5
-rw-r--r--Tests/CMakeCommands/target_include_directories/same.c7
-rw-r--r--Tests/CMakeCommands/target_include_directories/same_one/same.h1
-rw-r--r--Tests/CMakeCommands/target_include_directories/same_two/same.h1
5 files changed, 15 insertions, 0 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index f91879e878..4746507bae 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2977,6 +2977,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
buildSettings->AddAttribute("SECTORDER_FLAGS", this->CreateString(""));
buildSettings->AddAttribute("ALWAYS_SEARCH_USER_PATHS",
this->CreateString("NO"));
+ buildSettings->AddAttribute("USE_HEADERMAP", this->CreateString("NO"));
cmXCodeObject* group = this->CreateObject(cmXCodeObject::OBJECT_LIST);
group->AddObject(this->CreateString("$(inherited)"));
buildSettings->AddAttribute("WARNING_CFLAGS", group);
diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
index 0702ab5b25..3de9ef7e00 100644
--- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
@@ -83,3 +83,8 @@ get_target_property(_res imp INCLUDE_DIRECTORIES)
if (_res)
message(SEND_ERROR "include_directories populated the INCLUDE_DIRECTORIES target property")
endif()
+
+# Test selecting lexicographically-later header of same name via include order.
+# Xcode 'USE_HEADERMAP = YES' breaks this.
+add_library(same STATIC same.c same_one/same.h same_two/same.h)
+target_include_directories(same PRIVATE same_two)
diff --git a/Tests/CMakeCommands/target_include_directories/same.c b/Tests/CMakeCommands/target_include_directories/same.c
new file mode 100644
index 0000000000..8fb8d29830
--- /dev/null
+++ b/Tests/CMakeCommands/target_include_directories/same.c
@@ -0,0 +1,7 @@
+#include "same.h"
+#ifndef CORRECT_SAME_H_INCLUDED
+# error "Correct \"same.h\" not included!"
+#endif
+void same(void)
+{
+}
diff --git a/Tests/CMakeCommands/target_include_directories/same_one/same.h b/Tests/CMakeCommands/target_include_directories/same_one/same.h
new file mode 100644
index 0000000000..e71fe0190b
--- /dev/null
+++ b/Tests/CMakeCommands/target_include_directories/same_one/same.h
@@ -0,0 +1 @@
+#error "Wrong \"same.h\" included!"
diff --git a/Tests/CMakeCommands/target_include_directories/same_two/same.h b/Tests/CMakeCommands/target_include_directories/same_two/same.h
new file mode 100644
index 0000000000..91ac63cbc3
--- /dev/null
+++ b/Tests/CMakeCommands/target_include_directories/same_two/same.h
@@ -0,0 +1 @@
+#define CORRECT_SAME_H_INCLUDED