I would like to have cmake manage the inclusion of the "-std=c++14" compiler flag. This is easy to do using the CMAKE_CXX_STANDARD as described here. This boils down to including the following:
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED on)
However, when using gcc, this results in the inclusion of "-std=gnu++14" which includes some non-standard features. Is there a way to have cmake invoke the "-std=c++14" compiler flag when using CMAKE_CXX_STANDARD instead of "-std=gnu++14"?
You can use the property CXX_EXTENSIONS or the global variable CMAKE_CXX_EXTENSIONS to switch between -std=c++1n and -std=gnu++1n.
https://cmake.org/cmake/help/v3.1/prop_tgt/CXX_EXTENSIONS.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With