【发布时间】:2017-11-11 13:46:29
【问题描述】:
所以我一直在尝试将<filesystem> 包含到我的项目中,这似乎是一个比我想象的更大的问题。 <filesystem> 应该是 c++17 的一部分,我需要将该定义添加到我的 CMakeList 中。
我的根 CmakeList 如下所示:
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库?为什么?
【问题讨论】:
-
您使用的是哪个版本的 cmake? 17 作为
CMAKE_CXX_STANDARD的值仅受 v3.8 支持 -
我正在使用 cmake 3.9.6 .. 因为这个我更新了 cmake ......但解决方案显然也是升级 gcc 和 g++
-
@Lamda 如果您找到了问题的解决方案,那么您应该将其作为答案发布并最终接受。