From ea5360cb997f0fe52bc83a2907da41f507c295f2 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Fri, 19 Jan 2024 08:18:36 -0800 Subject: [PATCH] fix: turn warnings into errors (#1425) * Update PlayerContainer.cpp fix: turn warnings into errors for the few warnings we get, at least make sure we listen to them now on unix platforms. Windows has too many right now to enable /WX resolve warning actually fix it Update CMakeLists.txt * detour pls * Update CMakeLists.txt * I HAVE 20 DOLLARS AND I NEED A WII GAME FOR MY KID * I HAVE 0 DOLLARS NOW * don't look don't look * Revert "don't look don't look" This reverts commit 5603eb59803dc2f55d0f1f4b1ff692753a17b218. * Revert "Revert "don't look don't look"" This reverts commit a334832a4dcd6f932f5065012e0a5ac80ea6fa9a. * could it be * we found one (but its already reported) not resolved yet though. * Revert "don't look don't look" This reverts commit 5603eb59803dc2f55d0f1f4b1ff692753a17b218. * ignore warning for file * another one * Update .gitmodules * comments --- CMakeLists.txt | 4 +++- dCommon/CMakeLists.txt | 6 ++++++ dGame/dInventory/CMakeLists.txt | 6 ++++++ thirdparty/SQLite/CMakeLists.txt | 7 ++++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74408df8..09cbac97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,7 +272,9 @@ link_directories(${PROJECT_BINARY_DIR}) # Load all of our third party directories add_subdirectory(thirdparty) - +if (UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +endif() # Glob together all headers that need to be precompiled file( GLOB HEADERS_DDATABASE diff --git a/dCommon/CMakeLists.txt b/dCommon/CMakeLists.txt index 5300a4f2..fec1a2d7 100644 --- a/dCommon/CMakeLists.txt +++ b/dCommon/CMakeLists.txt @@ -20,6 +20,12 @@ set(DCOMMON_SOURCES "FdbToSqlite.cpp" ) +# Workaround for compiler bug where the optimized code could result in a memcpy of 0 bytes, even though that isnt possible. +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97185 +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set_source_files_properties("FdbToSqlite.cpp" PROPERTIES COMPILE_FLAGS "-Wno-stringop-overflow") +endif() + add_subdirectory(dClient) foreach(file ${DCOMMON_DCLIENT_SOURCES}) diff --git a/dGame/dInventory/CMakeLists.txt b/dGame/dInventory/CMakeLists.txt index a663a97d..bc741efe 100644 --- a/dGame/dInventory/CMakeLists.txt +++ b/dGame/dInventory/CMakeLists.txt @@ -5,5 +5,11 @@ set(DGAME_DINVENTORY_SOURCES "ItemSet.cpp" "ItemSetPassiveAbility.cpp") +# Workaround for compiler bug where the optimized code could result in a memcpy of 0 bytes, even though that isnt possible. +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97185 +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set_source_files_properties("Item.cpp" PROPERTIES COMPILE_FLAGS "-Wno-stringop-overflow") +endif() + add_library(dInventory STATIC ${DGAME_DINVENTORY_SOURCES}) target_precompile_headers(dInventory REUSE_FROM dGameBase) diff --git a/thirdparty/SQLite/CMakeLists.txt b/thirdparty/SQLite/CMakeLists.txt index aa7a6423..ba45f015 100644 --- a/thirdparty/SQLite/CMakeLists.txt +++ b/thirdparty/SQLite/CMakeLists.txt @@ -10,5 +10,10 @@ if(UNIX) target_link_libraries(sqlite3 pthread dl m) # -Wno-unused-result -Wno-unknown-pragmas -fpermissive - target_compile_options(sqlite3 PRIVATE "-Wno-return-local-addr" "-Wno-maybe-uninitialized") + target_compile_options(sqlite3 PRIVATE) + if(NOT APPLE) + target_compile_options(sqlite3 PRIVATE "-Wno-return-local-addr" "-Wno-maybe-uninitialized") + else() + target_compile_options(sqlite3 PRIVATE "-Wno-return-stack-address" "-Wno-uninitialized") + endif() endif()