From 765b46d1e1c6bc397942764fcbdd9fab9d29cb11 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Oct 2013 10:44:25 -0400 Subject: Xcode: Fix test architecture selection for Xcode >= 5 In Tests/Architecture and Tests/BuildDepends/Project we select a set of OS X cpu architectures to use for the test. Prior to Xcode 4 we always used i386 and ppc. Starting with Xcode 4, the tools do not support ppc but do support x86_64, so we switch to that. Fix the version check to recognize Xcode >= 5 as at least Xcode 4 and use the new architectures. --- Tests/Architecture/CMakeLists.txt | 4 ++-- Tests/BuildDepends/Project/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt index 927ce3f..ea5fc0b 100644 --- a/Tests/Architecture/CMakeLists.txt +++ b/Tests/Architecture/CMakeLists.txt @@ -7,8 +7,8 @@ function(test_for_xcode4 result_var) execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE ov RESULT_VARIABLE rv ) - if("${rv}" STREQUAL "0") - if(ov MATCHES "^Xcode 4.[0-9].*$") + if("${rv}" STREQUAL "0" AND ov MATCHES "^Xcode ([0-9]+)\\.") + if(NOT CMAKE_MATCH_1 VERSION_LESS 4) set(${result_var} 1 PARENT_SCOPE) endif() endif() diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index b4c6a07..8806ecd 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -7,8 +7,8 @@ function(test_for_xcode4 result_var) execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE ov RESULT_VARIABLE rv ) - if("${rv}" STREQUAL "0") - if(ov MATCHES "^Xcode 4.[0-9].*$") + if("${rv}" STREQUAL "0" AND ov MATCHES "^Xcode ([0-9]+)\\.") + if(NOT CMAKE_MATCH_1 VERSION_LESS 4) set(${result_var} 1 PARENT_SCOPE) endif() endif() -- cgit v0.12 From 118032247cf3c4938b4edce1c9c105b21b436518 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Oct 2013 11:34:21 -0400 Subject: Xcode: Teach Tests/BuildDepends to allow LINK_DEPENDS_NO_SHARED failure Xcode 5.0 now relinks targets when their shared libraries dependencies are modified, and there seems to be no way to stop it. Report this as a known limitation in the test output and do not fail. --- Tests/BuildDepends/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 3af0fda..0687154 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -285,6 +285,8 @@ if(EXISTS "${link_depends_no_shared_check_txt}") file(STRINGS "${link_depends_no_shared_check_txt}" link_depends_no_shared_check LIMIT_COUNT 1) if("${link_depends_no_shared_check}" STREQUAL "0") message(STATUS "link_depends_no_shared_exe is older than link_depends_no_shared_lib as expected.") + elseif(XCODE AND NOT XCODE_VERSION VERSION_LESS 5) + message(STATUS "Known limitation: link_depends_no_shared_exe is newer than link_depends_no_shared_lib but we cannot stop Xcode ${XCODE_VERSION} from enforcing this dependency.") else() message(SEND_ERROR "Project did not rebuild properly: link_depends_no_shared_exe is newer than link_depends_no_shared_lib.") endif() -- cgit v0.12 From dff8d113b4e7009436072af1b458272492badee6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Oct 2013 11:39:22 -0400 Subject: Xcode: Drop XCODE_DEPEND_HELPER for Xcode >= 5 Xcode 5.0 now computes dependencies from files linked through OTHER_LDFLAGS, so we no longer need the XCODE_DEPEND_HELPER hack to re-link dependents when targets change. --- Source/cmGlobalXCodeGenerator.cxx | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7cb2d1f..002c219 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -431,13 +431,16 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, // Add XCODE depend helper std::string dir = mf->GetCurrentOutputDirectory(); - cmCustomCommandLine makecommand; - makecommand.push_back("make"); - makecommand.push_back("-C"); - makecommand.push_back(dir.c_str()); - makecommand.push_back("-f"); - makecommand.push_back(this->CurrentXCodeHackMakefile.c_str()); - makecommand.push_back(""); // placeholder, see below + cmCustomCommandLine makeHelper; + if(this->XcodeVersion < 50) + { + makeHelper.push_back("make"); + makeHelper.push_back("-C"); + makeHelper.push_back(dir.c_str()); + makeHelper.push_back("-f"); + makeHelper.push_back(this->CurrentXCodeHackMakefile.c_str()); + makeHelper.push_back(""); // placeholder, see below + } // Add ZERO_CHECK bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION"); @@ -477,17 +480,18 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, // 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() == cmTarget::EXECUTABLE || + if(!makeHelper.empty() && + (target.GetType() == cmTarget::EXECUTABLE || // Nope - no post-build for OBJECT_LIRBRARY // target.GetType() == cmTarget::OBJECT_LIBRARY || target.GetType() == cmTarget::STATIC_LIBRARY || target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY)) { - makecommand[makecommand.size()-1] = + makeHelper[makeHelper.size()-1] = // fill placeholder this->PostBuildMakeTarget(target.GetName(), "$(CONFIGURATION)"); cmCustomCommandLines commandLines; - commandLines.push_back(makecommand); + commandLines.push_back(makeHelper); lg->GetMakefile()->AddCustomCommandToTarget(target.GetName(), no_depends, commandLines, @@ -3338,8 +3342,11 @@ void cmGlobalXCodeGenerator cmXCodeObject* t = *i; this->AddDependAndLinkInformation(t); } - // now create xcode depend hack makefile - this->CreateXCodeDependHackTarget(targets); + if(this->XcodeVersion < 50) + { + // now create xcode depend hack makefile + this->CreateXCodeDependHackTarget(targets); + } // now add all targets to the root object cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST); for(std::vector::iterator i = targets.begin(); -- cgit v0.12 From a3194ff4a70c60db4fcf7d0d9bee2139af67ec8f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 2 Oct 2013 11:52:18 -0400 Subject: Xcode: Fix OBJECT library support for Xcode 5 (#14254) Xcode 2.1 through 4 supported $(CURRENT_ARCH) in a PBXFileReference 'path' value used in the "Link Binary with Libraries" build phase. CMake uses this to reference object file locations on link lines to bring in OBJECT library content. However, Xcode 5 now evaluates the $(CURRENT_ARCH) reference in this context as "undefined_arch" so the wrong path is given to the linker. There seems to be no alternative way to produce an architecture-specific value in a PBXFileReference. Fortunately Xcode 5 now also handles link dependencies for paths linked through OTHER_LDFLAGS. For Xcode >= 5, move the OBJECT library object file references from the link build phase to OTHER_LDFLAGS. We can still show the object files in the source group listing in either case. --- Source/cmGlobalXCodeGenerator.cxx | 59 ++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 002c219..0a2b32b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1031,18 +1031,21 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, } } - // Add object library contents as external objects. (Equivalent to - // the externalObjFiles above, except each one is not a cmSourceFile - // within the target.) - std::vector objs; - this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs); - for(std::vector::const_iterator - oi = objs.begin(); oi != objs.end(); ++oi) - { - std::string obj = *oi; - cmXCodeObject* xsf = - this->CreateXCodeSourceFileFromPath(obj, cmtarget, ""); - externalObjFiles.push_back(xsf); + if(this->XcodeVersion < 50) + { + // Add object library contents as external objects. (Equivalent to + // the externalObjFiles above, except each one is not a cmSourceFile + // within the target.) + std::vector objs; + this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs); + for(std::vector::const_iterator + oi = objs.begin(); oi != objs.end(); ++oi) + { + std::string obj = *oi; + cmXCodeObject* xsf = + this->CreateXCodeSourceFileFromPath(obj, cmtarget, ""); + externalObjFiles.push_back(xsf); + } } // some build phases only apply to bundles and/or frameworks @@ -2769,13 +2772,6 @@ void cmGlobalXCodeGenerator } } - // Skip link information for static libraries. - if(cmtarget->GetType() == cmTarget::OBJECT_LIBRARY || - cmtarget->GetType() == cmTarget::STATIC_LIBRARY) - { - return; - } - // Loop over configuration types and set per-configuration info. for(std::vector::iterator i = this->CurrentConfigurationTypes.begin(); @@ -2788,6 +2784,31 @@ void cmGlobalXCodeGenerator configName = 0; } + if(this->XcodeVersion >= 50) + { + // Add object library contents as link flags. + std::string linkObjs; + const char* sep = ""; + std::vector objs; + this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs); + for(std::vector::const_iterator + oi = objs.begin(); oi != objs.end(); ++oi) + { + linkObjs += sep; + sep = " "; + linkObjs += this->XCodeEscapePath(oi->c_str()); + } + this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS", + linkObjs.c_str(), configName); + } + + // Skip link information for object libraries. + if(cmtarget->GetType() == cmTarget::OBJECT_LIBRARY || + cmtarget->GetType() == cmTarget::STATIC_LIBRARY) + { + continue; + } + // Compute the link library and directory information. cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); if(!pcli) -- cgit v0.12