Skip to content

Commit 2e2a5bf

Browse files
committed
Give more precedence to per-instance CMake option
Per second point in FAQ: https://no-color.org Follows up 46748d9.
1 parent 46748d9 commit 2e2a5bf

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

cmake/ColorDebugOptions.cmake

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,64 @@
11
# ColorDebug options
22

3+
# no colors
4+
5+
set(cd_no_color_default OFF)
6+
37
if(DEFINED ENV{NO_COLOR})
4-
message(STATUS "NO_COLOR environment variable present, disabling color output.")
8+
if(NOT DEFINED COLOR_DEBUG_NO_COLOR)
9+
message(STATUS "NO_COLOR environment variable present, disabling color output.")
10+
endif()
11+
set(cd_no_color_default ON)
512
endif()
613

7-
include(CMakeDependentOption)
8-
9-
cmake_dependent_option(COLOR_DEBUG_NO_COLOR "Choose if you want to disable colors altogether" OFF
10-
"NOT DEFINED ENV{NO_COLOR}" ON)
14+
option(COLOR_DEBUG_NO_COLOR "Choose if you want to disable colors altogether" ${cd_no_color_default})
1115

1216
if(COLOR_DEBUG_NO_COLOR)
1317
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_NO_COLOR)
1418
endif()
1519

16-
cmake_dependent_option(COLOR_DEBUG_HIDE_ERROR "Choose if you want to hide error level messages" OFF
17-
"NOT COLOR_DEBUG_NO_COLOR" OFF)
20+
# debug
21+
22+
option(COLOR_DEBUG_HIDE_ERROR "Choose if you want to hide error level messages" OFF)
1823

1924
if(COLOR_DEBUG_HIDE_ERROR)
2025
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_ERROR)
2126
endif()
2227

23-
cmake_dependent_option(COLOR_DEBUG_HIDE_WARNING "Choose if you want to hide warning level messages" OFF
24-
"NOT COLOR_DEBUG_NO_COLOR" OFF)
28+
# warning
29+
30+
option(COLOR_DEBUG_HIDE_WARNING "Choose if you want to hide warning level messages" OFF)
2531

2632
if(COLOR_DEBUG_HIDE_WARNING)
2733
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_WARNING)
2834
endif()
2935

30-
cmake_dependent_option(COLOR_DEBUG_HIDE_SUCCESS "Choose if you want to hide success level messages" OFF
31-
"NOT COLOR_DEBUG_NO_COLOR" OFF)
36+
# success
37+
38+
option(COLOR_DEBUG_HIDE_SUCCESS "Choose if you want to hide success level messages" OFF)
3239

3340
if(COLOR_DEBUG_HIDE_SUCCESS)
3441
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_SUCCESS)
3542
endif()
3643

37-
cmake_dependent_option(COLOR_DEBUG_HIDE_INFO "Choose if you want to hide info level messages" OFF
38-
"NOT COLOR_DEBUG_NO_COLOR" OFF)
44+
# info
45+
46+
option(COLOR_DEBUG_HIDE_INFO "Choose if you want to hide info level messages" OFF)
3947

4048
if(COLOR_DEBUG_HIDE_INFO)
4149
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_INFO)
4250
endif()
4351

44-
cmake_dependent_option(COLOR_DEBUG_HIDE_DEBUG "Choose if you want to hide debug level messages" OFF
45-
"NOT COLOR_DEBUG_NO_COLOR" OFF)
52+
# debug
53+
54+
option(COLOR_DEBUG_HIDE_DEBUG "Choose if you want to hide debug level messages" OFF)
4655

4756
if(COLOR_DEBUG_HIDE_DEBUG)
4857
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS CD_HIDE_DEBUG)
4958
endif()
5059

60+
# full file path
61+
5162
option(COLOR_DEBUG_FULL_FILE "Choose if you want to compile with CD_FULL_FILE" OFF)
5263

5364
if(COLOR_DEBUG_FULL_FILE)

0 commit comments

Comments
 (0)