[CMake] Set CMAKE_<LANG>_FLAGS_* and overriding

David Demelier demelier.david at gmail.com
Tue Sep 17 05:40:31 EDT 2013


Hello,

I'm writing a C++11 project. To enable C++11 it requires some switches,
such as -std=c++11.

So for the moment, I have in my CMakeLists.txt:

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

So with that, I'm sure that any build configuration will add this.
However, with clang++, you need to pass an additional flag (for FreeBSD
especially): -stdlib=libc++.

So I would like to be able to do at command line:

cmake .. -DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++"

But with that, it just ignore my setting and take the one from the
CMakeLists.txt

What is the correct way to:

* Set CXX flags globally, for any type of configuration
* Let them be overriden?

Regards,

David.


More information about the CMake mailing list