温馨提示:本文翻译自stackoverflow.com,查看原文请点击:c++ - Target requires the language dialect "CXX17" (with compiler extensions), but CMake does not know the

c++ - 目标要求使用语言方言“ CXX17”(具有编译器扩展名),但CMake不知道

发布于 2020-03-27 11:57:36

因此,我一直想将<filesystem>纳入我的项目,这似乎是一个比我想象的更大的问题。 <filesystem>应该是c ++ 17的一部分,我需要将该定义添加到我的CMakeList中。

我的根CmakeLists看起来像这样:

MESSAGE(“In src CMAKELIST”)

#
# Build everything in include/ directory
add_subdirectory(include)
#

#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

## Main executable target
add_executable(cmakeDemo main.cpp)

# These libraries get built in include/*/, CMake will auto-set required
# compiler flags and include paths from their definitions
target_link_libraries(cmakeDemo record ${portaudio})
target_link_libraries(cmakeDemo database)
target_link_libraries(cmakeDemo match)
target_link_libraries(cmakeDemo spectogram)

在其中添加了c ++ 17定义,但是在编译系统时出现此错误:

 make 
“InsrcCMAKELIST”
“InincludeCMAKELIST”
“IndatabaseCMAKELIST”
“InmatchCMAKELIST”
“InrecordCMAKELIST”
“InspectogramCMAKELIST”
/home/lamda/soundcloud/src/include/spectogram/base/base.h
“outspectogramCMAKELIST”
-- Configuring done
CMake Error in src/CMakeLists.txt:
  Target "cmakeDemo" requires the language dialect "CXX17" (with compiler
  extensions), but CMake does not know the compile flags to use to enable it.


-- Generating done
-- Build files have been written to: /home/lamda/soundcloud/build
make: *** [cmake_check_build_system] Error 1

但是不知道为什么不愿意使用c ++ 17,所以我可以使用该filesystem库?为什么?

查看更多

查看更多

提问者
Lamda
被浏览
58
Lamda 2017-11-13 00:56

如前所述,cmake版本> 3.8仅支持c ++ 17,因此我不得不对其进行更新。

但是我的问题是我的gcc和g ++不支持它,所以我不得不更新那些,然后我做了。

我遵循了本指南

发布
问题

分享
好友

手机
浏览

扫码手机浏览