Merge topic 'xcode-top-level-only-with-object-library'

64304fe72b Xcode: Fix post build script for 'top level project only' opt

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4284
This commit is contained in:
Brad King 2020-01-28 16:04:45 +00:00 committed by Kitware Robot
commit 7706b6a714
5 changed files with 29 additions and 2 deletions

View File

@ -528,7 +528,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY");
bool isTopLevel =
!root->GetStateSnapshot().GetBuildsystemDirectoryParent().IsValid();
if (regenerate && (isTopLevel || !generateTopLevelProjectOnly)) {
bool isGenerateProject = isTopLevel || !generateTopLevelProjectOnly;
if (regenerate && isGenerateProject) {
this->CreateReRunCMakeFile(root, gens);
std::string file =
this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile);
@ -558,7 +559,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// run the depend check makefile as a post build rule
// this will make sure that when the next target is built
// things are up-to-date
if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
if (isGenerateProject &&
target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
commandLines.front().back() = // fill placeholder
this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
gen->AddCustomCommandToTarget(

View File

@ -8,6 +8,16 @@ run_cmake(XcodeAttributeLocation)
run_cmake(XcodeAttributeGenex)
run_cmake(XcodeAttributeGenexError)
run_cmake(XcodeGenerateTopLevelProjectOnly)
function(XcodeGenerateTopLevelProjectOnlyWithObjectLibrary)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeGenerateTopLevelProjectOnlyWithObjectLibrary-build)
run_cmake(XcodeGenerateTopLevelProjectOnlyWithObjectLibrary)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(XcodeGenerateTopLevelProjectOnlyWithObjectLibrary-build ${CMAKE_COMMAND} --build . --target shared_lib)
endfunction()
XcodeGenerateTopLevelProjectOnlyWithObjectLibrary()
run_cmake(XcodeObjectNeedsEscape)
run_cmake(XcodeObjectNeedsQuote)
run_cmake(XcodeOptimizationFlags)

View File

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

View File

@ -0,0 +1,7 @@
project(subproject_with_object_lib)
add_library(object_lib_dependency OBJECT dummy.cpp)
add_library(shared_lib SHARED dummy.cpp)
target_sources(shared_lib PRIVATE $<TARGET_OBJECTS:object_lib_dependency>)
set_target_properties(shared_lib PROPERTIES MACOSX_RPATH ON)

View File

@ -0,0 +1,5 @@
namespace {
void dummy()
{
}
}