From 2a9d46088e3555038468885f6fec593d3f469b9c Mon Sep 17 00:00:00 2001
From: Christoph Alt <christoph.alt@fau.de>
Date: Thu, 13 Mar 2025 11:37:45 +0100
Subject: [PATCH] add minimal version for the rest of the compilers to support
 c++17 and the std::filesystem

---
 cmake/compileroptions/Clang.cmake        | 12 +++++++-----
 cmake/compileroptions/Cray.cmake         |  5 +++++
 cmake/compileroptions/FujitsuClang.cmake |  7 ++++++-
 cmake/compileroptions/GNU.cmake          |  7 ++++---
 cmake/compileroptions/IBM.cmake          |  7 ++++---
 cmake/compileroptions/Intel.cmake        |  7 ++++++-
 cmake/compileroptions/IntelLLVM.cmake    |  7 ++++++-
 cmake/compileroptions/MSVC.cmake         |  7 ++++---
 8 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/cmake/compileroptions/Clang.cmake b/cmake/compileroptions/Clang.cmake
index 4bba387b2..d45f2c035 100644
--- a/cmake/compileroptions/Clang.cmake
+++ b/cmake/compileroptions/Clang.cmake
@@ -1,12 +1,14 @@
 message(STATUS "Setting Clang specific compiler options")
 
 if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
-  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.0)
-    message(FATAL_ERROR "Clang version must be at least 11!")
+   set(_apple_clang_minimal_version 11.0.0)
+  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_apple_clang_minimal_version})
+    message(FATAL_ERROR "Clang version must be at least ${_apple_clang_minimal_version}!")
   endif()
 else()
-  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7)
-    message(FATAL_ERROR "Clang version must be at least 7!")
+  set(_clang_minimal_version 7)
+  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_clang_minimal_version})
+    message(FATAL_ERROR "Clang version must be at least ${_clang_minimal_version}!")
   endif()
 endif()
 
@@ -103,4 +105,4 @@ if(WALBERLA_BUILD_WITH_OPENMP)
     )
     add_flag(CMAKE_CXX_FLAGS "-Wno-sign-conversion")
   endif()
-endif()
+endif()
\ No newline at end of file
diff --git a/cmake/compileroptions/Cray.cmake b/cmake/compileroptions/Cray.cmake
index 95b889794..c8476f64d 100644
--- a/cmake/compileroptions/Cray.cmake
+++ b/cmake/compileroptions/Cray.cmake
@@ -1,5 +1,10 @@
 message(STATUS "Setting Cray specific compiler options")
 
+set(_cray_minimal_version 9)
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_cray_minimal_version})
+   message(FATAL_ERROR "Cray version must be at least ${_cray_minimal_version}!")
+endif()
+
 # Fixes linker errors with Cray compiler
 add_flag(CMAKE_EXE_LINKER_FLAGS "-dynamic -L/opt/gcc/4.9.3/snos/lib64")
 
diff --git a/cmake/compileroptions/FujitsuClang.cmake b/cmake/compileroptions/FujitsuClang.cmake
index 0d7f9282f..feb790871 100644
--- a/cmake/compileroptions/FujitsuClang.cmake
+++ b/cmake/compileroptions/FujitsuClang.cmake
@@ -1,5 +1,10 @@
 message(STATUS "Setting FujitsuClang specific compiler options")
 
+set(_clang_minimal_version 7)
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_clang_minimal_version})
+ message(FATAL_ERROR "Clang version must be at least ${_clang_minimal_version}!")
+endif()
+
 add_flag(CMAKE_CXX_FLAGS
          "-Wall -Wconversion -Wshadow -Wno-c++11-extensions -Qunused-arguments")
 
@@ -37,4 +42,4 @@ if(WALBERLA_BUILD_WITH_LIKWID_MARKERS)
         OFF
         CACHE BOOL "Compile in markers for likwid-perfctr" FORCE)
   endif()
-endif()
+endif()
\ No newline at end of file
diff --git a/cmake/compileroptions/GNU.cmake b/cmake/compileroptions/GNU.cmake
index b9839cf45..1e1e81b69 100644
--- a/cmake/compileroptions/GNU.cmake
+++ b/cmake/compileroptions/GNU.cmake
@@ -1,7 +1,8 @@
 message(STATUS "Setting GNU specific compiler options")
 
-if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
-  message(FATAL_ERROR "GCC version must be at least 8!")
+set(_gcc_minimal_version 8)
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_gcc_minimal_version})
+  message(FATAL_ERROR "GCC version must be at least ${_gcc_minimal_version}!")
 endif()
 
 # Profile guided optimization
@@ -106,4 +107,4 @@ endif()
 if(WALBERLA_BUILD_WITH_GCOV AND CMAKE_COMPILER_IS_GNUCXX)
   add_flag(CMAKE_CXX_FLAGS "--coverage")
 endif()
-# ##############################################################################
+# ##############################################################################
\ No newline at end of file
diff --git a/cmake/compileroptions/IBM.cmake b/cmake/compileroptions/IBM.cmake
index 6b6a2617d..6c475c84f 100644
--- a/cmake/compileroptions/IBM.cmake
+++ b/cmake/compileroptions/IBM.cmake
@@ -1,7 +1,8 @@
 message(STATUS "Setting IBM specific compiler options")
 
-if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.1.1)
-  message(FATAL_ERROR "IBM compiler version must be at least 17.1.1!")
+set(_ibm_minimal_version 17.1.1)
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_ibm_minimal_version})
+  message(FATAL_ERROR "IBM compiler version must be at least ${_ibm_minimal_version}!")
 endif()
 
 # Fixes linker errors with IBM compiler
@@ -26,4 +27,4 @@ add_flag(CMAKE_C_FLAGS "-qsuppress=1500-030") # 1500-030: (I) INFORMATION: [...]
                                               # Additional optimization may be
                                               # attained by recompiling and
                                               # specifying MAXMEM option with a
-                                              # value greater than 8192.
+                                              # value greater than 8192.
\ No newline at end of file
diff --git a/cmake/compileroptions/Intel.cmake b/cmake/compileroptions/Intel.cmake
index ef0d1a8df..b70664a05 100644
--- a/cmake/compileroptions/Intel.cmake
+++ b/cmake/compileroptions/Intel.cmake
@@ -1,5 +1,10 @@
 message(STATUS "Setting Intel specific compiler options")
 
+set(_intel_minimal_version 19.0.0)
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_intel_minimal_version})
+  message(FATAL_ERROR "IBM compiler version must be at least ${_intel_minimal_version}!")
+endif()
+
 if(WALBERLA_PROFILE_GENERATE)
   add_flag(CMAKE_CXX_FLAGS "-prof-gen")
   file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/profile")
@@ -72,4 +77,4 @@ if(WALBERLA_BUILD_WITH_GPROF)
 endif()
 
 # Intel C++17 support introduced in 2.6.2 (https://github.com/pybind/pybind11/pull/2729)
-set(PYBIND11_MINIMUM_VERSION "2.6.2")
+set(PYBIND11_MINIMUM_VERSION "2.6.2")
\ No newline at end of file
diff --git a/cmake/compileroptions/IntelLLVM.cmake b/cmake/compileroptions/IntelLLVM.cmake
index 82bdd400c..03d41f83d 100644
--- a/cmake/compileroptions/IntelLLVM.cmake
+++ b/cmake/compileroptions/IntelLLVM.cmake
@@ -1,5 +1,10 @@
 message(STATUS "Setting IntelLLVM specific compiler options")
 
+set(_intel_llvm_minimal_version 2021.0)
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_intel_llvm_minimal_version})
+  message(FATAL_ERROR "IBM compiler version must be at least ${_intel_llvm_minimal_version}!")
+endif()
+
 # fastmath
 if(NOT WALBERLA_BUILD_WITH_FASTMATH)
   add_flag(CMAKE_CXX_FLAGS "-fp-model=precise")
@@ -40,4 +45,4 @@ if(WALBERLA_BUILD_WITH_OPENMP)
     )
     add_flag(CMAKE_CXX_FLAGS "-Wno-sign-conversion")
   endif()
-endif()
+endif()
\ No newline at end of file
diff --git a/cmake/compileroptions/MSVC.cmake b/cmake/compileroptions/MSVC.cmake
index 4bd400df5..bbf7de295 100644
--- a/cmake/compileroptions/MSVC.cmake
+++ b/cmake/compileroptions/MSVC.cmake
@@ -1,7 +1,8 @@
 message(STATUS "Setting MSVC specific compiler options")
 
-if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.11)
-  message(FATAL_ERROR "MSVC version must be at least 19.11!")
+set(_msvc_minimal_version 19.11)
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_msvc_minimal_version})
+  message(FATAL_ERROR "MSVC version must be at least ${_msvc_minimal_version}!")
 endif()
 
 if(WALBERLA_PROFILE_GENERATE)
@@ -81,4 +82,4 @@ string(REPLACE "/Od" "/O2" CMAKE_CXX_FLAGS_DEBUGOPTIMIZED
 string(REPLACE "/Ob0" "/Ob2" CMAKE_CXX_FLAGS_DEBUGOPTIMIZED
                ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED})
 string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUGOPTIMIZED
-               ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED})
+               ${CMAKE_CXX_FLAGS_DEBUGOPTIMIZED})
\ No newline at end of file
-- 
GitLab