set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") Setting this command activates the C++11 features for the compiler and after executing the cmake .. command, you should be able to use range based for loops in your code and compile it without any errors. Share. Follow
22 hours ago · Browse other questions tagged c++ c++11 cmake undefined-reference or ask your own question. The Overflow Blog AI and nanotechnology are working together to solve real-world problems
If you need to support older versions of CMake, here is a macro I came up with that you can use: macro(use_cxx11) if (CMAKE_VERSION VERSION_LESS "3.1") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") endif () else () set (CMAKE_CXX_STANDARD 11) endif () endmacro(use_cxx11)
C++11 and beyond. C++11 is supported by CMake. Really. Just not in CMake 2.8, because, guess what, C++11 didn't exist in 2009 when 2.0 was released. As long as you are using CMake 3.1 or newer, you should be fine, there are two different ways to enable support. And as you'll soon see, there's even better support in CMake 3.8+.
kimd99 November 8, 2019, 11:10am #1. Hello, I am trying to compile macros with c++14/17 features, either with g+±9 g++-9 -std=c++17 -o simulation.exe ...
Nov 06, 2017 · You'll notice there's no -std=gnu++11 flag anymore. Of course, since it looks like you're GCC version 7.2, you'll still want your set CMAKE_CXX_STANDARD to 98 since gcc-7.2 uses C++11 by default. (Or maybe it's C++14 now...) You can do this on your cmake command line. $ cmake -DUSE_VTK=FALSE -DCMAKE_CXX_STANDARD=98 ..
This property specifies the C++ standard whose features are requested to build this target. For some compilers, this results in adding a flag such as -std=gnu++ ...
Nov 23, 2013 · CMake will from this information make sure the C++ compiler is invoked with the correct command line flags (e.g. -std=c++11 ). For example, this C++ program with the filename main.cc makes use of the C++ features: cxx_strong_enums, cxx_constexpr, cxx_auto_type
Jan 05, 2014 · Various compiler versions of gcc and clang use different flags to specify C++11 support, namely older ones accept -std=c++0x and newer one -std=c++11. The above snippets detects which is the right one for the compiler being used and adds the flag to the CXX_FLAGS. Vim: Creating .clang_complete using CMake January 29, 2013 In "vim"
06.11.2017 · I'm trying to compile a project in C++ using cmake, and in the page of the project they tell me that it will crash if I don't add the standard 98. (I'm on a mac) I've tried all I found on the internet and I could manage to make the cmake use the option -std=c++98 but it also adds -DNDEBUG -std=gnu++11. (I saw it using the make VERBOSE=1 option)