diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ed68605e..a3b11382e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ option(IMHEX_USE_GTK_FILE_PICKER "Use GTK file picker instead of xdg-desktop-por option(IMHEX_DISABLE_STACKTRACE "Disables support for printing stack traces" OFF) option(IMHEX_ENABLE_LTO "Enables Link Time Optimizations if possible" OFF) option(IMHEX_USE_DEFAULT_BUILD_SETTINGS "Use default build settings" OFF) +option(IMHEX_STRICT_WARNINGS "Enable most available warnings and treat them as errors" ON) # Basic compiler and cmake configurations set(CMAKE_CXX_STANDARD 23) diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index ae0d679de..da8ada024 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -377,8 +377,8 @@ function(verifyCompiler) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0.0") message(FATAL_ERROR "ImHex requires GCC 12.0.0 or newer. Please use the latest GCC version.") - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14.0.0") - message(FATAL_ERROR "ImHex requires Clang 14.0.0 or newer. Please use the latest Clang version.") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "17.0.0") + message(FATAL_ERROR "ImHex requires Clang 17.0.0 or newer. Please use the latest Clang version.") elseif (NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) message(FATAL_ERROR "ImHex can only be compiled with GCC or Clang. ${CMAKE_CXX_COMPILER_ID} is not supported.") endif() @@ -428,7 +428,10 @@ endfunction() macro(setupCompilerFlags target) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - set(IMHEX_COMMON_FLAGS "-Wall -Wextra -Wpedantic -Werror") + if (IMHEX_STRICT_WARNINGS) + set(IMHEX_COMMON_FLAGS "-Wall -Wextra -Wpedantic -Werror") + endif() + set(IMHEX_C_FLAGS "${IMHEX_COMMON_FLAGS} -Wno-array-bounds") set(IMHEX_CXX_FLAGS "-fexceptions -frtti") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") diff --git a/lib/external/yara/CMakeLists.txt b/lib/external/yara/CMakeLists.txt index dc5732245..0e758da5a 100644 --- a/lib/external/yara/CMakeLists.txt +++ b/lib/external/yara/CMakeLists.txt @@ -114,7 +114,9 @@ target_compile_definitions(libyara PRIVATE HASH_MODULE DOTNET_MODULE MAGIC_MODULE MACHO_MODULE DEX_MODULE ) -target_compile_options(libyara PRIVATE -Wno-shift-count-overflow -Wno-stringop-overflow) +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(libyara PRIVATE -Wno-shift-count-overflow -Wno-stringop-overflow) +endif () target_include_directories( libyara