Skip to content

Commit

Permalink
Add cmake option to force-enable colors in build (#3269)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlstill authored Apr 29, 2022
1 parent 827bca9 commit 3d4f881
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ if(CMAKE_COMPILER_IS_GNUCC)
unset(LD_VERSION)
endif ()

set(BUILD_USE_COLOR OFF CACHE BOOL "Use color in C++ compiler output (even if "
"the compiler does not detect terminal, e.g. when using ccache/distcc)")
if (BUILD_USE_COLOR)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
else()
message(WARNING "Colors enabled (BUILD_USE_COLOR=ON) but we don't know "
"how to enable them for ${CMAKE_CXX_COMPILER_ID} C++ compiler")
endif()
endif()

include_directories (
${P4C_SOURCE_DIR}/frontends
${P4C_SOURCE_DIR}/backends
Expand Down

0 comments on commit 3d4f881

Please sign in to comment.