如何强制Xcode使用自定义编译器? [英] How can I force Xcode to use a custom compiler?

查看:413
本文介绍了如何强制Xcode使用自定义编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想强制Xcode使用自定义编译器(从src构建'clang-llvm'),以便可以使用clang插件.我的Xcode版本是7.3.1.

I want to force Xcode to use a custom compiler ('clang-llvm' build from the src) so I can use the clang plugin. My Xcode version is 7.3.1.

推荐答案

人们说使用自定义工具链是可能的.我没有对它们进行研究,因为更简单的解决方案对我来说很有效:

People say it is possible with custom toolchains. I didn't make a research on them because easier solution worked well for me:

也可以通过设置Xcode的适当构建设置"来直接运行前端插件. (执行此操作的几种方法,例如,可以在命令行上设置它们:xcodebuild build FOO = bla.)以下是一些我发现对注入C标志有用的构建设置:

It is also possible to run frontend plugins directly by setting appropriate "build settings" of Xcode. (Several ways to do this, you can set them on the command line for instance: xcodebuild build FOO=bla.) Here are a few build settings that I found useful to inject C flags:

OTHER_CFLAGS,OTHER_CPLUSPLUSFLAGS或替换编译器和链接器:

OTHER_CFLAGS, OTHER_CPLUSPLUSFLAGS or to replace the compiler(s) and linker(s):

CC,CPLUSPLUS,LD,LDPLUSPLUS,LIBTOOL

CC, CPLUSPLUS, LD, LDPLUSPLUS, LIBTOOL

相同的方法可以控制分析"操作:CLANG_ANALYZER_EXEC,CLANG_ANALYZER_OTHER_FLAGS

The same approach works to control the "analyze" action: CLANG_ANALYZER_EXEC, CLANG_ANALYZER_OTHER_FLAGS

免责声明:其中一些构建设置未记录在案(afaik).使用风险自负.

Disclaimer: some of those build settings are undocumented (afaik). Use at your own risk.

(取自 [cfe-dev]编译/重构iOS Xcode项目)

对我来说,在Xcode项目的构建设置"中定义以下用户定义的设置就足够了:

For me it was enough to define the following User-Defined Settings in Build Settings of Xcode projects:

CC=my-c-compiler

CXX=my-cxx-compiler

LIBTOOL=my-linker-for-static-libraries


如果您使用CMake ,则自动注入编译器的方法是使用


If you use CMake, the way to inject your compiler automatically is to use

set_target_properties(your-target PROPERTIES XCODE_ATTRIBUTE_CC "${YOUR_CC}")
set_target_properties(your-target PROPERTIES XCODE_ATTRIBUTE_CXX "${YOUR_CXX}")

这篇关于如何强制Xcode使用自定义编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆