cmake will not compile to C++ 11 standard

前端 未结 4 1460
面向向阳花
面向向阳花 2021-02-03 12:26

I\'m new to C++ and have been struggling with compiling/making/linking/building/whatever, lets see if somebody can help me out. I did some searches and found other people with

4条回答
  •  南笙
    南笙 (楼主)
    2021-02-03 12:42

    I always enable c++11 in my code using CMake this way:

    set(CMAKE_CXX_FLAGS "-std=c++11")
    

    My compiler is gcc (Debian 4.9.2-10) 4.9.2, however in my workplace I also use other versions and this approach always works.

    EDIT (to avoid variable overwriting):

    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    

提交回复
热议问题