diff options
author | Brad King <brad.king@kitware.com> | 2019-07-08 17:00:33 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-07-08 17:00:45 (GMT) |
commit | 80d9836a35cc72618cc79b27108d42c016b93a34 (patch) | |
tree | 00688d36c2dc0fae83e6eb42c5a3ad3f9ca10755 /Source/cmake.cxx | |
parent | 09fe6664afd2270d1d3b851adb4125b86bd59202 (diff) | |
parent | f8a310c9d141c750fd7747f8d7eecf1142231d6e (diff) | |
download | CMake-80d9836a35cc72618cc79b27108d42c016b93a34.zip CMake-80d9836a35cc72618cc79b27108d42c016b93a34.tar.gz CMake-80d9836a35cc72618cc79b27108d42c016b93a34.tar.bz2 |
Merge topic 'autogen_header_extension'
f8a310c9d1 cmSystemTools: Remove cmSystemTools::FileFormat method
90b5289c55 cmExtraCodeLiteGenerator: Use cmake::Is*Extension for file type detection
e50fa44a35 cmake: Refactor file extension list setup
8214ad442f Tests: Autogen: Extend SameName test with additional header extensions
4a9154537c Autogen: Use cmake::IsHeader/SourceExtension for file type detection
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3511
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8f2f86d..ca3b405 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -104,7 +104,6 @@ #include <cstring> #include <initializer_list> #include <iostream> -#include <iterator> #include <memory> // IWYU pragma: keep #include <sstream> #include <stdio.h> @@ -122,9 +121,9 @@ typedef std::unordered_map<std::string, Json::Value> JsonValueMapType; static bool cmakeCheckStampFile(const std::string& stampName); static bool cmakeCheckStampList(const std::string& stampList); -void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/, - void* ctx, const char* /*unused*/, - const cmMakefile* /*unused*/) +static void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/, + void* ctx, const char* /*unused*/, + const cmMakefile* /*unused*/) { cmake* cm = reinterpret_cast<cmake*>(ctx); cm->MarkCliAsUsed(variable); @@ -184,40 +183,36 @@ cmake::cmake(Role role, cmState::Mode mode) // Make sure we can capture the build tool output. cmSystemTools::EnableVSConsoleOutput(); - // Set up a list of source and header extensions - // these are used to find files when the extension - // is not given - // The "c" extension MUST precede the "C" extension. - this->SourceFileExtensions.emplace_back("c"); - this->SourceFileExtensions.emplace_back("C"); - - this->SourceFileExtensions.emplace_back("c++"); - this->SourceFileExtensions.emplace_back("cc"); - this->SourceFileExtensions.emplace_back("cpp"); - this->SourceFileExtensions.emplace_back("cxx"); - this->SourceFileExtensions.emplace_back("cu"); - this->SourceFileExtensions.emplace_back("m"); - this->SourceFileExtensions.emplace_back("M"); - this->SourceFileExtensions.emplace_back("mm"); - - std::copy(this->SourceFileExtensions.begin(), - this->SourceFileExtensions.end(), - std::inserter(this->SourceFileExtensionsSet, - this->SourceFileExtensionsSet.end())); - - this->HeaderFileExtensions.emplace_back("h"); - this->HeaderFileExtensions.emplace_back("hh"); - this->HeaderFileExtensions.emplace_back("h++"); - this->HeaderFileExtensions.emplace_back("hm"); - this->HeaderFileExtensions.emplace_back("hpp"); - this->HeaderFileExtensions.emplace_back("hxx"); - this->HeaderFileExtensions.emplace_back("in"); - this->HeaderFileExtensions.emplace_back("txx"); - - std::copy(this->HeaderFileExtensions.begin(), - this->HeaderFileExtensions.end(), - std::inserter(this->HeaderFileExtensionsSet, - this->HeaderFileExtensionsSet.end())); + // Set up a list of source and header extensions. + // These are used to find files when the extension is not given. + { + auto fillExts = [](FileExtensions& exts, + std::initializer_list<const char*> extList) { + // Fill ordered vector + exts.ordered.reserve(extList.size()); + for (const char* ext : extList) { + exts.ordered.emplace_back(ext); + }; + // Fill unordered set + exts.unordered.insert(exts.ordered.begin(), exts.ordered.end()); + }; + + // Source extensions + // The "c" extension MUST precede the "C" extension. + fillExts(this->SourceFileExtensions, + { "c", "C", "c++", "cc", "cpp", "cxx", "cu", "m", "M", "mm" }); + + // Header extensions + fillExts(this->HeaderFileExtensions, + { "h", "hh", "h++", "hm", "hpp", "hxx", "in", "txx" }); + + // Cuda extensions + fillExts(this->CudaFileExtensions, { "cu" }); + + // Fortran extensions + fillExts(this->FortranFileExtensions, + { "f", "F", "for", "f77", "f90", "f95", "f03" }); + } } cmake::~cmake() |