jeudi 4 février 2016

Clang Apple C++11 correct setup for CMake

I am trying to configure CMake to compile for OS X Target.This is IMac with OS X Yosemite v 10.10.2

Clang version:

Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)

Target: x86_64-apple-darwin14.1.0

When I compile without putting any compiler flags I am getting one error for this chunk of code in one the sources:

 static const char* LogLevelStr[] {
     "TRACE  " ,
     "INFO   " ,
     "WARNING" ,
     "ERROR  " ,
     "FATAL  " ,
};

error: definition of variable with array type needs an explicit size or an initializer

I am compiling this code on Windows and GCC and it is completely fine so I don't understand why Clang complains here.So I decided,maybe I have to set C++11 support flags because I use this standard in the code a lot.

Setting

set (CMAKE_CXX_STANDARD 11)

or

set(CMAKE_CXX_FLAGS " -std=c++11")

Adds even more weird errors like these:

/Applications/http://ift.tt/1nIU91R: error: expected ';' at end of declaration list _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT ^ /Applications/http://ift.tt/1S2q0Yi: error: expected ';' at end of declaration swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT ^ >/Applications/http://ift.tt/1nIU91T>hain/usr/bin/../include/c++/v1/__bit_reference:87:58: error: C++ requires a type specifier for all declarations >swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT ^ >/Applications/http://ift.tt/1S2q3n5: note: expanded from macro '_NOEXCEPT'

The error block from above the compiler spits at the point it is trying to parse include

Now,I tried also to set:

set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++") 

Same errors.

What do I miss here?

Aucun commentaire:

Enregistrer un commentaire