FASTbuild: allow setting custom IDE args

Allow users to set custom args
when FBuild is invoked via IDE.
This commit is contained in:
Eduard Voronkin
2025-10-16 16:21:54 -07:00
committed by Brad King
parent 4b5233e3e7
commit 31b51340a1
5 changed files with 47 additions and 14 deletions

View File

@@ -67,6 +67,7 @@ The following variables can be used to configure this generator:
* :variable:`CMAKE_FASTBUILD_CACHE_PATH`
* :variable:`CMAKE_FASTBUILD_CAPTURE_SYSTEM_ENV`
* :variable:`CMAKE_FASTBUILD_ENV_OVERRIDES`
* :variable:`CMAKE_FASTBUILD_IDE_ARGS`
* :variable:`CMAKE_FASTBUILD_TRACK_BYPRODUCTS_AS_OUTPUT`
* :variable:`CMAKE_FASTBUILD_VERBOSE_GENERATOR`

View File

@@ -65,6 +65,7 @@ Variables that Provide Information
/variable/CMAKE_FASTBUILD_CLANG_GCC_UPDATE_XLANG_ARG
/variable/CMAKE_FASTBUILD_CLANG_REWRITE_INCLUDES
/variable/CMAKE_FASTBUILD_FORCE_RESPONSE_FILE
/variable/CMAKE_FASTBUILD_IDE_ARGS
/variable/CMAKE_FASTBUILD_SOURCE_MAPPING
/variable/CMAKE_FASTBUILD_USE_DETERMINISTIC_PATHS
/variable/CMAKE_FASTBUILD_USE_LIGHTCACHE

View File

@@ -0,0 +1,17 @@
CMAKE_FASTBUILD_IDE_ARGS
------------------------
.. versionadded:: 4.2
Specifies the command-line arguments used when invoking ``fbuild`` from IDE
projects.
If not set, the following arguments are used::
-ide -cache -summary -dist
Example:
.. code-block:: cmake
set(CMAKE_FASTBUILD_IDE_ARGS "-ide -cache -summary -dist -clean")

View File

@@ -55,7 +55,7 @@ class cmLinkLineComputer;
#define FASTBUILD_VS_BASE_PATH "VisualStudio/Projects"
#define FASTBUILD_IDE_VS_COMMAND_PREFIX "cd ^$(SolutionDir).. && "
#define FASTBUILD_IDE_BUILD_ARGS " -ide -cache -summary -dist "
#define FASTBUILD_DEFAULT_IDE_BUILD_ARGS " -ide -cache -summary -dist "
constexpr auto FASTBUILD_CAPTURE_SYSTEM_ENV =
"CMAKE_FASTBUILD_CAPTURE_SYSTEM_ENV";
@@ -83,6 +83,8 @@ constexpr auto FASTBUILD_ALLOW_RESPONSE_FILE =
constexpr auto FASTBUILD_FORCE_RESPONSE_FILE =
"CMAKE_FASTBUILD_FORCE_RESPONSE_FILE";
constexpr auto FASTBUILD_IDE_ARGS = "CMAKE_FASTBUILD_IDE_ARGS";
static std::map<std::string, std::string> const compilerIdToFastbuildFamily = {
{ "MSVC", "msvc" }, { "Clang", "clang" }, { "AppleClang", "clang" },
{ "GNU", "gcc" }, { "NVIDIA", "cuda-nvcc" }, { "Clang-cl", "clang-cl" },
@@ -1451,28 +1453,39 @@ void cmGlobalFastbuildGenerator::WriteIDEProjects()
#endif
}
std::string cmGlobalFastbuildGenerator::GetIDEBuildArgs() const
{
cmValue const ideArgs = this->GetGlobalSetting(FASTBUILD_IDE_ARGS);
if (ideArgs) {
return cmStrCat(' ', ideArgs, ' ');
}
return FASTBUILD_DEFAULT_IDE_BUILD_ARGS;
}
void cmGlobalFastbuildGenerator::WriteVSBuildCommands()
{
WriteVariable("ProjectBuildCommand",
Quote(FASTBUILD_IDE_VS_COMMAND_PREFIX +
this->FastbuildCommand +
FASTBUILD_IDE_BUILD_ARGS " ^$(ProjectName)"),
1);
WriteVariable("ProjectRebuildCommand",
Quote(FASTBUILD_IDE_VS_COMMAND_PREFIX +
this->FastbuildCommand +
FASTBUILD_IDE_BUILD_ARGS "-clean ^$(ProjectName)"),
1);
std::string const ideArgs = this->GetIDEBuildArgs();
WriteVariable(
"ProjectBuildCommand",
Quote(cmStrCat(FASTBUILD_IDE_VS_COMMAND_PREFIX, this->FastbuildCommand,
ideArgs, " ^$(ProjectName)")),
1);
WriteVariable(
"ProjectRebuildCommand",
Quote(cmStrCat(FASTBUILD_IDE_VS_COMMAND_PREFIX, this->FastbuildCommand,
ideArgs, "-clean ^$(ProjectName)")),
1);
WriteVariable("ProjectCleanCommand",
Quote(FASTBUILD_IDE_VS_COMMAND_PREFIX +
this->FastbuildCommand + " -ide clean"),
Quote(cmStrCat(FASTBUILD_IDE_VS_COMMAND_PREFIX,
this->FastbuildCommand, ideArgs, " clean")),
1);
}
void cmGlobalFastbuildGenerator::WriteXCodeBuildCommands()
{
std::string const ideArgs = this->GetIDEBuildArgs();
WriteVariable("XCodeBuildToolPath", Quote(this->FastbuildCommand), 1);
WriteVariable("XCodeBuildToolArgs",
Quote(FASTBUILD_IDE_BUILD_ARGS "^$(FASTBUILD_TARGET)"), 1);
Quote(cmStrCat(ideArgs, "^$(FASTBUILD_TARGET)")), 1);
WriteVariable("XCodeBuildWorkingDir",
Quote(this->CMakeInstance->GetHomeOutputDirectory()), 1);
}

View File

@@ -530,6 +530,7 @@ public:
void WriteCopy(FastbuildCopyNode const& Copy);
void WriteIDEProjects();
std::string GetIDEBuildArgs() const;
void WriteVSBuildCommands();
void WriteXCodeBuildCommands();
void WriteIDEProjectCommon(IDEProjectCommon const& project);