From c697c1fafef16f00e4ec6a72d12eb3a43c01879a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 9 Feb 2015 19:51:54 +0100 Subject: [PATCH 01/13] cmTarget: Remove template argument workaround. Pre-C++98 compilers required that the template argument be used in the function parameters. Those compilers are no longer supported as hosts, so drop the workaround. --- Help/manual/cmake-developer.7.rst | 28 ---------------------------- Source/cmTarget.cxx | 14 +++++--------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index e18250c6a..7bffa4253 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -28,34 +28,6 @@ Some implementations have a ``std::auto_ptr`` which can not be used as a return value from a function. ``std::auto_ptr`` may not be used. Use ``cmsys::auto_ptr`` instead. -Template Parameter Defaults ---------------------------- - -On ancient compilers, C++ template must use template parameters in function -arguments. If no parameter of that type is needed, the common workaround is -to add a defaulted pointer to the type to the templated function. However, -this does not work with other ancient compilers: - -.. code-block:: c++ - - template - PropertyType getTypedProperty(cmTarget* tgt, const char* prop, - PropertyType* = 0) // Wrong - { - - } - -.. code-block:: c++ - - template - PropertyType getTypedProperty(cmTarget* tgt, const char* prop, - PropertyType*) // Ok - { - - } - -and invoke it with the value ``0`` explicitly in all cases. - size_t ------ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 526a923f4..1ad0d486a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4711,13 +4711,11 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop, - PropertyType *); +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); //---------------------------------------------------------------------------- template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop, - bool *) +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) { return tgt->GetPropertyAsBool(prop); } @@ -4725,8 +4723,7 @@ bool getTypedProperty(cmTarget const* tgt, const std::string& prop, //---------------------------------------------------------------------------- template<> const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop, - const char **) + const std::string& prop) { return tgt->GetProperty(prop); } @@ -4937,8 +4934,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p, - 0); + PropertyType propContent = getTypedProperty(tgt, p); const bool explicitlySet = tgt->GetProperties() .find(p) != tgt->GetProperties().end(); @@ -4991,7 +4987,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, != theTarget->GetProperties().end(); PropertyType ifacePropContent = getTypedProperty(theTarget, - interfaceProperty, 0); + interfaceProperty); std::string reportEntry; if (ifaceIsSet) From 62429a1e54ec443edda35074bc66805d6e602f89 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 9 Feb 2015 20:00:19 +0100 Subject: [PATCH 02/13] cmGlobalGenerator: Remove unneeded pointer check. Deleting nullptr is ok. --- Source/cmGlobalGenerator.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6d0fedc16..227462d48 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -74,11 +74,7 @@ cmGlobalGenerator::cmGlobalGenerator() cmGlobalGenerator::~cmGlobalGenerator() { this->ClearGeneratorMembers(); - - if (this->ExtraGenerator) - { - delete this->ExtraGenerator; - } + delete this->ExtraGenerator; } bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p, From 1ee4721f7c7d0d889e00c0a2cdb799e71a4b5574 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 9 Feb 2015 20:01:46 +0100 Subject: [PATCH 03/13] Help: Fix formatting of command parameter. --- Help/command/target_compile_definitions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/command/target_compile_definitions.rst b/Help/command/target_compile_definitions.rst index 3c9fe8758..8bd323375 100644 --- a/Help/command/target_compile_definitions.rst +++ b/Help/command/target_compile_definitions.rst @@ -9,7 +9,7 @@ Add compile definitions to a target. [items1...] [ [items2...] ...]) -Specify compile definitions to use when compiling a given ``. The named ```` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`Imported Target `. From 0550b9e330d75dfcb02257c998706759574cd9c0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 1 Jan 2015 13:41:48 +0100 Subject: [PATCH 04/13] Revert "Attempt to fix the compile of cmake on Sun CC." This reverts commit a573a856581118d7a9d8dd7be1f613ba7b1ddb04. The workaround is not needed on supported SolarisStudio compilers. --- Source/cmGeneratorExpressionEvaluator.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 6692a9265..ba18faabb 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -24,10 +24,7 @@ #include //---------------------------------------------------------------------------- -#if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510 -static -#endif -void reportError(cmGeneratorExpressionContext *context, +static void reportError(cmGeneratorExpressionContext *context, const std::string &expr, const std::string &result) { context->HadError = true; From 6010f93632c8de9405bc97e40fc06f5949c09976 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 1 Jan 2015 13:41:54 +0100 Subject: [PATCH 05/13] Revert "cmGlobalGenerator: Fix value type pushed into autogens vector" This reverts commit ae6fc555a7e8929f6d96545bd1137c8bd378566d. Use the more-natural make_pair algorithm. The compiler motivating the need for this is not supported as a host anymore. --- Source/cmGlobalGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 227462d48..1de4a5976 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1387,7 +1387,7 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) cmQtAutoGenerators autogen; if(autogen.InitializeAutogenTarget(&target)) { - autogens.push_back(AutogensType::value_type(autogen, &target)); + autogens.push_back(std::make_pair(autogen, &target)); } } } From cfb8483412761e567f64343ccc008b44150a901b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 9 Feb 2015 19:48:21 +0100 Subject: [PATCH 06/13] Update comment to match recent dashboard testing. --- Source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8a83c3e3d..69bc2a1b6 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -520,8 +520,8 @@ if(APPLE) target_link_libraries(CMakeLib "-framework CoreFoundation") endif() -# On some platforms we need the rpcrt4 library for the VS 7 generators. if(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) + # We need the rpcrt4 library for at least the VS7-VC10 generators. target_link_libraries(CMakeLib rpcrt4) endif() From 26602cf56c4697a589f320809afa7a127268d09f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 9 Feb 2015 08:08:26 +0100 Subject: [PATCH 07/13] cmLocalGenerator: Move variable population inside of condition. It is only used in the condition, so no need to look for uses elsewhere when reading the code. --- Source/cmLocalGenerator.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 35956aded..6a6135b78 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1952,14 +1952,13 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, // Write the library flags to the build rule. fout << linkLibs; - // Get the RPATH entries. - std::vector runtimeDirs; - cli.GetRPath(runtimeDirs, relink); - // Check what kind of rpath flags to use. if(cli.GetRuntimeSep().empty()) { // Each rpath entry gets its own option ("-R a -R b -R c") + std::vector runtimeDirs; + cli.GetRPath(runtimeDirs, relink); + std::string rpath; for(std::vector::iterator ri = runtimeDirs.begin(); ri != runtimeDirs.end(); ++ri) From 2d833232a35715e412a40ee6207137ecfee7da36 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 12 Feb 2015 21:03:34 +0100 Subject: [PATCH 08/13] cmCoreTryCompile: Remove variable assignment. The variable is not a reference, and we return in the same scope after assigning, so it has no effect. --- Source/cmCoreTryCompile.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index d9369e6e7..8e20c14e8 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -685,8 +685,7 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName) command += tmpOutputFile; if(cmSystemTools::FileExists(command.c_str())) { - tmpOutputFile = cmSystemTools::CollapseFullPath(command); - this->OutputFile = tmpOutputFile; + this->OutputFile = cmSystemTools::CollapseFullPath(command); return; } } From 2acd04c96624ce530edcb0ca991bddad7f70023e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 12 Feb 2015 22:14:08 +0100 Subject: [PATCH 09/13] cmcmd: Remove some comment copy-pasta. --- Source/cmcmd.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 5c9397519..6a7dc6ea5 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -287,8 +287,6 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) } #if defined(CMAKE_BUILD_WITH_CMAKE) - // Command to create a symbolic link. Fails on platforms not - // supporting them. else if (args[1] == "environment" ) { std::vector env = cmSystemTools::GetEnvironmentVariables(); @@ -352,8 +350,6 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { for (std::string::size_type cc = 2; cc < args.size(); cc ++) { - // Complain if the file could not be removed, still exists, - // and the -f option was not given. if(!cmSystemTools::Touch(args[cc], true)) { return 1; From 74906322585034968142e1d1663f604e2c97332c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 17 Feb 2015 09:02:03 +0100 Subject: [PATCH 10/13] cmAlgorithms: Remove sort of already-sorted container. The indices is populated by an increasing number. --- Source/cmAlgorithms.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index a9960880f..dc4f2758a 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -275,7 +275,6 @@ typename Range::const_iterator cmRemoveDuplicates(Range& r) { return r.end(); } - std::sort(indices.begin(), indices.end()); return cmRemoveIndices(r, indices); } From 10e53e230811b94701d86e8c78e38df5abf69ee8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 17 Feb 2015 19:32:52 +0100 Subject: [PATCH 11/13] cmAlgorithms: Add missing const to functors. --- Source/cmAlgorithms.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index dc4f2758a..8491838e5 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -99,7 +99,7 @@ template::value> struct DefaultDeleter { - void operator()(typename Container::value_type value) { + void operator()(typename Container::value_type value) const { delete value; } }; @@ -107,7 +107,7 @@ struct DefaultDeleter template struct DefaultDeleter { - void operator()(typename Container::value_type value) { + void operator()(typename Container::value_type value) const { delete value.second; } }; @@ -163,7 +163,7 @@ struct BinarySearcher { } - bool operator()(argument_type const& item) + bool operator()(argument_type const& item) const { return std::binary_search(m_range.begin(), m_range.end(), item); } From 75661fdfd94fef4b8f1e8112aa75d76d1cc366e6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 25 Jan 2015 15:20:56 +0100 Subject: [PATCH 12/13] cmListCommand: Move size variable out of loop. Re-use it where possible in two instances. --- Source/cmListCommand.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 98dcef109..0c6adfd11 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -202,12 +202,12 @@ bool cmListCommand::HandleGetCommand(std::vector const& args) std::string value; size_t cc; const char* sep = ""; + size_t nitem = varArgsExpanded.size(); for ( cc = 2; cc < args.size()-1; cc ++ ) { int item = atoi(args[cc].c_str()); value += sep; sep = ";"; - size_t nitem = varArgsExpanded.size(); if ( item < 0 ) { item = (int)nitem + item; @@ -216,8 +216,8 @@ bool cmListCommand::HandleGetCommand(std::vector const& args) { std::ostringstream str; str << "index: " << item << " out of range (-" - << varArgsExpanded.size() << ", " - << varArgsExpanded.size()-1 << ")"; + << nitem << ", " + << nitem - 1 << ")"; this->SetError(str.str()); return false; } @@ -485,10 +485,10 @@ bool cmListCommand::HandleRemoveAtCommand( size_t cc; std::vector removed; + size_t nitem = varArgsExpanded.size(); for ( cc = 2; cc < args.size(); ++ cc ) { int item = atoi(args[cc].c_str()); - size_t nitem = varArgsExpanded.size(); if ( item < 0 ) { item = (int)nitem + item; @@ -497,8 +497,8 @@ bool cmListCommand::HandleRemoveAtCommand( { std::ostringstream str; str << "index: " << item << " out of range (-" - << varArgsExpanded.size() << ", " - << varArgsExpanded.size()-1 << ")"; + << nitem << ", " + << nitem - 1 << ")"; this->SetError(str.str()); return false; } From 6652afe66961bcbb5ff17dd7b8a3a91da62f2712 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 15 Feb 2015 13:42:17 +0100 Subject: [PATCH 13/13] CTest: Use clear instead of erase-all. --- Source/CTest/cmCTestBuildAndTestHandler.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index d90aeb7b5..4cdce71b7 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -32,8 +32,7 @@ cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() //---------------------------------------------------------------------- void cmCTestBuildAndTestHandler::Initialize() { - this->BuildTargets.erase( - this->BuildTargets.begin(), this->BuildTargets.end()); + this->BuildTargets.clear(); this->Superclass::Initialize(); }