From 57017a166c8f46efb2b9c7fcf0b5d36adb732f30 Mon Sep 17 00:00:00 2001 From: Magne Date: Fri, 9 May 2025 14:00:32 +0200 Subject: [PATCH] Add minimum requirements for CMake, gcc and clang On Linux, link with stdc++exp Define requirements in README --- ApplicationLibCode/CMakeLists.txt | 7 +++-- CMakeLists.txt | 26 +++++++++++++++++++ README.md | 7 +++++ .../Ert/cmake/Modules/FindCXX11Features.cmake | 2 -- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 9fcb9acc26..b91696f12b 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -303,10 +303,13 @@ set(LINK_LIBRARIES ${RI_LIBRARIES} ) -# According to ivarun this is needed on OpenSuse, and Fedora. See: -# https://github.com/OPM/ResInsight/pull/7 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + # According to ivarun rt is needed on OpenSuse, and Fedora. See: + # https://github.com/OPM/ResInsight/pull/7 list(APPEND EXTERNAL_LINK_LIBRARIES rt) + + # stdc++exp is required for std::stacktrace + list(APPEND EXTERNAL_LINK_LIBRARIES stdc++exp) endif() target_link_libraries( diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f07e25d2b..1746e15fd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,37 @@ # The way boost is configured and used in Boost 1.86 requires CMake 3.26 cmake_minimum_required(VERSION 3.26) +# Check if CMake version is 4.0 or higher +if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.0) + message( + FATAL_ERROR + "CMake version ${CMAKE_VERSION} detected. We are investigating issues for CMake 4. Use CMake 3.x to build ResInsight." + ) +endif() + include(CheckCSourceCompiles) include(FetchContent) project(ResInsight) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) + message( + FATAL_ERROR + "Minimum GCC version is 13, detected version: ${CMAKE_CXX_COMPILER_VERSION}" + ) + endif() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0) + message( + FATAL_ERROR + "Minimum supported version is Clang 19, detected version: ${CMAKE_CXX_COMPILER_VERSION}" + ) + endif() +endif() + # Ensure all binary files ensd up in the same folder as the executable set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/README.md b/README.md index cf564f6dea..b1a92829f5 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,13 @@ ResInsight is cross-platform with automated testing on: ``` git clone git://github.com/OPM/ResInsight.git ``` +### Minimum Requirements +gcc 13 +clang 19 +CMake 3.15 (CMake 4 is currently not supported) +MSVC 2022 17.4 + +These requirements are defined by used features in c++23 like std::stacktrace and std::expected. ### Dependencies Most dependencies are managed using vcpkg as defined in [vcpkg.json](https://github.com/OPM/ResInsight/blob/dev/vcpkg.json) diff --git a/ThirdParty/Ert/cmake/Modules/FindCXX11Features.cmake b/ThirdParty/Ert/cmake/Modules/FindCXX11Features.cmake index 13b25e3856..cd942ad274 100644 --- a/ThirdParty/Ert/cmake/Modules/FindCXX11Features.cmake +++ b/ThirdParty/Ert/cmake/Modules/FindCXX11Features.cmake @@ -11,8 +11,6 @@ if (NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - else() - message(SEND_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() endif()