cmake forces c++11 on an app that needs c++14

Stephen Kelly steveire at gmail.com
Sun Jun 5 09:27:48 UTC 2016


On 06/04/2016 11:03 AM, David Faure wrote:
> Symptom: zanshin doesn't compile with Qt 5.7 and cmake from "release" branch,
> error is "std::make_unique not found".
>
> Reason: zanshin wants -std=c++14, but gets a compile line like this:
> -std=c++0x [...] -std=c++14 [...] -std=gnu++11
> so in the end only C++11 is enabled, not C++14.
>
> In order to enable C++14, Zanshin does this:
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

This is likely:

 https://bugreports.qt.io/browse/QTBUG-53002

I don't know where the -std=c++0x comes from in your compile line
(something in ECM?).

The -std=gnu++11 comes from Qt 5.7 now requiring some C++11 features and
the Qt5 CMake targets reflecting that in their interface.

You probably want

 set(CMAKE_CXX_STANDARD 14)

in Zanshin. I don't know if the use of -std=c++11 instead of
-std=gnu++11 is deliberate (usually it is not, but the internet got in
the habit of recommending -std=c++11), but if it is, then you
additionally want to disable gnu extensions with

 set(CMAKE_CXX_EXTENSIONS OFF)

Thanks,

Steve.



More information about the Kde-buildsystem mailing list