diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesColor.cxx | 59 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesColor.h | 5 | ||||
-rw-r--r-- | Source/CursesDialog/cmCursesOptionsWidget.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 2 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 5 |
6 files changed, 65 insertions, 12 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f376bd4..ed86054 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 17) -set(CMake_VERSION_PATCH 20200427) +set(CMake_VERSION_PATCH 20200428) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CursesDialog/cmCursesColor.cxx b/Source/CursesDialog/cmCursesColor.cxx index 641d48c..c0b468b 100644 --- a/Source/CursesDialog/cmCursesColor.cxx +++ b/Source/CursesDialog/cmCursesColor.cxx @@ -2,6 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCursesColor.h" +#include <cctype> +#include <cstdlib> +#include <cstring> +#include <unordered_map> +#include <utility> + #include "cmCursesStandardIncludes.h" bool cmCursesColor::HasColors() @@ -19,11 +25,54 @@ void cmCursesColor::InitColors() if (HasColors()) { start_color(); use_default_colors(); - init_pair(cmCursesColor::BoolOff, COLOR_RED, -1); - init_pair(cmCursesColor::BoolOn, COLOR_GREEN, -1); - init_pair(cmCursesColor::String, COLOR_BLUE, -1); - init_pair(cmCursesColor::Path, COLOR_YELLOW, -1); - init_pair(cmCursesColor::Options, COLOR_MAGENTA, -1); + init_pair(BoolOff, GetColor('N', COLOR_RED), -1); + init_pair(BoolOn, GetColor('Y', COLOR_GREEN), -1); + init_pair(String, GetColor('S', COLOR_CYAN), -1); + init_pair(Path, GetColor('P', COLOR_YELLOW), -1); + init_pair(Choice, GetColor('C', COLOR_MAGENTA), -1); } #endif } + +short cmCursesColor::GetColor(char id, short fallback) +{ + static bool initialized = false; + static std::unordered_map<char, short> env; + + if (!initialized) { + if (auto* v = getenv("CCMAKE_COLORS")) { + while (v[0] && v[1] && v[1] == '=') { + auto const n = std::toupper(*v); + + char buffer[12]; + memset(buffer, 0, sizeof(buffer)); + + if (auto* const e = strchr(v, ':')) { + if (static_cast<size_t>(e - v) > sizeof(buffer)) { + break; + } + + strncpy(buffer, v + 2, static_cast<size_t>(e - v - 2)); + v = e + 1; + } else { + auto const l = strlen(v); + if (l > sizeof(buffer)) { + break; + } + + strncpy(buffer, v + 2, l - 2); + v += l; + } + + auto const c = atoi(buffer); + if (c && c < COLORS) { + env.emplace(n, static_cast<short>(c)); + } + } + } + initialized = true; + } + + auto const iter = env.find(id); + return (iter == env.end() ? fallback : iter->second); +} diff --git a/Source/CursesDialog/cmCursesColor.h b/Source/CursesDialog/cmCursesColor.h index 78ca52c..f83265f 100644 --- a/Source/CursesDialog/cmCursesColor.h +++ b/Source/CursesDialog/cmCursesColor.h @@ -13,12 +13,15 @@ public: BoolOn, String, Path, - Options + Choice }; static bool HasColors(); static void InitColors(); + +protected: + static short GetColor(char id, short fallback); }; #endif // cmCursesColor_h diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx index a15241f..8df32e2 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.cxx +++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx @@ -17,8 +17,8 @@ cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left, // the widget into a string widget at some point. BOOL is safe for // now. if (cmCursesColor::HasColors()) { - set_field_fore(this->Field, COLOR_PAIR(cmCursesColor::Options)); - set_field_back(this->Field, COLOR_PAIR(cmCursesColor::Options)); + set_field_fore(this->Field, COLOR_PAIR(cmCursesColor::Choice)); + set_field_back(this->Field, COLOR_PAIR(cmCursesColor::Choice)); } else { set_field_fore(this->Field, A_NORMAL); set_field_back(this->Field, A_STANDOUT); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index aa8912e..1401e29 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1442,7 +1442,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // Create the scanner for this language std::unique_ptr<cmDepends> scanner; if (lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM" || - lang == "CUDA") { + lang == "OBJC" || lang == "OBJCXX" || lang == "CUDA") { // TODO: Handle RC (resource files) dependencies correctly. scanner = cm::make_unique<cmDependsC>(this, targetDir, lang, &validDeps); } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b21946c..267d5e1 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -724,8 +724,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // At the moment, it is assumed that C, C++, Fortran, and CUDA have both // assembly and preprocessor capabilities. The same is true for the // ability to export compile commands - bool lang_has_preprocessor = ((lang == "C") || (lang == "CXX") || - (lang == "Fortran") || (lang == "CUDA")); + bool lang_has_preprocessor = + ((lang == "C") || (lang == "CXX") || (lang == "OBJC") || + (lang == "OBJCXX") || (lang == "Fortran") || (lang == "CUDA")); bool const lang_has_assembly = lang_has_preprocessor; bool const lang_can_export_cmds = lang_has_preprocessor; |