summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>2020-06-04 14:38:56 +0200
committerCharles Pigott <charlespigott@googlemail.com>2020-06-30 09:43:00 +0100
commit0d46e20bd4ab4e66e5801b731e0d2b4cb9014ad2 (patch)
tree942fe50fc5d6a6c11fbc85a0f7f7315b5fe41063
parent04c050f93ed1ea60409f53bea96a1790245851e0 (diff)
downloadopenttd-0d46e20bd4ab4e66e5801b731e0d2b4cb9014ad2.tar.xz
Add: add option for forcing coloured compiler output (useful for Ninja)
-rw-r--r--cmake/CompileFlags.cmake13
-rw-r--r--cmake/Options.cmake2
2 files changed, 15 insertions, 0 deletions
diff --git a/cmake/CompileFlags.cmake b/cmake/CompileFlags.cmake
index e7d470c7d..d200b3f50 100644
--- a/cmake/CompileFlags.cmake
+++ b/cmake/CompileFlags.cmake
@@ -82,6 +82,19 @@ macro(compile_flags)
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-variable>"
)
+ # Ninja processes the output so the output from the compiler
+ # isn't directly to a terminal; hence, the default is
+ # non-coloured output. We can override this to get nicely
+ # coloured output, but since that might yield odd results with
+ # IDEs, we extract it to an option.
+ if (OPTION_FORCE_COLORED_OUTPUT)
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ add_compile_options (-fdiagnostics-color=always)
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
+ add_compile_options (-fcolor-diagnostics)
+ endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+ endif (OPTION_FORCE_COLORED_OUTPUT)
+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-flifetime-dse=1" LIFETIME_DSE_FOUND)
diff --git a/cmake/Options.cmake b/cmake/Options.cmake
index 478f1b2b2..4210c5b49 100644
--- a/cmake/Options.cmake
+++ b/cmake/Options.cmake
@@ -48,6 +48,8 @@ function(set_options)
set(DEFAULT_OPTION_INSTALL_FHS OFF)
endif (UNIX AND NOT APPLE)
+ option(OPTION_FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF)
+
option(OPTION_DEDICATED "Build dedicated server only (no GUI)" OFF)
option(OPTION_INSTALL_FHS "Install with Filesstem Hierarchy Standard folders" ${DEFAULT_OPTION_INSTALL_FHS})
option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" ON)