summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio10Generator.cxx
diff options
context:
space:
mode:
authorFlorian Maushart <FloriansGit@online.ms>2018-04-14 20:50:19 (GMT)
committerBrad King <brad.king@kitware.com>2018-05-25 13:42:20 (GMT)
commit1ab3881ec9e809ac5f6cad5cd84048310b8683e2 (patch)
tree2b5c7c5a9ad2e38a584de50b5f019056883c3877 /Source/cmGlobalVisualStudio10Generator.cxx
parentdfc692342831186053bd385605c8a21239e2e77d (diff)
downloadCMake-1ab3881ec9e809ac5f6cad5cd84048310b8683e2.zip
CMake-1ab3881ec9e809ac5f6cad5cd84048310b8683e2.tar.gz
CMake-1ab3881ec9e809ac5f6cad5cd84048310b8683e2.tar.bz2
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 [<N>]` and `-j [<N>]` to abstract this and map to the proper option for the native build tool.
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 205e0d0..51e9ab1 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -764,7 +764,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
std::vector<std::string>& makeCommand, const std::string& makeProgram,
const std::string& projectName, const std::string& projectDir,
const std::string& targetName, const std::string& config, bool fast,
- bool verbose, std::vector<std::string> const& makeOptions)
+ int jobs, bool verbose, std::vector<std::string> const& makeOptions)
{
// Select the caller- or user-preferred make program, else MSBuild.
std::string makeProgramSelected =
@@ -805,7 +805,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
// Use devenv to build solutions containing Intel Fortran projects.
cmGlobalVisualStudio7Generator::GenerateBuildCommand(
makeCommand, makeProgram, projectName, projectDir, targetName, config,
- fast, verbose, makeOptions);
+ fast, jobs, verbose, makeOptions);
return;
}
@@ -813,6 +813,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
std::string realTarget = targetName;
// msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
+ // /m
if (realTarget.empty()) {
realTarget = "ALL_BUILD";
}
@@ -841,6 +842,17 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
makeCommand.push_back(configArg);
makeCommand.push_back(std::string("/p:VisualStudioVersion=") +
this->GetIDEVersion());
+
+ if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
+ if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
+ makeCommand.push_back("/m");
+ } else {
+ makeCommand.push_back(std::string("/m:") + std::to_string(jobs));
+ }
+ // Having msbuild.exe and cl.exe using multiple jobs is discouraged
+ makeCommand.push_back("/p:CL_MPCount=1");
+ }
+
makeCommand.insert(makeCommand.end(), makeOptions.begin(),
makeOptions.end());
}