diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 58885d3b9..042fabeeb 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -406,6 +406,7 @@ std::vector cmState::GetCommandNames() const void cmState::RemoveUserDefinedCommands() { + std::vector renamedCommands; for(std::map::iterator j = this->Commands.begin(); j != this->Commands.end(); ) { @@ -415,11 +416,21 @@ void cmState::RemoveUserDefinedCommands() delete j->second; this->Commands.erase(j++); } + else if (j->first != j->second->GetName()) + { + renamedCommands.push_back(j->second); + this->Commands.erase(j++); + } else { ++j; } } + for (std::vector::const_iterator it = renamedCommands.begin(); + it != renamedCommands.end(); ++it) + { + this->Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it; + } } void cmState::SetGlobalProperty(const std::string& prop, const char* value) diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 5e5eead80..9251ff37d 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -4,6 +4,13 @@ cmake_minimum_required(VERSION 2.4) project (Complex) +# Test that renaming a built-in works when configured multiple times. +message("message") +function(message) + _message(${ARGN}) +endfunction() +message("message") + # Try setting a new policy. The IF test is for coverage. if(POLICY CMP0003) cmake_policy(SET CMP0003 NEW)