summaryrefslogtreecommitdiffstats
path: root/Source/cmake.h
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.h
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.h')
-rw-r--r--Source/cmake.h39
1 files changed, 14 insertions, 25 deletions
diff --git a/Source/cmake.h b/Source/cmake.h
index 086ec87..c5d608f 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -264,44 +264,33 @@ public:
this->GeneratorToolsetSet = true;
}
- const std::vector<std::string>& GetSourceExtensions() const
+ bool IsAKnownSourceExtension(cm::string_view ext) const
{
- return this->SourceFileExtensions.ordered;
+ return this->CLikeSourceFileExtensions.Test(ext) ||
+ this->CudaFileExtensions.Test(ext) ||
+ this->FortranFileExtensions.Test(ext);
}
- bool IsSourceExtension(cm::string_view ext) const
+ bool IsACLikeSourceExtension(cm::string_view ext) const
{
- return this->SourceFileExtensions.Test(ext);
+ return this->CLikeSourceFileExtensions.Test(ext);
}
- const std::vector<std::string>& GetHeaderExtensions() const
- {
- return this->HeaderFileExtensions.ordered;
- }
-
- bool IsHeaderExtension(cm::string_view ext) const
- {
- return this->HeaderFileExtensions.Test(ext);
- }
-
- const std::vector<std::string>& GetCudaExtensions() const
+ bool IsAKnownExtension(cm::string_view ext) const
{
- return this->CudaFileExtensions.ordered;
+ return this->IsAKnownSourceExtension(ext) || this->IsAHeaderExtension(ext);
}
- bool IsCudaExtension(cm::string_view ext) const
- {
- return this->CudaFileExtensions.Test(ext);
- }
+ std::vector<std::string> GetAllExtensions() const;
- const std::vector<std::string>& GetFortranExtensions() const
+ const std::vector<std::string>& GetHeaderExtensions() const
{
- return this->FortranFileExtensions.ordered;
+ return this->HeaderFileExtensions.ordered;
}
- bool IsFortranExtension(cm::string_view ext) const
+ bool IsAHeaderExtension(cm::string_view ext) const
{
- return this->FortranFileExtensions.Test(ext);
+ return this->HeaderFileExtensions.Test(ext);
}
// Strips the extension (if present and known) from a filename
@@ -628,7 +617,7 @@ private:
std::string CheckStampList;
std::string VSSolutionFile;
std::string EnvironmentGenerator;
- FileExtensions SourceFileExtensions;
+ FileExtensions CLikeSourceFileExtensions;
FileExtensions HeaderFileExtensions;
FileExtensions CudaFileExtensions;
FileExtensions FortranFileExtensions;