summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorAaron Orenstein <aorenste@fb.com>2017-10-27 05:41:04 (GMT)
committerBrad King <brad.king@kitware.com>2017-11-17 15:25:41 (GMT)
commit4a6348dbbd35c51fabf01d517357129ed9480c85 (patch)
treeb38bcaa7a1416dd90f16a54651ea61cf0cfa1f1c /Source/cmake.cxx
parent1fe9e49bad0ad4f540ceda028106d9af89084946 (diff)
downloadCMake-4a6348dbbd35c51fabf01d517357129ed9480c85.zip
CMake-4a6348dbbd35c51fabf01d517357129ed9480c85.tar.gz
CMake-4a6348dbbd35c51fabf01d517357129ed9480c85.tar.bz2
Performance: Improve efficiency of source file lookup in cmMakefile
This reintroduces the change from commit v3.10.0-rc1~69^2 (Performance: Improve efficiency of source file lookup in cmMakefile, 2017-08-17) with some corrections. The original was rolled back by commit v3.10.0-rc1~52^2~1 (Revert "Performance: ...", 2017-09-25) due to incompatibilities found. The rollback was followed-up by addition of a test for the offending case, and this revision passes the test.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index fde77a7..2a5bb6c 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -200,6 +200,11 @@ cmake::cmake(Role role)
this->SourceFileExtensions.push_back("M");
this->SourceFileExtensions.push_back("mm");
+ std::copy(this->SourceFileExtensions.begin(),
+ this->SourceFileExtensions.end(),
+ std::inserter(this->SourceFileExtensionsSet,
+ this->SourceFileExtensionsSet.end()));
+
this->HeaderFileExtensions.push_back("h");
this->HeaderFileExtensions.push_back("hh");
this->HeaderFileExtensions.push_back("h++");
@@ -208,6 +213,11 @@ cmake::cmake(Role role)
this->HeaderFileExtensions.push_back("hxx");
this->HeaderFileExtensions.push_back("in");
this->HeaderFileExtensions.push_back("txx");
+
+ std::copy(this->HeaderFileExtensions.begin(),
+ this->HeaderFileExtensions.end(),
+ std::inserter(this->HeaderFileExtensionsSet,
+ this->HeaderFileExtensionsSet.end()));
}
cmake::~cmake()
@@ -1647,6 +1657,21 @@ void cmake::AddCacheEntry(const std::string& key, const char* value,
this->UnwatchUnusedCli(key);
}
+std::string cmake::StripExtension(const std::string& file) const
+{
+ auto dotpos = file.rfind('.');
+ if (dotpos != std::string::npos) {
+ auto ext = file.substr(dotpos + 1);
+#if defined(_WIN32) || defined(__APPLE__)
+ ext = cmSystemTools::LowerCase(ext);
+#endif
+ if (this->IsSourceExtension(ext) || this->IsHeaderExtension(ext)) {
+ return file.substr(0, dotpos);
+ }
+ }
+ return file;
+}
+
const char* cmake::GetCacheDefinition(const std::string& name) const
{
return this->State->GetInitializedCacheValue(name);