vector-of-bool / cmrc

A Resource Compiler in a Single CMake Script
MIT License
672 stars 74 forks source link

clangd-lsp does not recognize header files #50

Open Gabriel-Dropout opened 1 year ago

Gabriel-Dropout commented 1 year ago

First of all, to use Clangd's LSP feature, I set set(CMAKE_EXPORT_COMPILE_COMMANDS ON) in CMakeLists.txt. This makes the compile commands to be written to the compile_commands.json file, which helps the language server understand the project structure.

However, using cmrc_add_resource_library() in CMakeLists.txt causes some header files to not recognize other header files. For example, the project structure is as follows

│  CMakeLists.txt
│  CMakeRC.cmake
├─build
├─include1
│      header1.h
├─include2
│      header2.h
├─resources
│      kitty.png
└─src
        main.cpp

in this case, if header1.h imports header2.h, LSP says it could not find the file. (However, it will compile and build normally!)