From 8704525f201452929a2bec96fb04387c97ad8a79 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 14 Jan 2011 10:03:22 -0500 Subject: Reject directory names containing '=' (#11689) Some characters are not well-supported by native build systems. Reject paths containing such characters before even trying to configure a project. --- Source/cmake.cxx | 24 ++++++++++++++++++++++++ Source/cmake.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1b49837..bc3245e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1946,8 +1946,32 @@ int cmake::Configure() } +bool cmake::RejectUnsupportedPaths(const char* desc, std::string const& path) +{ + // Some characters are not well-supported by native build systems. + std::string::size_type pos = path.find_first_of("="); + if(pos == std::string::npos) + { + return false; + } + cmOStringStream e; + e << "The path to the " << desc << " directory:\n" + << " " << path << "\n" + << "contains unsupported character '" << path[pos] << "'.\n" + << "Please use a different " << desc << " directory name."; + cmListFileBacktrace bt; + this->IssueMessage(cmake::FATAL_ERROR, e.str(), bt); + return true; +} + int cmake::ActualConfigure() { + if(this->RejectUnsupportedPaths("source", this->cmHomeDirectory) || + this->RejectUnsupportedPaths("binary", this->HomeOutputDirectory)) + { + return 1; + } + // Construct right now our path conversion table before it's too late: this->UpdateConversionPathTable(); this->CleanupCommandsAndMacros(); diff --git a/Source/cmake.h b/Source/cmake.h index 435d38b..6744ca1 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -435,6 +435,8 @@ protected: ///! Find the full path to one of the cmake programs like ctest, cpack, etc. std::string FindCMakeProgram(const char* name) const; + + bool RejectUnsupportedPaths(const char* desc, std::string const& path); private: cmake(const cmake&); // Not implemented. void operator=(const cmake&); // Not implemented. -- cgit v0.12