go2sh / cmake-integration-vscode

CMake Server Interface for VSCode.
https://go2sh.github.io/cmake-integration-vscode/
Other
19 stars 11 forks source link

ExternalProject headers squigglies #56

Open tambry opened 4 years ago

tambry commented 4 years ago

My big project uses the ExternalProject CMake feature to download third-party libraries, e.g. spdlog, nlohmann json, imgui.

Unfortunately all of their headers show up with IntelliSense squigglies despite compiling fine and being able to open them with CTRL+clicking their names. System headers and the project's own includes seem to be parsed fine.

I tried to replicate this setup with a small example project, but it worked fine. The official CMake extension also groks this.

What are the steps I could take to try trace down this bug occurring with this project? E.g. is there a way to enable extra debug output from the extension?

go2sh commented 4 years ago

How do you add the external project into cmake? Do you define a custom target or as sub directory? The extension does not provide any log as of now, but you can check the cpptools log if you set the log level to debug. They report the SourceFileConfiguration for each file send form the cmake extensions, you can check there if your include path shows up and if it is the right one.

tambry commented 4 years ago

Found the problem. I had "C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools" left over in the settings.json from the official CMake extension. Maybe consider adding a warning or prompting the user about this? I only got a prompt for adding that line but for this extension once I had removed the previous one.

For reference regarding adding external projects:

cmake_minimum_required(VERSION 3.15)
project(control_station LANGUAGES CXX CUDA)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include(FetchContent)

FetchContent_Declare(
    spdlog
    GIT_REPOSITORY https://github.com/gabime/spdlog.git
    GIT_TAG        v1.x
    GIT_SHALLOW    TRUE
)

FetchContent_MakeAvailable(spdlog)

add_executable(test main.cpp)
target_link_libraries(test PRIVATE spdlog::spdlog)

add_subdirectory(example)
go2sh commented 4 years ago

Ah, okay thank you. I'll try to come up with a solution for the selection of the provider.