From c6166b136467d73c30c4f947e7f5f9345ec35942 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Wed, 6 Apr 2022 06:23:45 -0700 Subject: [PATCH] CMake: Workaround for `compile_commands.json` being incomplete When building contrib libraries as a Sandboxed API super-project or when building Sandboxed API as a sub-project, CMake may not include all files when writing a `compile_commands.json`, leading to missing include paths for the libtooling interface generator. This change sets `CMAKE_EXPORT_COMPILE_COMMANDS` as a cache variable so that it persists across project boundaries. Writing compilation databases, even when they are otherwise unused, is harmless. PiperOrigin-RevId: 439820022 Change-Id: Ice96e78cf41fff5792aa0a8734f1ccf80f541e4c --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecff941..f07e8aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,9 @@ endif() include(CheckCXXCompilerFlag) -# Allow the header generator to auto-configure include paths -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +# Allow the header generator to auto-configure include paths. Need to set a +# cache variable, so that sub- and super-projects also have this enabled. +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") set(CMAKE_SKIP_BUILD_RPATH ON)