mitaki28 / vscode-clang

Completion and Diagnostic for C/C++/Objective-C using Clang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Header "file not found" error when using cmake's FetchContent

lprc opened this issue · comments

I was about to raise an issue at vscode-cmake-tools but fortunately I first disabled all extensions just to see if any extension possibly has an effect on the error.

So I have a very simple example project that contains only the two files main.cpp and CMakeLists.txt (contents see below). Everything works fine using the C/C++ and CMake Tools extensions. However only if this extension is active, VS Code states the fetched header file is not found:

grafik

main.cpp:

#include <iostream>

#include "nanobench.h"

int main(int argc, char const *argv[])
{
    std::cout << "test123" << std::endl;
    return 0;
}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.17)
project(Cmake-Intellisense-Test VERSION 0.1.0)

Include(FetchContent)

FetchContent_Declare(
    nanobench
    GIT_REPOSITORY https://github.com/martinus/nanobench.git
    GIT_TAG v4.3.7
    GIT_SHALLOW TRUE)

FetchContent_MakeAvailable(nanobench)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE nanobench)

Fortunately all the IntelliSense stuff works nevertheless (like ctrl+click) but I thought you should know about this. And maybe you also have an idea why this happens.

clang pp file not found