[CMake] detecting if c++11 available

Matthew Woehlke matthew.woehlke at kitware.com
Tue Feb 19 18:59:58 EST 2013


On 2013-02-19 18:36, Brad Bell wrote:
> My goal is to use some new c++11 features if they are available,
> otherwise to stick to the c++03 features. I need to build test programs
> that check for correctness as well as distribute an include file library.

In general, you should test for specific features that you want to use, 
as they may be available on compilers that don't claim C++11 compliance 
(e.g. MSVC, g++ with -std=c++0x).

I would write a simple test program per feature and use try_compile to 
see if the feature can be used. Then use configure_file and #cmakedefine 
to generate a header file with feature test symbols that you can use in 
your real code.

-- 
Matthew



More information about the CMake mailing list