I'm working on some project which uses C++17 standard with clangd-13.0. Sometime after I decided to add library that used C99 standard in its CMakeLists file and now clangd always does analysis based on a C99 standard even in cpp files.
My CMakeLists file looks like this:
cmake_minimum_required(VERSION 3.21)
project(my_proj)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(SOURCES include/some_header.h src/some_source.cpp)
# Adding library that mostly uses C code
add_subdirectory(lib/path/to/lib)
add_library(${PROJECT_NAME} STATIC ${SOURCES})
target_link_libraries(${PROJECT_NAME}
imported_lib
)
Can I somehow exclude this library from compile_commands or enforce usage of C++17 standard?
Edit:
After I've removed declaration of -std=c99 flag the problem still occurs, clangd analyses cpp code as pure C, even though compile_commands.json doesn't contain any -std
parameter for library files