diff --git a/CMakeLists.txt b/CMakeLists.txt index 1abb193de..0d5d96cd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.16) option(IMHEX_OFFLINE_BUILD "Enable offline build" OFF) option(IMHEX_IGNORE_BAD_CLONE "Disabled the bad clone prevention checks" OFF) option(IMHEX_PATTERNS_PULL_MASTER "Download latest files from master branch of the ImHex-Patterns repo" OFF) +option(IMHEX_IGNORE_BAD_COMPILER "Allow compiling with an unsupported compiler" OFF) # Basic compiler and cmake configurations set(CMAKE_CXX_STANDARD 23) @@ -19,6 +20,7 @@ project(imhex VERSION ${IMHEX_VERSION}) # Make sure project is configured correctly setDefaultBuiltTypeIfUnset() detectBadClone() +verifyCompiler() # List plugin names here. Project name must match folder name set(PLUGINS diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index b4658f17b..8f305b1c6 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -309,6 +309,18 @@ function(detectBadClone) endforeach () endfunction() +set(IMHEX_REQUIRED_COMPILER "GNU") +set(IMHEX_MIN_COMPILER_VERSION "12.1.0") +function(verifyCompiler) + if (IMHEX_IGNORE_BAD_COMPILER) + return() + endif() + + if (NOT CMAKE_CXX_COMPILER_ID STREQUAL ${IMHEX_REQUIRED_COMPILER} OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${IMHEX_MIN_COMPILER_VERSION}) + message(FATAL_ERROR "ImHex requires GCC ${IMHEX_MIN_COMPILER_VERSION} or newer. Please use the latest GCC version.") + endif() +endfunction() + macro(setVariableInParent variable value) get_directory_property(hasParent PARENT_DIRECTORY)