xcode CMake,选择Xcode编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8195429/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:29:00  来源:igfitidea点击:

CMake, choose Xcode compiler

c++xcodecompiler-constructioncmake

提问by moka

I know that until recently it was not possible to select any specific compiler for xcode projects generated by CMake (it would always choose xcodes default compiler). Anyways this post: http://cmake.3232098.n2.nabble.com/CMake-2-8-1-available-for-download-td4752230.htmlmakes me believe that it should be possible with a specific CMAKE_XCODE_ATTRIBUTE_flag by now.- Unfortunatelly I could neither find which flag is supposed to change xcodes compiler, nor a list of all xcode flags supported by CMake.

我知道直到最近才可能为 CMake 生成的 xcode 项目选择任何特定的编译器(它总是选择 xcodes 默认编译器)。无论如何,这篇文章:http: //cmake.3232098.n2.nabble.com/CMake-2-8-1-available-for-download-td4752230.html让我相信现在应该可以使用特定的CMAKE_XCODE_ATTRIBUTE_标志.- 不幸的是,我既找不到应该更改 xcodes 编译器的标志,也找不到 CMake 支持的所有 xcode 标志的列表。

I am using Xcode 4.2 and CMake 2.8.6, and I'd like to be able to switch between LLVM 3.0 and LLVM GCC 4.2 from within CMake.

我正在使用 Xcode 4.2 和 CMake 2.8.6,我希望能够从 CMake 中在 LLVM 3.0 和 LLVM GCC 4.2 之间切换。

As I said a list, which lists all xcode flags I can change from within CMake would be great!

正如我所说的,列出我可以在 CMake 中更改的所有 xcode 标志的列表会很棒!

Thanks

谢谢

EDIT:

编辑:

with Cmake 2.8.6, if you want to generate an xcode project that does not default to Clang/LLVM 3.0, use the following:

使用 Cmake 2.8.6,如果要生成不默认为 Clang/LLVM 3.0 的 xcode 项目,请使用以下命令:

set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")

采纳答案by James

It seems that CMake just transparently sets whatever attribute you set in the XCode Project file - so it supports any and all attributes that you like.

似乎 CMake 只是透明地设置了您在 XCode 项目文件中设置的任何属性 - 因此它支持您喜欢的任何和所有属性。

By inspection of one of my XCode project files, the attribute that you want seems to be GCC_VERSION, and these are the acceptable values (my XCode is 4.0.2, gcc v4.2).

通过检查我的 XCode 项目文件之一,您想要的属性似乎是GCC_VERSION,这些是可接受的值(我的 XCode 是 4.0.2,gcc v4.2)。

GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_VERSION = 4.2
GCC_VERSION = com.apple.compilers.llvmgcc42

My CMake documentation seems to suggest that you want to set XCODE_ATTRIBUTE_Xnot CMAKE_XCODE_ATTRIBUTE_X, too.

我的 CMake 文档似乎暗示您也不想设置XCODE_ATTRIBUTE_XCMAKE_XCODE_ATTRIBUTE_X。