Подсветка сообщений

This commit is contained in:
Andrei Astafev 2021-12-21 13:45:09 +03:00
parent 42db4201e7
commit 5b6ed5b79b
12 changed files with 33 additions and 48 deletions

View File

@ -5,7 +5,7 @@ get_filename_component(MYX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
set(MYX_CMAKE_FUNCTIONS_DIR "${MYX_CMAKE_DIR}/functions") set(MYX_CMAKE_FUNCTIONS_DIR "${MYX_CMAKE_DIR}/functions")
if(NOT IS_DIRECTORY "${MYX_CMAKE_FUNCTIONS_DIR}") if(NOT IS_DIRECTORY "${MYX_CMAKE_FUNCTIONS_DIR}")
message(STATUS "MyxCMake: Functions directory is not found.") myx_cmake_message_warning("MyxCMake: Functions directory is not found.")
else() else()
if(NOT ${MYX_CMAKE_FUNCTIONS_DIR} IN_LIST CMAKE_MODULE_PATH) if(NOT ${MYX_CMAKE_FUNCTIONS_DIR} IN_LIST CMAKE_MODULE_PATH)
list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_FUNCTIONS_DIR}") list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_FUNCTIONS_DIR}")
@ -14,7 +14,7 @@ endif()
set(MYX_CMAKE_THIRDPARTY_DIR "${MYX_CMAKE_DIR}/thirdparty") set(MYX_CMAKE_THIRDPARTY_DIR "${MYX_CMAKE_DIR}/thirdparty")
if(NOT IS_DIRECTORY "${MYX_CMAKE_THIRDPARTY_DIR}") if(NOT IS_DIRECTORY "${MYX_CMAKE_THIRDPARTY_DIR}")
message(STATUS "MyxCMake: Thirdparty submodule is not found.") myx_cmake_message_warning("MyxCMake: Thirdparty submodule is not found.")
else() else()
if(NOT ${MYX_CMAKE_THIRDPARTY_DIR} IN_LIST CMAKE_MODULE_PATH) if(NOT ${MYX_CMAKE_THIRDPARTY_DIR} IN_LIST CMAKE_MODULE_PATH)
list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_THIRDPARTY_DIR}") list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_THIRDPARTY_DIR}")
@ -23,7 +23,7 @@ endif()
set(MYX_CMAKE_SANITIZERS_DIR "${MYX_CMAKE_DIR}/sanitizers") set(MYX_CMAKE_SANITIZERS_DIR "${MYX_CMAKE_DIR}/sanitizers")
if(NOT IS_DIRECTORY "${MYX_CMAKE_SANITIZERS_DIR}") if(NOT IS_DIRECTORY "${MYX_CMAKE_SANITIZERS_DIR}")
message(STATUS "MyxCMake: Sanitizers submodule is not found.") myx_cmake_message_warning(STATUS "MyxCMake: Sanitizers submodule is not found.")
else() else()
if(NOT ${MYX_CMAKE_SANITIZERS_DIR} IN_LIST CMAKE_MODULE_PATH) if(NOT ${MYX_CMAKE_SANITIZERS_DIR} IN_LIST CMAKE_MODULE_PATH)
list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_SANITIZERS_DIR}") list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_SANITIZERS_DIR}")
@ -33,7 +33,7 @@ endif()
set(MYX_CMAKE_FIND_DIR "${MYX_CMAKE_DIR}/find") set(MYX_CMAKE_FIND_DIR "${MYX_CMAKE_DIR}/find")
if(NOT IS_DIRECTORY "${MYX_CMAKE_FIND_DIR}") if(NOT IS_DIRECTORY "${MYX_CMAKE_FIND_DIR}")
message(STATUS "MyxCMake: Custom find submodules are not found.") myx_cmake_message_warning("MyxCMake: Custom find submodules are not found.")
else() else()
if(NOT ${MYX_CMAKE_FIND_DIR} IN_LIST CMAKE_MODULE_PATH) if(NOT ${MYX_CMAKE_FIND_DIR} IN_LIST CMAKE_MODULE_PATH)
list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_FIND_DIR}") list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_FIND_DIR}")
@ -42,7 +42,7 @@ endif()
set(MYX_CMAKE_MODULES_DIR "${MYX_CMAKE_DIR}/modules") set(MYX_CMAKE_MODULES_DIR "${MYX_CMAKE_DIR}/modules")
if(NOT IS_DIRECTORY "${MYX_CMAKE_MODULES_DIR}") if(NOT IS_DIRECTORY "${MYX_CMAKE_MODULES_DIR}")
message(FATAL_ERROR "MyxCMake: Requried modules directory is not found.") myx_cmake_message_error("MyxCMake: Requried modules directory is not found.")
else() else()
if(NOT ${MYX_CMAKE_MODULES_DIR} IN_LIST CMAKE_MODULE_PATH) if(NOT ${MYX_CMAKE_MODULES_DIR} IN_LIST CMAKE_MODULE_PATH)
list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_MODULES_DIR}") list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_MODULES_DIR}")

View File

@ -7,7 +7,7 @@ function(myx_cmake_enable_high_precision_math)
if(MPFR_FOUND) if(MPFR_FOUND)
find_package(MPFRCppThirdparty) find_package(MPFRCppThirdparty)
else() else()
message(FATAL_ERROR "Nor Quadmath, nor MPFR found.") myx_cmake_message_error("MyxCMake: Nor Quadmath, nor MPFR found.")
endif() endif()
endif() endif()
endfunction() endfunction()

View File

@ -7,9 +7,7 @@ function(myx_cmake_add_shared_library target)
endif() endif()
get_target_property(__target_type ${target} TYPE) get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY) if(NOT __target_type STREQUAL OBJECT_LIBRARY)
message(FATAL_ERROR myx_cmake_message_error("MyxCMake: myx_cmake_add_shared_library needs target of type OBJECT_LIBRARY")
"MyxCMake: myx_cmake_add_shared_library needs target of type OBJECT_LIBRARY")
return()
endif() endif()
add_library(${target}-shared SHARED $<TARGET_OBJECTS:${target}>) add_library(${target}-shared SHARED $<TARGET_OBJECTS:${target}>)

View File

@ -7,9 +7,7 @@ function(myx_cmake_add_static_library target)
endif() endif()
get_target_property(__target_type ${target} TYPE) get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY) if(NOT __target_type STREQUAL OBJECT_LIBRARY)
message(FATAL_ERROR myx_cmake_message_error("MyxCMake: myx_cmake_add_static_library needs target of type OBJECT_LIBRARY")
"MyxCMake: myx_cmake_add_static_library needs target of type OBJECT_LIBRARY")
return()
endif() endif()
add_library(${target}-static STATIC $<TARGET_OBJECTS:${target}>) add_library(${target}-static STATIC $<TARGET_OBJECTS:${target}>)

View File

@ -16,7 +16,7 @@ else()
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
elseif(NOT "${CMAKE_BUILD_TYPE}" IN_LIST _allowed_build_types) elseif(NOT "${CMAKE_BUILD_TYPE}" IN_LIST _allowed_build_types)
message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}") myx_cmake_message_error("Invalid build type: ${CMAKE_BUILD_TYPE}")
endif() endif()
endif() endif()

View File

@ -10,13 +10,13 @@ get_filename_component(_binary_realpath "${CMAKE_BINARY_DIR}" REALPATH)
get_filename_component(_install_realpath "${CMAKE_INSTALL_PREFIX}" REALPATH) get_filename_component(_install_realpath "${CMAKE_INSTALL_PREFIX}" REALPATH)
if(_install_realpath STREQUAL _binary_realpath) if(_install_realpath STREQUAL _binary_realpath)
message(FATAL_ERROR "MyxCMake: Cannot install into build directory.") myx_cmake_message_error("MyxCMake: Cannot install into build directory.")
endif() endif()
if(_install_realpath STREQUAL _source_realpath) if(_install_realpath STREQUAL _source_realpath)
message(FATAL_ERROR "MyxCMake: Cannot install into source directory.") myx_cmake_message_error("MyxCMake: Cannot install into source directory.")
endif() endif()
if(_source_realpath STREQUAL _binary_realpath) if(_source_realpath STREQUAL _binary_realpath)
message(FATAL_ERROR "MyxCMake: In-source builds are not allowed.") myx_cmake_message_error("MyxCMake: In-source builds are not allowed.")
endif() endif()

View File

@ -31,7 +31,7 @@ function(myx_cmake_message_status)
endfunction() endfunction()
function(myx_cmake_message_notice) function(myx_cmake_message_notice)
message(STATUS ${MyxCMakeColorBold}${ARGV}${MyxCMakeColorReset}) message(${MyxCMakeColorBold}${ARGV}${MyxCMakeColorReset})
endfunction() endfunction()
function(myx_cmake_message) function(myx_cmake_message)

View File

@ -1,7 +1,6 @@
function(myx_cmake_common_target_properties target) function(myx_cmake_common_target_properties target)
if(NOT TARGET ${target}) if(NOT TARGET ${target})
message(FATAL_ERROR "MyxCMake: Target ${target} does not exists.") myx_cmake_message_error("MyxCMake: Target ${target} does not exists.")
return()
endif() endif()
get_target_property(_target_type ${target} TYPE) get_target_property(_target_type ${target} TYPE)
@ -155,8 +154,7 @@ endfunction()
function(myx_cmake_common_target_properties_post target) function(myx_cmake_common_target_properties_post target)
if(NOT TARGET ${target}) if(NOT TARGET ${target})
message(FATAL_ERROR "MyxCMake: Target ${target} does not exists.") myx_cmake_message_error("MyxCMake: Target ${target} does not exists.")
return()
endif() endif()
get_target_property(_target_type ${target} TYPE) get_target_property(_target_type ${target} TYPE)

View File

@ -25,11 +25,11 @@ macro(CHECK_ENABLE_DEBUG_CXX_FLAG flag)
unset(CMAKE_REQUIRED_QUIET) unset(CMAKE_REQUIRED_QUIET)
if(CHECK_CXX_FLAG_DEBUG) if(CHECK_CXX_FLAG_DEBUG)
message(STATUS "'${flag}': debug flag is supported.") myx_cmake_message_notice("'${flag}': debug flag is supported.")
string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG
"${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG} ${flag}") "${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG} ${flag}")
else() else()
message(STATUS "'${flag}': debug flag is NOT supported.") myx_cmake_message_status("'${flag}': debug flag is NOT supported.")
endif() endif()
# NOTE: check_cxx_compiler stores variables in the cache. # NOTE: check_cxx_compiler stores variables in the cache.
unset(CHECK_CXX_FLAG_DEBUG CACHE) unset(CHECK_CXX_FLAG_DEBUG CACHE)

View File

@ -5,7 +5,7 @@ if(DISTCC_EXECUTABLE)
# cmake-format: off # cmake-format: off
if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND
NOT CMAKE_${lang}_COMPILER MATCHES ".*/distcc$") NOT CMAKE_${lang}_COMPILER MATCHES ".*/distcc$")
myx_cmake_message("MyxCMake: distcc enabled for ${lang}") myx_cmake_message_notice("MyxCMake: distcc enabled for ${lang}")
set(CMAKE_${lang}_COMPILER_LAUNCHER ${DISTCC_EXECUTABLE} CACHE STRING "") set(CMAKE_${lang}_COMPILER_LAUNCHER ${DISTCC_EXECUTABLE} CACHE STRING "")
endif() endif()
# cmake-format: on # cmake-format: on

View File

@ -1,17 +1,15 @@
function(myx_cmake_check_project_version) function(myx_cmake_check_project_version)
if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)") if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)")
message(FATAL_ERROR "MyxCMake: Please set project version in X.Y.Z format") myx_cmake_message_error("MyxCMake: Please set project version in X.Y.Z format")
endif() endif()
endfunction() endfunction()
function(myx_cmake_set_project_version_int) function(myx_cmake_set_project_version_int)
# cmake-format: off
myx_cmake_check_project_version() myx_cmake_check_project_version()
math( math(EXPR _version_int "(${PROJECT_VERSION_MAJOR} << 16) + (${PROJECT_VERSION_MINOR} << 8) + ${PROJECT_VERSION_PATCH}")
EXPR
_version_int
"(${PROJECT_VERSION_MAJOR} << 16) + (${PROJECT_VERSION_MINOR} << 8) + ${PROJECT_VERSION_PATCH}"
)
set_property(GLOBAL PROPERTY PROJECT_VERSION_INT ${_version_int}) set_property(GLOBAL PROPERTY PROJECT_VERSION_INT ${_version_int})
# cmake-format: on
endfunction() endfunction()
myx_cmake_set_project_version_int() myx_cmake_set_project_version_int()

View File

@ -3,32 +3,25 @@
# CMakeLists.txt до подключения MyxCMake, либо передать из командной строки # CMakeLists.txt до подключения MyxCMake, либо передать из командной строки
# через ключ -D # через ключ -D
# #
# cmake-format: off
if(NOT MYX_CMAKE_ORGANIZATION_NAME) if(NOT MYX_CMAKE_ORGANIZATION_NAME)
message( myx_cmake_message_error("MyxCMake: Required variable MYX_CMAKE_ORGANIZATION_NAME is not defined")
FATAL_ERROR
"MyxCMake: Required variable MYX_CMAKE_ORGANIZATION_NAME is not defined")
endif() endif()
if(NOT MYX_CMAKE_AUTHOR_NAME) if(NOT MYX_CMAKE_AUTHOR_NAME)
message( myx_cmake_message_error("MyxCMake: Required variable MYX_CMAKE_AUTHOR_NAME is not defined")
FATAL_ERROR
"MyxCMake: Required variable MYX_CMAKE_AUTHOR_NAME is not defined")
endif() endif()
if(NOT MYX_CMAKE_AUTHOR_EMAIL) if(NOT MYX_CMAKE_AUTHOR_EMAIL)
message( myx_cmake_message_error("MyxCMake: Required variable MYX_CMAKE_AUTHOR_EMAIL is not defined")
FATAL_ERROR
"MyxCMake: Required variable MYX_CMAKE_AUTHOR_EMAIL is not defined")
endif() endif()
set(CPACK_PACKAGE_CONTACT
"${MYX_CMAKE_AUTHOR_NAME} <${MYX_CMAKE_AUTHOR_EMAIL}>"
CACHE STRING "")
if(NOT MYX_CMAKE_DESCRIPTION) if(NOT MYX_CMAKE_DESCRIPTION)
message( myx_cmake_message_error("MyxCMake: Required variable MYX_CMAKE_DESCRIPTION is not defined")
FATAL_ERROR
"MyxCMake: Required variable MYX_CMAKE_DESCRIPTION is not defined")
endif() endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
${MYX_CMAKE_DESCRIPTION} set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${MYX_CMAKE_DESCRIPTION} CACHE STRING "")
CACHE STRING "") set(CPACK_PACKAGE_CONTACT "${MYX_CMAKE_AUTHOR_NAME} <${MYX_CMAKE_AUTHOR_EMAIL}>" CACHE STRING "")
# cmake-format: on