From 46d30599da28c49657c7991c86c64f4f7b1ff4f0 Mon Sep 17 00:00:00 2001 From: Kirill Andriianov Date: Tue, 11 Feb 2025 23:58:02 +0100 Subject: [PATCH] feat: Make implicit include paths explicit. This is useful for development, since tooling, that reads compile_commands.json will see all includes. Fixes issue with clangd on nixos --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 133eb5220671..f32f022fc408 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,15 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) project(userver) +# Generate compile_commands.json by default +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") +if(CMAKE_EXPORT_COMPILE_COMMANDS) + # Make sure the file is generated with all implicit paths spelled out explicitly + # This makes clangd usable on nix-based setups + set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES + ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}) +endif() + set(USERVER_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}") option(