目标要求使用语言方言“ CXX17”。 (带有编译器扩展),但是CMake不知道用于启用它的编译标志 [英] Target requires the language dialect "CXX17" (with compiler extensions), but CMake does not know the compile flags to use to enable it

查看:1674
本文介绍了目标要求使用语言方言“ CXX17”。 (带有编译器扩展),但是CMake不知道用于启用它的编译标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我一直试图将< filesystem> 包含到我的项目中,这似乎比我想象的要大。 <文件系统> 应该是c ++ 17的一部分,我需要将该定义添加到CMakeList中。

So I've been trying to include the <filesystem> into my project, which seem to be a bigger problem than I thought. <filesystem> should be part of c++17, I need to add that definition into my CMakeList.

我的根CmakeList看起来像这样:

My root CmakeLists look like this:

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定义,但是当我编译我的系统,我收到此错误:

In which I added the c++17 definition, but when I compile my system, I get this error:

 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,所以我可以使用文件系统库?为什么?

But somehow isn't it willing to use c++17, so I can use the filesystem library? why?

推荐答案

如上所述,c ++版本3.8仅支持c ++ 17,因此我必须对其进行更新。

As mentioned is c++17 only supported by cmake version > 3.8, so I had to update it.

但是我的问题是我的gcc和g ++不支持它,所以我不得不更新它们,然后才更新。

But my problem was my gcc and g++ didn't support it, so I had to update those, which I then did.

我关注了这个指南

这篇关于目标要求使用语言方言“ CXX17”。 (带有编译器扩展),但是CMake不知道用于启用它的编译标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆