Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake, choose Xcode compiler

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.html makes 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.

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.

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

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:

set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
like image 967
moka Avatar asked Nov 19 '11 16:11

moka


1 Answers

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.

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).

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_X not CMAKE_XCODE_ATTRIBUTE_X, too.

like image 87
James Avatar answered Oct 16 '22 02:10

James