From 1ab3881ec9e809ac5f6cad5cd84048310b8683e2 Mon Sep 17 00:00:00 2001 From: Florian Maushart Date: Sat, 14 Apr 2018 22:50:19 +0200 Subject: cmake: Add options for parallel builds to --build mode While we already support `cmake --build . -- -j`, the options after `--` are specific to the native build tool. Add new options `--parallel []` and `-j []` to abstract this and map to the proper option for the native build tool. --- Source/cmGlobalJOMMakefileGenerator.cxx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Source/cmGlobalJOMMakefileGenerator.cxx') diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 18c45e0d86..0f41ea1482 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -52,3 +52,29 @@ void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice( } this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar); } + +void cmGlobalJOMMakefileGenerator::GenerateBuildCommand( + std::vector& makeCommand, const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, + int jobs, bool verbose, std::vector const& makeOptions) +{ + std::vector jomMakeOptions; + + // Since we have full control over the invocation of JOM, let us + // make it quiet. + jomMakeOptions.push_back(this->MakeSilentFlag); + jomMakeOptions.insert(jomMakeOptions.end(), makeOptions.begin(), + makeOptions.end()); + + // JOM does parallel builds by default, the -j is only needed if a specific + // number is given + // see https://github.com/qt-labs/jom/blob/v1.1.2/src/jomlib/options.cpp + if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) { + jobs = cmake::NO_BUILD_PARALLEL_LEVEL; + } + + cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( + makeCommand, makeProgram, projectName, projectDir, targetName, config, + fast, jobs, verbose, jomMakeOptions); +} -- cgit v1.2.1