Permalink
Browse files

Give more precedence to per-instance CMake option

Per second point in FAQ: https://no-color.org

Follows up 46748d9.
  • Loading branch information...
PeterBowman committed Feb 9, 2019
1 parent 46748d9 commit 2e2a5bf5a202228985612008967fb63ba8be53d8
Showing with 26 additions and 15 deletions.
  1. +26 −15 cmake/ColorDebugOptions.cmake
@@ -1,53 +1,64 @@
# ColorDebug options

# no colors

set(cd_no_color_default OFF)

if(DEFINED ENV{NO_COLOR})
message(STATUS "NO_COLOR environment variable present, disabling color output.")
if(NOT DEFINED COLOR_DEBUG_NO_COLOR)
message(STATUS "NO_COLOR environment variable present, disabling color output.")
endif()
set(cd_no_color_default ON)
endif()

include(CMakeDependentOption)

cmake_dependent_option(COLOR_DEBUG_NO_COLOR "Choose if you want to disable colors altogether" OFF
"NOT DEFINED ENV{NO_COLOR}" ON)
option(COLOR_DEBUG_NO_COLOR "Choose if you want to disable colors altogether" ${cd_no_color_default})

if(COLOR_DEBUG_NO_COLOR)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_NO_COLOR)
endif()

cmake_dependent_option(COLOR_DEBUG_HIDE_ERROR "Choose if you want to hide error level messages" OFF
"NOT COLOR_DEBUG_NO_COLOR" OFF)
# debug

option(COLOR_DEBUG_HIDE_ERROR "Choose if you want to hide error level messages" OFF)

if(COLOR_DEBUG_HIDE_ERROR)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_ERROR)
endif()

cmake_dependent_option(COLOR_DEBUG_HIDE_WARNING "Choose if you want to hide warning level messages" OFF
"NOT COLOR_DEBUG_NO_COLOR" OFF)
# warning

option(COLOR_DEBUG_HIDE_WARNING "Choose if you want to hide warning level messages" OFF)

if(COLOR_DEBUG_HIDE_WARNING)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_WARNING)
endif()

cmake_dependent_option(COLOR_DEBUG_HIDE_SUCCESS "Choose if you want to hide success level messages" OFF
"NOT COLOR_DEBUG_NO_COLOR" OFF)
# success

option(COLOR_DEBUG_HIDE_SUCCESS "Choose if you want to hide success level messages" OFF)

if(COLOR_DEBUG_HIDE_SUCCESS)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_SUCCESS)
endif()

cmake_dependent_option(COLOR_DEBUG_HIDE_INFO "Choose if you want to hide info level messages" OFF
"NOT COLOR_DEBUG_NO_COLOR" OFF)
# info

option(COLOR_DEBUG_HIDE_INFO "Choose if you want to hide info level messages" OFF)

if(COLOR_DEBUG_HIDE_INFO)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_INFO)
endif()

cmake_dependent_option(COLOR_DEBUG_HIDE_DEBUG "Choose if you want to hide debug level messages" OFF
"NOT COLOR_DEBUG_NO_COLOR" OFF)
# debug

option(COLOR_DEBUG_HIDE_DEBUG "Choose if you want to hide debug level messages" OFF)

if(COLOR_DEBUG_HIDE_DEBUG)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_DEBUG)
endif()

# full file path

option(COLOR_DEBUG_FULL_FILE "Choose if you want to compile with CD_FULL_FILE" OFF)

if(COLOR_DEBUG_FULL_FILE)

0 comments on commit 2e2a5bf

Please sign in to comment.