mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 00:11:07 -06:00
FASTBuild: generate compile_commands
If `CMAKE_EXPORT_COMPILE_COMMANDS` is set use FASTBuild's `-compdb` option in order to generate `compile_commands.json` file. Fixes: #27345
This commit is contained in:
committed by
Brad King
parent
d98c9bf2cc
commit
5e25ee691a
@@ -477,11 +477,18 @@ void cmGlobalFastbuildGenerator::Generate()
|
||||
this->GetCMakeInstance()->GetIsInTryCompile()) {
|
||||
return;
|
||||
}
|
||||
std::string const workingDir =
|
||||
this->GetCMakeInstance()->GetHomeOutputDirectory();
|
||||
// Make "rebuild-bff" target up-to-date after the generation.
|
||||
// This is actually a noop, it just asks CMake to touch the generated file
|
||||
// so FASTBuild would consider the target as up-to-date.
|
||||
AskCMakeToMakeRebuildBFFUpToDate(
|
||||
this->GetCMakeInstance()->GetHomeOutputDirectory());
|
||||
AskCMakeToMakeRebuildBFFUpToDate(workingDir);
|
||||
|
||||
if (this->GlobalSettingIsOn("CMAKE_EXPORT_COMPILE_COMMANDS")) {
|
||||
std::string output;
|
||||
ExecuteFastbuildTarget(workingDir, FASTBUILD_ALL_TARGET_NAME, output,
|
||||
{ "-compdb" });
|
||||
}
|
||||
}
|
||||
|
||||
void cmGlobalFastbuildGenerator::AskCMakeToMakeRebuildBFFUpToDate(
|
||||
|
||||
@@ -407,7 +407,7 @@ add_RunCMake_test(Configure -DMSVC_IDE=${MSVC_IDE})
|
||||
add_RunCMake_test(CpsExportImportBuild)
|
||||
add_RunCMake_test(CpsExportImportInstall)
|
||||
add_RunCMake_test(DisallowedCommands)
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
|
||||
if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja|FASTBuild")
|
||||
add_RunCMake_test(ExportCompileCommands)
|
||||
endif()
|
||||
add_RunCMake_test(ExcludeFromAll)
|
||||
|
||||
@@ -9,4 +9,7 @@ endif()
|
||||
run_cmake_with_options(BeforeProject -DCMAKE_PROJECT_INCLUDE_BEFORE=BeforeProjectBEFORE.cmake)
|
||||
run_cmake(CustomCompileRule)
|
||||
run_cmake(Properties)
|
||||
run_cmake(PropertiesGenerateCommand)
|
||||
|
||||
if(NOT RunCMake_GENERATOR STREQUAL "FASTBuild")
|
||||
run_cmake(PropertiesGenerateCommand)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user