Unverified Commit ae38a70d authored by Rafael Kitover's avatar Rafael Kitover
Browse files

cmake: gcc/clang colors with ninja, fix warnings

Ninja requires `-fdiagnostics-color=always` instead of
`-fdiagnostics-color=auto` with gcc because it pipes output from the
compiler unlike regular makes.

Use `-fcolor-diagnostics` for clang, which also works correctly with
ninja to show colors.

Information for this taken from here:

https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949



Set all cmake policies in both the root `CMakeLists.txt` and
`src/wx/CMakeLists.txt` to silence warnings about unset policies from
cmake.
Signed-off-by: default avatarRafael Kitover <rkitover@gmail.com>
parent 23fe13d8
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW) # link to full path of libs
cmake_policy(SET CMP0005 NEW) # escapes in add_definitions
cmake_policy(SET CMP0077 NEW) # use vars for options
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy(SET CMP0043 NEW) # for wxWidgets, use generator expressions
endif()
endif()
option(ENABLE_VCPKG "Use dependencies for Visual Studio from vcpkg" ON)
......@@ -432,9 +437,24 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp)
endif()
check_cxx_compiler_flag(-fdiagnostics-color=auto COMPILER_COLOR_OUTPUT)
if(COMPILER_COLOR_OUTPUT)
add_compile_options(-fdiagnostics-color=auto)
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fdiagnostics-color=always COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fdiagnostics-color=always)
else()
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fdiagnostics-color COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fdiagnostics-color)
endif()
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
unset(COMPILER_COLOR_DIAGNOSTICS)
check_cxx_compiler_flag(-fcolor-diagnostics COMPILER_COLOR_DIAGNOSTICS)
if(COMPILER_COLOR_DIAGNOSTICS)
add_compile_options(-fcolor-diagnostics)
endif()
endif()
if(MINGW)
......
#Do not use this file directly. Always use the top level CMakeLists.txt file
# This build is much easier if we just do it here.
# Do not use this file directly. Always use the top level CMakeLists.txt file
IF(NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy(SET CMP0043 NEW) # for wxWidgets
ENDIF()
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW) # link to full path of libs
cmake_policy(SET CMP0005 NEW) # escapes in add_definitions
cmake_policy(SET CMP0077 NEW) # use vars for options
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy(SET CMP0043 NEW) # for wxWidgets, use generator expressions
endif()
endif()
include(VbamFunctions)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment