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

David Faure faure at kde.org
Fri Jun 10 12:31:49 UTC 2016


On dimanche 5 juin 2016 11:27:48 CEST Stephen Kelly wrote:
> 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?)

Indeed.

kde-modules/KDECompilerSettings.cmake:    set(CMAKE_CXX_FLAGS "$
{CMAKE_CXX_FLAGS} -std=c++0x")

Should we only do this if cmake < 3.1 ?

> You probably want
> 
>  set(CMAKE_CXX_STANDARD 14)
> 
> in Zanshin. 

Works. Thanks, pushed.

> 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)

No opinion. Kévin, I'll let you decide on that part.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5



More information about the Kde-buildsystem mailing list