Support emitting Index-Store for SourceKit-lsp
The IndexStore helps SourceKit-lsp provide an improved LSP experience. AppleClang, Clang from the Swift toolchain on other platforms, and the Swift compiler on all platforms support emitting an index database with the -index-store-path
flag. We can provide a mechanism for enabling and disabling emitting the index.
The index is useful for development and should not be installed. It can likely go somewhere in the CMakeFiles
directory. SourceKit-lsp will read the index-store path from the exported compile_commands.json
.
Thoughts for consideration:
-
We could consider only emitting the index store flag if
CMAKE_EXPORT_COMPILE_COMMANDS
is set to true, but then toggling that variable would require a full rebuild to get the full LSP behavior, instead of just reconfiguring, which is odd. -
We could have this flag passed to any compiler that supports it at all times, but it has an impact on compile-times so we likely want to have a user-configurable option. A reasonable default is likely to enable it for Debug configurations and disable it otherwise (this matches what Swift-package-manager does). This option should be either enabled or disabled for all targets, so a target property does not make sense.