diff options
author | Brad King <brad.king@kitware.com> | 2018-01-29 13:05:17 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-01-29 13:05:27 (GMT) |
commit | 92cd3d06772ada13935790d66927ab4663c7d628 (patch) | |
tree | 2550a2ad9003b47f9029c186aeabdfd6521bc615 /Source/cmGlobalGenerator.cxx | |
parent | 18153217e27d2cf560d874313557ec9fa2bcffdb (diff) | |
parent | c85bb007df37aad9f20355cdf4d7ca9af562cb20 (diff) | |
download | CMake-92cd3d06772ada13935790d66927ab4663c7d628.zip CMake-92cd3d06772ada13935790d66927ab4663c7d628.tar.gz CMake-92cd3d06772ada13935790d66927ab4663c7d628.tar.bz2 |
Merge topic 'reduce-temporaries'
c85bb007 Reduce allocation of temporary values on heap.
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1698
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 99 |
1 files changed, 49 insertions, 50 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 59158b0..153684a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2294,9 +2294,8 @@ void cmGlobalGenerator::AddGlobalTarget_Package( singleLine.push_back(cmakeCfgIntDir); } singleLine.push_back("--config"); - std::string relConfigFile = "./CPackConfig.cmake"; - singleLine.push_back(relConfigFile); - gti.CommandLines.push_back(singleLine); + singleLine.push_back("./CPackConfig.cmake"); + gti.CommandLines.push_back(std::move(singleLine)); if (this->GetPreinstallTargetName()) { gti.Depends.push_back(this->GetPreinstallTargetName()); } else { @@ -2306,7 +2305,7 @@ void cmGlobalGenerator::AddGlobalTarget_Package( gti.Depends.push_back(this->GetAllTargetName()); } } - targets.push_back(gti); + targets.push_back(std::move(gti)); } void cmGlobalGenerator::AddGlobalTarget_PackageSource( @@ -2340,11 +2339,10 @@ void cmGlobalGenerator::AddGlobalTarget_PackageSource( cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCPackCommand()); singleLine.push_back("--config"); - std::string relConfigFile = "./CPackSourceConfig.cmake"; - singleLine.push_back(relConfigFile); - singleLine.push_back(configFile); - gti.CommandLines.push_back(singleLine); - targets.push_back(gti); + singleLine.push_back("./CPackSourceConfig.cmake"); + singleLine.push_back(std::move(configFile)); + gti.CommandLines.push_back(std::move(singleLine)); + targets.push_back(std::move(gti)); } void cmGlobalGenerator::AddGlobalTarget_Test( @@ -2379,58 +2377,59 @@ void cmGlobalGenerator::AddGlobalTarget_Test( { singleLine.push_back("$(ARGS)"); } - gti.CommandLines.push_back(singleLine); - targets.push_back(gti); + gti.CommandLines.push_back(std::move(singleLine)); + targets.push_back(std::move(gti)); } void cmGlobalGenerator::AddGlobalTarget_EditCache( std::vector<GlobalTargetInfo>& targets) { const char* editCacheTargetName = this->GetEditCacheTargetName(); - if (editCacheTargetName) { - GlobalTargetInfo gti; - gti.Name = editCacheTargetName; - cmCustomCommandLine singleLine; - - // Use generator preference for the edit_cache rule if it is defined. - std::string edit_cmd = this->GetEditCacheCommand(); - if (!edit_cmd.empty()) { - singleLine.push_back(edit_cmd); - singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); - singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); - gti.Message = "Running CMake cache editor..."; - gti.UsesTerminal = true; - gti.CommandLines.push_back(singleLine); - } else { - singleLine.push_back(cmSystemTools::GetCMakeCommand()); - singleLine.push_back("-E"); - singleLine.push_back("echo"); - singleLine.push_back("No interactive CMake dialog available."); - gti.Message = "No interactive CMake dialog available..."; - gti.UsesTerminal = false; - gti.CommandLines.push_back(singleLine); - } + if (!editCacheTargetName) { + return; + } + GlobalTargetInfo gti; + gti.Name = editCacheTargetName; + cmCustomCommandLine singleLine; - targets.push_back(gti); + // Use generator preference for the edit_cache rule if it is defined. + std::string edit_cmd = this->GetEditCacheCommand(); + if (!edit_cmd.empty()) { + singleLine.push_back(std::move(edit_cmd)); + singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); + singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); + gti.Message = "Running CMake cache editor..."; + gti.UsesTerminal = true; + } else { + singleLine.push_back(cmSystemTools::GetCMakeCommand()); + singleLine.push_back("-E"); + singleLine.push_back("echo"); + singleLine.push_back("No interactive CMake dialog available."); + gti.Message = "No interactive CMake dialog available..."; + gti.UsesTerminal = false; } + gti.CommandLines.push_back(std::move(singleLine)); + + targets.push_back(std::move(gti)); } void cmGlobalGenerator::AddGlobalTarget_RebuildCache( std::vector<GlobalTargetInfo>& targets) { const char* rebuildCacheTargetName = this->GetRebuildCacheTargetName(); - if (rebuildCacheTargetName) { - GlobalTargetInfo gti; - gti.Name = rebuildCacheTargetName; - gti.Message = "Running CMake to regenerate build system..."; - gti.UsesTerminal = true; - cmCustomCommandLine singleLine; - singleLine.push_back(cmSystemTools::GetCMakeCommand()); - singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); - singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); - gti.CommandLines.push_back(singleLine); - targets.push_back(gti); + if (!rebuildCacheTargetName) { + return; } + GlobalTargetInfo gti; + gti.Name = rebuildCacheTargetName; + gti.Message = "Running CMake to regenerate build system..."; + gti.UsesTerminal = true; + cmCustomCommandLine singleLine; + singleLine.push_back(cmSystemTools::GetCMakeCommand()); + singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); + singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); + gti.CommandLines.push_back(std::move(singleLine)); + targets.push_back(std::move(gti)); } void cmGlobalGenerator::AddGlobalTarget_Install( @@ -2458,7 +2457,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( gti.Name = "list_install_components"; gti.Message = ostr.str(); gti.UsesTerminal = false; - targets.push_back(gti); + targets.push_back(std::move(gti)); } std::string cmd = cmSystemTools::GetCMakeCommand(); GlobalTargetInfo gti; @@ -2512,7 +2511,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( localCmdLine.insert(localCmdLine.begin() + 1, "-DCMAKE_INSTALL_LOCAL_ONLY=1"); - gti.CommandLines.push_back(localCmdLine); + gti.CommandLines.push_back(std::move(localCmdLine)); targets.push_back(gti); } @@ -2528,7 +2527,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( stripCmdLine.insert(stripCmdLine.begin() + 1, "-DCMAKE_INSTALL_DO_STRIP=1"); - gti.CommandLines.push_back(stripCmdLine); + gti.CommandLines.push_back(std::move(stripCmdLine)); targets.push_back(gti); } } @@ -2972,7 +2971,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) std::vector<std::string> configs; target->Target->GetMakefile()->GetConfigurations(configs); if (configs.empty()) { - configs.push_back(""); + configs.emplace_back(); } for (std::string const& c : configs) { target->GetSourceFiles(sources, c); |