Xcode: Add targets marked as EXCLUDE_FROM_ALL to project (#16101)

This commit is contained in:
Gregor Jasny 2016-08-19 21:50:48 +02:00 committed by Brad King
parent ff88df48e8
commit df32e564ae
9 changed files with 41 additions and 11 deletions

View File

@ -2635,13 +2635,10 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
}
bool cmGlobalXCodeGenerator::CreateGroups(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
std::vector<cmLocalGenerator*>& generators)
{
for (std::vector<cmLocalGenerator*>::iterator i = generators.begin();
i != generators.end(); ++i) {
if (this->IsExcluded(root, *i)) {
continue;
}
cmMakefile* mf = (*i)->GetMakefile();
std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups();
std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets();
@ -2873,7 +2870,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
this->MainGroupChildren->AddObject(resourcesGroup);
// now create the cmake groups
if (!this->CreateGroups(root, generators)) {
if (!this->CreateGroups(generators)) {
return false;
}
@ -3041,10 +3038,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
std::vector<cmXCodeObject*> targets;
for (std::vector<cmLocalGenerator*>::iterator i = generators.begin();
i != generators.end(); ++i) {
if (!this->IsExcluded(root, *i)) {
if (!this->CreateXCodeTargets(*i, targets)) {
return false;
}
if (!this->CreateXCodeTargets(*i, targets)) {
return false;
}
}
// loop over all targets and add link and depend info

View File

@ -92,8 +92,7 @@ private:
cmXCodeObject* CreateOrGetPBXGroup(cmGeneratorTarget* gtgt,
cmSourceGroup* sg);
cmXCodeObject* CreatePBXGroup(cmXCodeObject* parent, std::string name);
bool CreateGroups(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
bool CreateGroups(std::vector<cmLocalGenerator*>& generators);
std::string XCodeEscapePath(const std::string& p);
std::string RelativeToSource(const char* p);
std::string RelativeToBinary(const char* p);

View File

@ -0,0 +1,6 @@
enable_language(CXX)
add_subdirectory(ExcludeFromAll EXCLUDE_FROM_ALL)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE foo)

View File

@ -0,0 +1,4 @@
add_library(bar STATIC bar.cpp)
add_library(foo STATIC foo.cpp)
target_include_directories(foo PUBLIC .)

View File

@ -0,0 +1 @@
#error This should be excluded from all target

View File

@ -0,0 +1,6 @@
#include "foo.h"
int foo()
{
return 42;
}

View File

@ -0,0 +1 @@
int foo();

View File

@ -3,3 +3,15 @@ include(RunCMake)
run_cmake(DoesNotExist)
run_cmake(Missing)
run_cmake(Function)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake(ExcludeFromAll)
run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .)
unset(RunCMake_TEST_BINARY_DIR)
unset(RunCMake_TEST_NO_CLEAN)

View File

@ -0,0 +1,6 @@
#include "foo.h"
int main(int, char**)
{
return foo();
}