From afb325018ebe7c41933b652732a43e4bb4777588 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Sun, 10 Feb 2019 11:22:38 +0100 Subject: Xcode: Require at least Xcode 5 --- CMakeCPack.cmake | 3 -- CMakeCPackOptions.cmake.in | 10 ----- Help/generator/Xcode.rst | 4 +- Help/release/dev/require-xcode-5.rst | 4 ++ Help/variable/CMAKE_MAKE_PROGRAM.rst | 8 +--- Source/CMakeLists.txt | 3 -- Source/cmGlobalXCodeGenerator.cxx | 72 ++++++-------------------------- Source/cmakexbuild.cxx | 80 ------------------------------------ 8 files changed, 19 insertions(+), 165 deletions(-) create mode 100644 Help/release/dev/require-xcode-5.rst delete mode 100644 Source/cmakexbuild.cxx diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake index dc9f0ba..78e22cc 100644 --- a/CMakeCPack.cmake +++ b/CMakeCPack.cmake @@ -102,9 +102,6 @@ if(CMake_INSTALL_COMPONENTS) if(WIN32 AND NOT CYGWIN) list(APPEND _CPACK_IFW_COMPONENTS_ALL cmcldeps) endif() - if(APPLE) - list(APPEND _CPACK_IFW_COMPONENTS_ALL cmakexbuild) - endif() if(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME) set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in index a08c97d..2a4bcc5 100644 --- a/CMakeCPackOptions.cmake.in +++ b/CMakeCPackOptions.cmake.in @@ -109,16 +109,6 @@ if(CPACK_GENERATOR MATCHES "IFW") set(CPACK_IFW_COMPONENT_CMCLDEPS_VERSION "@CMake_IFW_ROOT_COMPONENT_VERSION@") - set(CPACK_COMPONENT_CMAKEXBUILD_DISPLAY_NAME "cmakexbuild") - set(CPACK_COMPONENT_CMAKEXBUILD_DESCRIPTION - "The \"cmakexbuild\" executable is a wrapper program for \"xcodebuild\"") - set(CPACK_COMPONENT_CMAKEXBUILD_REQUIRED TRUE) - set(CPACK_COMPONENT_CMAKEXBUILD_GROUP Tools) - set(CPACK_IFW_COMPONENT_CMAKEXBUILD_NAME "CMakeXBuild") - set(CPACK_IFW_COMPONENT_CMAKEXBUILD_PRIORITY 85) - set(CPACK_IFW_COMPONENT_CMAKEXBUILD_VERSION - "@CMake_IFW_ROOT_COMPONENT_VERSION@") - # Dialogs set(CPACK_COMPONENT_GROUP_DIALOGS_DISPLAY_NAME "Interactive Dialogs") set(CPACK_COMPONENT_GROUP_DIALOGS_DESCRIPTION diff --git a/Help/generator/Xcode.rst b/Help/generator/Xcode.rst index 71430c7..d893ac5 100644 --- a/Help/generator/Xcode.rst +++ b/Help/generator/Xcode.rst @@ -3,9 +3,7 @@ Xcode Generate Xcode project files. -This supports Xcode 3.0 and above. Support for Xcode versions prior -to Xcode 5 is deprecated and will be dropped in a future version of -CMake. +This supports Xcode 5.0 and above. Toolset Selection ^^^^^^^^^^^^^^^^^ diff --git a/Help/release/dev/require-xcode-5.rst b/Help/release/dev/require-xcode-5.rst new file mode 100644 index 0000000..6cfe96a --- /dev/null +++ b/Help/release/dev/require-xcode-5.rst @@ -0,0 +1,4 @@ +require-xcode-5 +--------------- + +* The :generator:`Xcode` generator now requires at least Xcode 5. diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst index 4f5a50f..56df2df 100644 --- a/Help/variable/CMAKE_MAKE_PROGRAM.rst +++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst @@ -19,15 +19,11 @@ to configure the project: This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache so that it may be edited by the user. -* The :generator:`Xcode` generator sets this to ``xcodebuild`` (or possibly an - otherwise undocumented ``cmakexbuild`` wrapper implementing some - workarounds). +* The :generator:`Xcode` generator sets this to ``xcodebuild``. This generator prefers to lookup the build tool at build time rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache - ahead of time. This is because ``xcodebuild`` is easy to find, - the ``cmakexbuild`` wrapper is needed only for older Xcode versions, - and the path to ``cmakexbuild`` may be outdated if CMake itself moves. + ahead of time. This is because ``xcodebuild`` is easy to find. For compatibility with versions of CMake prior to 3.2, if a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1c06052..663d42e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1060,9 +1060,6 @@ if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARI endif() if(APPLE) - add_executable(cmakexbuild cmakexbuild.cxx) - list(APPEND _tools cmakexbuild) - target_link_libraries(cmakexbuild CMakeLib) add_executable(OSXScriptLauncher CPack/OSXScriptLauncher.cxx) target_link_libraries(OSXScriptLauncher cmsys) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 51c001e..4e4e1bb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -217,7 +217,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator( sscanf(version_string.c_str(), "%u.%u", &v[0], &v[1]); unsigned int version_number = 10 * v[0] + v[1]; - if (version_number < 30) { + if (version_number < 50) { cm->IssueMessage(MessageType::FATAL_ERROR, "Xcode " + version_string + " not supported."); return nullptr; @@ -256,15 +256,11 @@ std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand() std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand() { - if (this->XcodeVersion >= 40) { - std::string makeProgram = cmSystemTools::FindProgram("xcodebuild"); - if (makeProgram.empty()) { - makeProgram = "xcodebuild"; - } - return makeProgram; + std::string makeProgram = cmSystemTools::FindProgram("xcodebuild"); + if (makeProgram.empty()) { + makeProgram = "xcodebuild"; } - // Use cmakexbuild wrapper to suppress environment dump from output. - return cmSystemTools::GetCMakeCommand() + "xbuild"; + return makeProgram; } bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts, @@ -550,12 +546,7 @@ 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 || - (this->XcodeVersion < 50 && - (target->GetType() == cmStateEnums::EXECUTABLE || - target->GetType() == cmStateEnums::STATIC_LIBRARY || - target->GetType() == cmStateEnums::SHARED_LIBRARY || - target->GetType() == cmStateEnums::MODULE_LIBRARY))) { + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { makeHelper.back() = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); cmCustomCommandLines commandLines; @@ -1183,23 +1174,6 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( } } - 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; - gtgt->GetExternalObjects(objs, ""); - for (auto sourceFile : objs) { - if (sourceFile->GetObjectLibrary().empty()) { - continue; - } - std::string const& obj = sourceFile->GetFullPath(); - cmXCodeObject* xsf = - this->CreateXCodeSourceFileFromPath(obj, gtgt, "", nullptr); - externalObjFiles.push_back(xsf); - } - } - // some build phases only apply to bundles and/or frameworks bool isFrameworkTarget = gtgt->IsFrameworkOnApple(); bool isBundleTarget = gtgt->GetPropertyAsBool("MACOSX_BUNDLE"); @@ -2123,9 +2097,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, default: break; } - if (this->XcodeVersion < 40) { - buildSettings->AddAttribute("PREBINDING", this->CreateString("NO")); - } BuildObjectListOrString dirs(this, true); BuildObjectListOrString fdirs(this, true); @@ -2775,8 +2746,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) // Loop over configuration types and set per-configuration info. for (auto const& configName : this->CurrentConfigurationTypes) { - // Get the current configuration name. - if (this->XcodeVersion >= 50) { + { // Add object library contents as link flags. std::string linkObjs; const char* sep = ""; @@ -2886,7 +2856,7 @@ bool cmGlobalXCodeGenerator::CreateGroups( // Put cmSourceFile instances in proper groups: for (auto const& si : gtgt->GetAllConfigSources()) { cmSourceFile const* sf = si.Source; - if (this->XcodeVersion >= 50 && !sf->GetObjectLibrary().empty()) { + if (!sf->GetObjectLibrary().empty()) { // Object library files go on the link line instead. continue; } @@ -3076,16 +3046,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( v << std::setfill('0') << std::setw(4) << XcodeVersion * 10; group->AddAttribute("LastUpgradeCheck", this->CreateString(v.str())); this->RootObject->AddAttribute("attributes", group); - if (this->XcodeVersion >= 32) { - this->RootObject->AddAttribute("compatibilityVersion", - this->CreateString("Xcode 3.2")); - } else if (this->XcodeVersion >= 31) { - this->RootObject->AddAttribute("compatibilityVersion", - this->CreateString("Xcode 3.1")); - } else { - this->RootObject->AddAttribute("compatibilityVersion", - this->CreateString("Xcode 3.0")); - } + this->RootObject->AddAttribute("compatibilityVersion", + this->CreateString("Xcode 3.2")); // Point Xcode at the top of the source tree. { std::string pdir = @@ -3540,13 +3502,7 @@ void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmXCodeObject::Indent(1, fout); fout << "};\n"; cmXCodeObject::Indent(1, fout); - if (this->XcodeVersion >= 32) { - fout << "objectVersion = 46;\n"; - } else if (this->XcodeVersion >= 31) { - fout << "objectVersion = 45;\n"; - } else { - fout << "objectVersion = 44;\n"; - } + fout << "objectVersion = 46;\n"; cmXCode21Object::PrintList(this->XCodeObjects, fout); cmXCodeObject::Indent(1, fout); fout << "rootObject = " << this->RootObject->GetId() @@ -3714,11 +3670,7 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags, // Flag value with escaped quotes and backslashes. for (auto c : flag) { if (c == '\'') { - if (this->XcodeVersion >= 40) { - flags += "'\\''"; - } else { - flags += "\\'"; - } + flags += "'\\''"; } else if (c == '\\') { flags += "\\\\"; } else { diff --git a/Source/cmakexbuild.cxx b/Source/cmakexbuild.cxx deleted file mode 100644 index f5c8f07..0000000 --- a/Source/cmakexbuild.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ - -#include "cmConfigure.h" // IWYU pragma: keep - -#include "cmsys/Process.h" -#include -#include -#include - -#include "cmDuration.h" -#include "cmSystemTools.h" - -// This is a wrapper program for xcodebuild -// it calls xcodebuild, and does two things -// it removes much of the output, all the setenv -// stuff. Also, it checks for the text file busy -// error, and re-runs xcodebuild until that error does -// not show up. - -int RunXCode(std::vector& argv, bool& hitbug) -{ - hitbug = false; - cmsysProcess* cp = cmsysProcess_New(); - cmsysProcess_SetCommand(cp, argv.data()); - cmsysProcess_SetTimeout(cp, 0); - cmsysProcess_Execute(cp); - std::vector out; - std::vector err; - std::string line; - int pipe = - cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out, err); - while (pipe != cmsysProcess_Pipe_None) { - if (line.find("/bin/sh: bad interpreter: Text file busy") != - std::string::npos) { - hitbug = true; - std::cerr << "Hit xcodebuild bug : " << line << "\n"; - } - // if the bug is hit, no more output should be generated - // because it may contain bogus errors - // also remove all output with setenv in it to tone down - // the verbosity of xcodebuild - if (!hitbug && (line.find("setenv") == std::string::npos)) { - if (pipe == cmsysProcess_Pipe_STDERR) { - std::cerr << line << "\n"; - } else if (pipe == cmsysProcess_Pipe_STDOUT) { - std::cout << line << "\n"; - } - } - pipe = cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out, - err); - } - cmsysProcess_WaitForExit(cp, nullptr); - if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) { - return cmsysProcess_GetExitValue(cp); - } - if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) { - return -1; - } - return -1; -} - -int main(int ac, char* av[]) -{ - std::vector argv; - argv.push_back("xcodebuild"); - for (int i = 1; i < ac; i++) { - argv.push_back(av[i]); - } - argv.push_back(nullptr); - bool hitbug = true; - int ret = 0; - while (hitbug) { - ret = RunXCode(argv, hitbug); - } - if (ret < 0) { - return 255; - } - return ret; -} -- cgit v0.12