summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-06-15 13:23:49 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2020-06-22 13:13:16 (GMT)
commit7628153edb74ef29e3322fd4163754e301b9cb9a (patch)
treed2c66602ea5185b4667b40d02af9306d3b0c4929 /Source/cmake.cxx
parent6f7853cb42b75715d38a71bce3123390b78a502a (diff)
downloadCMake-7628153edb74ef29e3322fd4163754e301b9cb9a.zip
CMake-7628153edb74ef29e3322fd4163754e301b9cb9a.tar.gz
CMake-7628153edb74ef29e3322fd4163754e301b9cb9a.tar.bz2
Refactor file extension queries to be more consistent
It was very easy to forgot to check against all language file extensions. This updates the internal API to have a unified API.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 62a7fcb..27ecb4d 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -194,7 +194,7 @@ cmake::cmake(Role role, cmState::Mode mode)
};
// The "c" extension MUST precede the "C" extension.
- setupExts(this->SourceFileExtensions,
+ setupExts(this->CLikeSourceFileExtensions,
{ "c", "C", "c++", "cc", "cpp", "cxx", "cu", "m", "M", "mm" });
setupExts(this->HeaderFileExtensions,
{ "h", "hh", "h++", "hm", "hpp", "hxx", "in", "txx" });
@@ -1959,6 +1959,17 @@ void cmake::AddGlobCacheEntry(bool recurse, bool listDirectories,
backtrace);
}
+std::vector<std::string> cmake::GetAllExtensions() const
+{
+ std::vector<std::string> allExt = this->CLikeSourceFileExtensions.ordered;
+ allExt.insert(allExt.end(), this->HeaderFileExtensions.ordered.begin(),
+ this->HeaderFileExtensions.ordered.end());
+ // cuda extensions are also in SourceFileExtensions so we ignore it here
+ allExt.insert(allExt.end(), this->FortranFileExtensions.ordered.begin(),
+ this->FortranFileExtensions.ordered.end());
+ return allExt;
+}
+
std::string cmake::StripExtension(const std::string& file) const
{
auto dotpos = file.rfind('.');
@@ -1968,7 +1979,7 @@ std::string cmake::StripExtension(const std::string& file) const
#else
auto ext = cm::string_view(file).substr(dotpos + 1);
#endif
- if (this->IsSourceExtension(ext) || this->IsHeaderExtension(ext)) {
+ if (this->IsAKnownExtension(ext)) {
return file.substr(0, dotpos);
}
}