Xcode: Add option to generate only topmost project file

Closes #16780
This commit is contained in:
Gregor Jasny
2017-10-19 22:48:13 +02:00
parent 41d796be15
commit e4e9ce7cbe
8 changed files with 37 additions and 0 deletions

View File

@@ -188,6 +188,7 @@ Variables that Change Behavior
/variable/CMAKE_USER_MAKE_RULES_OVERRIDE
/variable/CMAKE_WARN_DEPRECATED
/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
/variable/CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY
Variables that Describe the System
==================================

View File

@@ -0,0 +1,8 @@
write-single-xcodeproj
----------------------
* The :generator:`Xcode` generator behavior of generating one project
file per :command:`project()` command could now be controlled with the
:variable:`CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY` variable.
This could be useful to speed up the CMake generation step for
large projects and to work-around a bug in the ``ZERO_CHECK`` logic.

View File

@@ -0,0 +1,9 @@
CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY
-------------------------------------------
If enabled, the :generator:`Xcode` generator will generate only a
single Xcode project file for the topmost :command:`project()` command
instead of generating one for every ``project()`` command.
This could be useful to speed up the CMake generation step for
large projects and to work-around a bug in the ``ZERO_CHECK`` logic.

View File

@@ -388,6 +388,17 @@ void cmGlobalXCodeGenerator::Generate()
std::map<std::string, std::vector<cmLocalGenerator*>>::iterator it;
for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
cmLocalGenerator* root = it->second[0];
bool generateTopLevelProjectOnly =
root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY");
if (generateTopLevelProjectOnly) {
cmStateSnapshot snp = root->GetStateSnapshot();
if (snp.GetBuildsystemDirectoryParent().IsValid()) {
continue;
}
}
this->SetGenerationRoot(root);
// now create the project
this->OutputXCodeProject(root, it->second);

View File

@@ -8,6 +8,7 @@ run_cmake(XcodeFileType)
run_cmake(XcodeAttributeLocation)
run_cmake(XcodeAttributeGenex)
run_cmake(XcodeAttributeGenexError)
run_cmake(XcodeGenerateTopLevelProjectOnly)
run_cmake(XcodeObjectNeedsEscape)
run_cmake(XcodeObjectNeedsQuote)
run_cmake(XcodeOptimizationFlags)

View File

@@ -0,0 +1,3 @@
if(EXISTS "${RunCMake_TEST_BINARY_DIR}/subproject/subproject.xcodeproj")
message(SEND_ERROR "Unexpected project file for subproject found.")
endif()

View File

@@ -0,0 +1,3 @@
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE)
project(XcodeGenerateTopLevelProjectOnly NONE)
add_subdirectory(subproject)

View File

@@ -0,0 +1 @@
project(subproject)