[CMake] Specifying compilers?

Rolf Eike Beer eike at sf-mail.de
Thu Aug 23 02:47:36 EDT 2012


Jason T. Slack-Moehrle wrote:
> Hello,
> 
> I am trying to use come C++v11 features and am trying to get the
> compiling to work.
> 
> The error:
> [jtsm at server]$ ./build.sh
> -- The C compiler identification is Clang 4.0.0
> -- The CXX compiler identification is Clang 4.0.0
> -- Check for working C compiler: /usr/bin/clang
> -- Check for working C compiler: /usr/bin/clang -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working CXX compiler: /usr/bin/clang++
> -- Check for working CXX compiler: /usr/bin/clang++ -- works
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
> -- Found GLUT: -framework GLUT
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /Users/jtsm/Dropbox/Projects/All-Stars
> Scanning dependencies of target All-Stars
> [100%] Building CXX object CMakeFiles/All-Stars.dir/main.cpp.o
> /Users/jtsm/Dropbox/Projects/All-Stars/main.cpp:4:10: fatal error:
> 'thread' file not found
> #include <thread>
>          ^
> 1 error generated.
> make[2]: *** [CMakeFiles/All-Stars.dir/main.cpp.o] Error 1
> make[1]: *** [CMakeFiles/All-Stars.dir/all] Error 2
> make: *** [all] Error 2
> 
> [jtsm at server ]$ clang -v
> Apple clang version 4.0 (tags/Apple/clang-421.10.60) (based on LLVM 3.1svn)
> Target: x86_64-apple-darwin12.0.0
> Thread model: posix
> [jtsm at server ]$ clang++ -v
> Apple clang version 4.0 (tags/Apple/clang-421.10.60) (based on LLVM 3.1svn)
> Target: x86_64-apple-darwin12.0.0
> Thread model: posix
> 
> in my 'build.sh' I have:
> 
> #/bin/bash

mkdir build && cd build

> CC=clang CXX=clang++ cmake .

CC=clang CXX=clang++ cmake ..

> make

> SET( CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++" )
> 
> PROJECT( ${PROJECT_NAME} )

PROJECT will set up the compiler and stuff. And in this process it will set 
CMAKE_CXX_FLAGS, i.e. will overwrite your lines. Exchange the lines and make 
sure not to overwrite the existing flags, but append to them.

Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120823/0b190afc/attachment.pgp>


More information about the CMake mailing list