1

I am compiling CMake with some default options, the first is -DCMAKE_CXX_FLAGS=-std=c++11.

Other compiles using CMake are complaining with warnings of needing C++14 as well.

Is it possible to have add multiple options to this flag such as -DCMAKE_CXX_FLAGS=-std=c++11:c++14

usr1234567
  • 21,601
  • 16
  • 108
  • 128
art vanderlay
  • 2,341
  • 4
  • 35
  • 64

1 Answers1

0

No, you cannot pass multiple options for C++ flags.
What would be the meaning of your example anyway? Use C++11 or C++14, whatever is available? If both are applicable, use the higher one? Either you use C++11 or C++14 features, then you need the compiler to be at least in the right mode.

If you write your own CMakeLists.txt for your project, you can either use CMake for checking supported C++1/C++14 features or you can try accepted flags and choose the most recent one.
For recent CMake versions, you can set the required C++ mode per target via the CXX_STANDARD properte, see https://cmake.org/cmake/help/v3.4/prop_tgt/CXX_STANDARD.html

Community
  • 1
  • 1
usr1234567
  • 21,601
  • 16
  • 108
  • 128
  • I have two dependencies being compiled for a 3rd program, one needs c++11, the other c++14, so based on your response it seems I need two cmake builds. – art vanderlay Jan 20 '16 at 06:33
  • Why not build both third party programs with C++14? – usr1234567 Jan 20 '16 at 06:35
  • I am going on the release notes that c++11 MUST be set for the first and that c++14 features are needed for the 2nd. I have no insight into why the first MUST have c++11, hence my question. I will try both with C++14 and hope that there are no unforeseen issues by using a higher version. thx Art. – art vanderlay Jan 20 '16 at 06:40