Home > Net >  VSCode can't find include path
VSCode can't find include path

Time:12-03

I've got a simple CMake educational project sturctured like this:

project structure

The root CMakeLists.txt is like that:

cmake_minimum_required(VERSION 3.24.2)
project(SIMPLE_ENGINE CXX)
add_subdirectory(engine)
add_subdirectory(game)

game:

cmake_minimum_required(VERSION 3.24.2)
project(GAME CXX)

add_executable(
    game
    src/main.cpp
)

target_link_libraries(
    game
    engine
)

set_property(TARGET game PROPERTY CXX_STANDARD 20)

engine:

cmake_minimum_required(VERSION 3.24.2)
project(ENGINE CXX)

add_library(
    engine
    include/base/window.h
    src/base/window.cpp
    include/base/engine.h
    src/base/engine.cpp
)

target_include_directories(
    engine
    PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(
    engine
    glfw
    GLEW
    GL
)

set_property(TARGET engine PROPERTY CXX_STANDARD 20)

The problem is that VSCode can't find include files despite the fact the project compiles and runs successfully. As far as I understand it should get all the information from cmake files. Any advice in that regard?

CodePudding user response:

Ok, it seems that problem was because "configurationProvider" in configuration file was set to "ms-vscode.makefile-tools". I changed it to "configurationProvider": "ms-vscode.cmake-tools" and now it seems to work.

CodePudding user response:

You should try putting all the files in one directory. You might also have some extension enabled that is messing up VSCode if it isn't detecting the files but still compiling them.

  • Related