From 090d8305e4e3c3ee085a897b72f2b4708e183eb8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 5 Oct 2020 13:09:42 +0100 Subject: Warnings improvements * Turn off global-constructors warning. These are needed to implement cRoot signal handler functionality * Add Clang flags based on version lookup instead of a compile test. The CMake config process is single threaded and slow enough already * Reduced GetStackValue verbosity + Clarify EnchantmentLevel, StayCount, AlwaysTicked, ViewDistance signedness + Give SettingsRepositoryInterface a move constructor to simplify main.cpp code - Remove do {} while (false) construction in redstone handler --- SetFlags.cmake | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'SetFlags.cmake') diff --git a/SetFlags.cmake b/SetFlags.cmake index f5c8a282b..ff1b4bad4 100644 --- a/SetFlags.cmake +++ b/SetFlags.cmake @@ -111,14 +111,6 @@ function(set_global_flags) endif() endfunction() -function (try_add_flag TARGET FLAG) - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag("${FLAG}" "HAS_FLAG_${FLAG}") - if ("${HAS_FLAG_${FLAG}}") - target_compile_options(${TARGET} PRIVATE "${FLAG}") - endif() -endfunction() - function(set_exe_flags TARGET) if (MSVC) # TODO: MSVC level 4, warnings as errors @@ -158,15 +150,27 @@ function(set_exe_flags TARGET) -Wno-switch-enum # Weverything with Clang exceptions: - -Weverything -Wno-error=disabled-macro-expansion -Wno-weak-vtables - -Wno-exit-time-destructors -Wno-string-conversion -Wno-c++98-compat-pedantic - -Wno-documentation -Wno-documentation-unknown-command -Wno-reserved-id-macro - -Wno-error=unused-command-line-argument + -Weverything -Wno-exit-time-destructors -Wno-error=disabled-macro-expansion + -Wno-weak-vtables -Wno-string-conversion -Wno-c++98-compat-pedantic -Wno-documentation + -Wno-documentation-unknown-command -Wno-reserved-id-macro -Wno-error=unused-command-line-argument ) - # We aren't using C++11 - try_add_flag(${TARGET} -Wno-return-std-move-in-c++11) - # int to float conversions happen a lot, not worth fixing all warnings - try_add_flag(${TARGET} -Wno-implicit-int-float-conversion) + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7) + target_compile_options( + ${TARGET} PRIVATE + + # We aren't using C++11: + -Wno-return-std-move-in-c++11 + ) + endif() + + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10) + target_compile_options( + ${TARGET} PRIVATE + + # int to float conversions happen a lot, not worth fixing all warnings: + -Wno-implicit-int-float-conversion + ) + endif() endif() endfunction() -- cgit v1.2.3