酷酷的哀殿


  • 首页

  • 技术

  • 笔记

  • 杂记

  • Todo

  • 关于

  • 搜索
close

Xcode 新构建系统 与 cmake 的兼容性解决方案

时间: 2021-03-22   |   阅读: 576 字 ~2分钟

什么是 Xcode 构建系统

Build system 是一套将源码和资源文件转为 APP 的工具。

比如,当我们进行点击下图的运行按钮(Run Button) (▶️)时,Xcode 就会调用 Build System 进行 APP 的构建过程 。

工具栏

除此外,当我们使用命令行通过 xcodebuild 进行 build、archive 等操作时,都依赖 build system 完成工作。

Xcode 目前支持两套 build system, 因为New Build System 的构建速度更快和错误检测更多。所以,从 Legacy Build System 切换到 New Build System 后,可能会存在无法构建的情况。

如何切换构建系统

我们可以通过下面两图所示的方法切换 build system:

image

image

什么是 cmake

CMake 是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。它能够输出各种各样的 makefile 或者 projec t 文件,能测试编译器所支持的 C++特性,类似 UNIX 下的 automake。

cmake 兼容性问题

从 cmake 3.19 版本开始,Xcode generator 会尝试默认启用 Xcode 的 New Build System

对于部分不支持 new build system 的项目,会出现下面的警告或者报错:

Policy CMP0114 is not set to NEW 警告:

1
2
3
4
5
6
7
      "Policy CMP0114 is not set to NEW.  "
      "In order to support the Xcode \"new build system\", "
      "this project must be updated to set policy CMP0114 to NEW."
      "\n"
      "Since CMake is generating for the Xcode \"new build system\", "
      "ExternalProject_Add will use policy CMP0114's NEW behavior anyway, "
      "but the generated build system may not match what the project intends."

构建 compiler-rt 报错:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
CMake Error in ~/swift-source/llvm-project/pstl/CMakeLists.txt:
  The custom command generating

    ~/swift-source/build/Xcode-2023/llvm-macosx-x86_64/projects/compiler-rt/lib/builtins/outline_atomic_helpers.dir/outline_atomic_cas1_1.S

  is attached to multiple targets:

    clang_rt.cc_kext_arm64e_osx
    clang_rt.builtins_arm64e_osx
    clang_rt.cc_kext_arm64_osx
    clang_rt.builtins_arm64_osx

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".

兼容性解决方案

为了避免上面的警告或报错,我们可以通过添加参数 -T buildsystem=1 避免

示例:

image

经过实际测试,笔者添加参数 -T buildsystem=1 后,可以成功的编译 llvm 整个项目

相关推荐

  • Objective-C 与 泛型
  • 强制 Xcode 启用 NSAssert
  • 跟着 NSDictionary 的底层设计学习优化技巧(2)
  • 跟着 NSDictionary 的底层设计学习优化技巧(3)
  • iOS 各种奇怪的崩溃
#iOS# #泛型# #Xcode# #cmake#
通过 php 的语法设计将判断 NSArray 数组是否包含指定元素的时间复杂度从 O(n) 降为 O(1)
GCD 的线程数量限制分析
  • 文章目录
  • 站点概览
酷酷的哀殿

酷酷的哀殿

单身狗

74 日志
83 标签
    • 什么是 Xcode 构建系统
    • 如何切换构建系统
    • 什么是 cmake
    • cmake 兼容性问题
    • 兼容性解决方案
© 2021 酷酷的哀殿 京ICP备18052541号-2
Powered by - Hugo v0.80.0
Theme by - NexT
0%