понедельник, 29 января 2018 г.

CentOS и cmake: this file requires compiler and library support for the iso c++ 2011 standard

Даже после установки devtoolset-7 софт может не собираться, выдавая
this file requires compiler and library support for the iso c++ 2011 standard
Была найдена такая штука:

# http://stackoverflow.com/questions/10851247/how-to-activate-c-11-in-cmake
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    add_definitions(-std=c++11)
elseif(COMPILER_SUPPORTS_CXX0X)
    add_definitions(-std=c++0x)
else()
    message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

Вставляем в CMakeLists.txt поближе к началу, собираем.

Хотя мелькал и такой вариант
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

ручной вариант
$ cmake -DCMAKE_CXX_FLAGS=-std=c++11 ..

Комментариев нет:

Отправить комментарий