Skip to content

Commit 3bb0e9d

Browse files
maxrdzyeetari
authored andcommitted
[cmake] Enable GCC/clang ANSI-colored output for Ninja build tool
1 parent 7d1547f commit 3bb0e9d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ option(INEXOR_BUILD_EXAMPLE "Build example" ON)
1717
option(INEXOR_BUILD_TESTS "Build tests" OFF)
1818
set(INEXOR_CONAN_PROFILE "default" CACHE STRING "conan profile")
1919
option(INEXOR_USE_VMA_RECORDING "Use VulkanMemoryAllocator recording feature" OFF)
20+
option(INEXOR_FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." TRUE)
2021

2122
message(STATUS "INEXOR_BUILD_BENCHMARKS = ${INEXOR_BUILD_BENCHMARKS}")
2223
message(STATUS "INEXOR_BUILD_DOC = ${INEXOR_BUILD_DOC}")
@@ -59,6 +60,16 @@ execute_process(
5960
OUTPUT_STRIP_TRAILING_WHITESPACE
6061
)
6162

63+
# Enable GCC/clang ANSI-colored terminal output using Ninja build tool
64+
# TODO: Switch to `CMAKE_COLOR_DIAGNOSTICS` with cmake 3.24 in the future
65+
if (FORCE_COLORED_OUTPUT)
66+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
67+
add_compile_options(-fdiagnostics-color=always)
68+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
69+
add_compile_options(-fcolor-diagnostics)
70+
endif()
71+
endif()
72+
6273
add_subdirectory(shaders)
6374
add_subdirectory(src)
6475

0 commit comments

Comments
 (0)