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
This commit is contained in:
Christian Blichmann 2022-04-06 06:23:45 -07:00 committed by Copybara-Service
parent 0d833be608
commit c6166b1364

View File

@ -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)