Brad King wrote:

> On 09/16/2015 02:22 PM, Stephen Kelly wrote:
>>> The default dialect computed with the compiler id may not be the
>>> same as the effective default dialect when CMAKE_CXX_FLAGS is
>>> considered.
>> 
>> I pushed another fixup which may disable the test in that case, and may
>> also disable it with GNU 6 and other compilers with default standard >=
>> 11.
> 
> That may fix the trouble for CMake's test suite, but might this
> also be a problem for projects in general?  Actually this could
> be an existing problem whether CMake computes or memorizes the
> raw compiler default.  If we're making decisions about what flags
> to add based on CMAKE_<LANG>_STANDARD_DEFAULT, but the user has
> already specified their own -std= flags in CMAKE_<LANG>_FLAGS,
> might we end up with the incorrect standard level, or multiple
> flags?

Multiple flags, apparently.

I made a project with 

 target_compile_features(hello PRIVATE cxx_decltype_auto) # -std=c++14

and built it with GNU 5.1(default dialect 98).

I ran cmake with -DCMAKE_CXX_FLAGS=-std=c++11.

The result is that a default of 11 is computed (with my branch) for the 
CXX_STANDARD_DEFAULT because of the CMAKE_CXX_FLAGS=-std=c++11, but 14 is 
the requirement, so

 -std=c++11   -std=gnu++14

appears on the command line. The latter 'wins' in this case.

If I instead use 

 target_compile_features(hello PRIVATE cxx_static_assert) # -std=c++11

Then 

 -std=c++11   -std=gnu++11

appears instead, which is consistent with the design of CompileFeatures. 
Arguably the -std=gnu++11 should not be added in that case, but changing 
that existing behavior would be a different topic.

Thanks,

Steve.


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to