From 481420ee89992cd8e761ce36808b3dc73ccc16d2 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Wed, 21 Feb 2018 23:42:55 +0100 Subject: Xcode: Generate ZERO_CHECK generator target only once In case CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY has been enabled generate only the root-level ZERO_CHECK target so targets in subdirectories pick up the root generator target of ZERO_CHECK. For the case that CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY is not enabled more investigation and a proper and final fix is still needed. Issue: 14297 --- Source/cmGlobalXCodeGenerator.cxx | 6 +++++- Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 14 ++++++++++++++ .../XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt | 1 + Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake | 4 ++++ Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt | 2 ++ 5 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt create mode 100644 Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake create mode 100644 Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2a38599..d3f5aac 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -459,7 +459,11 @@ void cmGlobalXCodeGenerator::AddExtraTargets( // Add ZERO_CHECK bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION"); - if (regenerate) { + bool generateTopLevelProjectOnly = + mf->IsOn("CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY"); + bool isTopLevel = + !root->GetStateSnapshot().GetBuildsystemDirectoryParent().IsValid(); + if (regenerate && (isTopLevel || !generateTopLevelProjectOnly)) { this->CreateReRunCMakeFile(root, gens); std::string file = this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str()); diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 64a07f0..5eff6b9 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -236,3 +236,17 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) deploymeny_target_test(${SDK}) endforeach() endif() + +function(XcodeDependOnZeroCheck) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeDependOnZeroCheck-build) + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(XcodeDependOnZeroCheck) + run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target parentdirlib) + run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target subdirlib) +endfunction() + +XcodeDependOnZeroCheck() diff --git a/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt new file mode 100644 index 0000000..92c9a29 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt @@ -0,0 +1 @@ +BUILD AGGREGATE TARGET ZERO_CHECK diff --git a/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake new file mode 100644 index 0000000..d759a65 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake @@ -0,0 +1,4 @@ +set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE) +project(XcodeDependOnZeroCheck CXX) +add_subdirectory(zerocheck) +add_library(parentdirlib foo.cpp) diff --git a/Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt b/Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt new file mode 100644 index 0000000..4adde99 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt @@ -0,0 +1,2 @@ +project(subproject) +add_library(subdirlib ../foo.cpp) -- cgit v0.12