From 9401cb4c3fd6b186b2b4e6bab53ee72acb73d172 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Tue, 21 Dec 2021 13:15:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B4=D1=81=D0=B2=D0=B5=D1=82?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B2=20?= =?UTF-8?q?=D1=82=D0=B5=D1=80=D0=BC=D0=B8=D0=BD=D0=B0=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/MyxCMakeColoredMessages.cmake | 39 +++++++++++++++++++ MyxCMake/modules/MyxCMakeCommon.cmake | 1 + MyxCMake/modules/MyxCMakeCompilerFlags.cmake | 4 +- MyxCMake/modules/MyxCMakeDistCC.cmake | 12 +++--- 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 MyxCMake/modules/MyxCMakeColoredMessages.cmake diff --git a/MyxCMake/modules/MyxCMakeColoredMessages.cmake b/MyxCMake/modules/MyxCMakeColoredMessages.cmake new file mode 100644 index 0000000..95da001 --- /dev/null +++ b/MyxCMake/modules/MyxCMakeColoredMessages.cmake @@ -0,0 +1,39 @@ +if(DEFINED ENV{TERM} AND UNIX) + string(ASCII 27 Esc) + set(MyxCMakeColorReset "${Esc}[m") + set(MyxCMakeColorBold "${Esc}[1m") + set(MyxCMakeColorRed "${Esc}[31m") + set(MyxCMakeColorGreen "${Esc}[32m") + set(MyxCMakeColorYellow "${Esc}[33m") + set(MyxCMakeColorBlue "${Esc}[34m") + set(MyxCMakeColorMagenta "${Esc}[35m") + set(MyxCMakeColorCyan "${Esc}[36m") + set(MyxCMakeColorWhite "${Esc}[37m") + set(MyxCMakeColorBoldRed "${Esc}[1;31m") + set(MyxCMakeColorBoldGreen "${Esc}[1;32m") + set(MyxCMakeColorBoldYellow "${Esc}[1;33m") + set(MyxCMakeColorBoldBlue "${Esc}[1;34m") + set(MyxCMakeColorBoldMagenta "${Esc}[1;35m") + set(MyxCMakeColorBoldCyan "${Esc}[1;36m") + set(MyxCMakeColorBoldWhite "${Esc}[1;37m") +endif() + +function(myx_cmake_message_error) + message(FATAL_ERROR ${MyxCMakeColorBoldRed}${ARGV}${MyxCMakeColorReset}) +endfunction() + +function(myx_cmake_message_warning) + message(WARNING ${MyxCMakeColorRed}${ARGV}${MyxCMakeColorReset}) +endfunction() + +function(myx_cmake_message_status) + message(STATUS ${MyxCMakeColorMagenta}${ARGV}${MyxCMakeColorReset}) +endfunction() + +function(myx_cmake_message_notice) + message(STATUS ${MyxCMakeColorBold}${ARGV}${MyxCMakeColorReset}) +endfunction() + +function(myx_cmake_message) + message(${MyxCMakeColorReset}${ARGV}${MyxCMakeColorReset}) +endfunction() diff --git a/MyxCMake/modules/MyxCMakeCommon.cmake b/MyxCMake/modules/MyxCMakeCommon.cmake index 6f7a014..7f2b2bd 100644 --- a/MyxCMake/modules/MyxCMakeCommon.cmake +++ b/MyxCMake/modules/MyxCMakeCommon.cmake @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) include(GNUInstallDirs) +include(MyxCMakeColoredMessages) include(MyxCMakeCheckPaths) link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) diff --git a/MyxCMake/modules/MyxCMakeCompilerFlags.cmake b/MyxCMake/modules/MyxCMakeCompilerFlags.cmake index a498944..cadad3f 100644 --- a/MyxCMake/modules/MyxCMakeCompilerFlags.cmake +++ b/MyxCMake/modules/MyxCMakeCompilerFlags.cmake @@ -8,11 +8,11 @@ macro(CHECK_ENABLE_CXX_FLAG flag) unset(CMAKE_REQUIRED_QUIET) if(CHECK_CXX_FLAG) - message(STATUS "'${flag}': flag is supported.") + myx_cmake_message_notice("'${flag}': flag is supported.") string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS "${_MYX_CMAKE_DETECTED_CXX_FLAGS} ${flag}") else() - message(STATUS "'${flag}': flag is NOT supported.") + myx_cmake_message_status("'${flag}': flag is NOT supported.") endif() # NOTE: check_cxx_compiler stores variables in the cache. unset(CHECK_CXX_FLAG CACHE) diff --git a/MyxCMake/modules/MyxCMakeDistCC.cmake b/MyxCMake/modules/MyxCMakeDistCC.cmake index 4b0b193..4c11b37 100644 --- a/MyxCMake/modules/MyxCMakeDistCC.cmake +++ b/MyxCMake/modules/MyxCMakeDistCC.cmake @@ -2,12 +2,12 @@ find_program(DISTCC_EXECUTABLE distcc) mark_as_advanced(DISTCC_EXECUTABLE) if(DISTCC_EXECUTABLE) foreach(lang C CXX) - if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER - AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/distcc$") - message(STATUS "MyxCMake: distcc enabled for ${lang}") - set(CMAKE_${lang}_COMPILER_LAUNCHER - ${DISTCC_EXECUTABLE} - CACHE STRING "") + # cmake-format: off + if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND + NOT CMAKE_${lang}_COMPILER MATCHES ".*/distcc$") + myx_cmake_message("MyxCMake: distcc enabled for ${lang}") + set(CMAKE_${lang}_COMPILER_LAUNCHER ${DISTCC_EXECUTABLE} CACHE STRING "") endif() + # cmake-format: on endforeach() endif()