为什么 VS 看不到包含的文件?

Why VS doesn't see included files?

我是一名写项目的学生。我创建了一个程序(这里是 link 到 SVN:https://mysvn.ru/Ilya_Antonov/antonov_sem_prj)。我使用 CMake 构建它并生成 .sln 项目。但是当运行它在Visual Studio时,会出现一些错误:编译器无法打开文件“drumswindow.h”和“mainwindow.h”(致命错误C1083)。请看看我的 CMakeLists.txt:

cmake_minimum_required(VERSION 3.1.0)

project(MusicSimulator VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

if(CMAKE_VERSION VERSION_LESS "3.7.0")
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()


find_package(Qt5 COMPONENTS Gui REQUIRED)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt5 COMPONENTS Core REQUIRED)
find_package(Qt5 COMPONENTS Multimedia REQUIRED)

add_executable(MusicSimulator
    mainwindow.ui
    mainwindow.cpp
    mainwindow.h
    main.cpp
    drumswindow.ui
    drumswindow.cpp
    drumswindow.h
    keyswindow.ui
    keyswindow.cpp
    keyswindow.h
    images.qrc
    drumres.qrc
    keysres2.qrc
    keysres3.qrc
    keysres4.qrc
    keysres5.qrc
    keysres6.qrc
)

target_link_libraries(MusicSimulator Qt5::Widgets Qt5::Gui Qt5::Core Qt5::Multimedia)

我做错了什么?

您没有包含当前源目录,因此编译器找不到它。添加当前源目录或使用正确的包含语句(例如 #include "keyswindow.h"