CMake: when compiler is too old, report found version

To aid in debugging the case where your compiler is too old for Blender,
actually log which version CMake found.

Before, CMake would output:
```
CMake Error at CMakeLists.txt:121 (message):
  The minimum supported version of GCC is 11.0.0
```

With the patch, it logs:
```
CMake Error at CMakeLists.txt:121 (message):
  The minimum supported version of GCC is 11.0.0, found 10.4.0
```

This has been implemented for GCC and Clang. MSVC has been explicitly
excluded, as the version numbers used for this comparison are internal
versions and not directly usable/recognisable.

Reviewed By: LazyDodo, brecht

Differential Revision: https://developer.blender.org/D16849
This commit is contained in:
Sybren A. Stüvel 2023-01-05 11:34:11 +01:00
parent 200a114e15
commit 963600ddc0

@ -118,14 +118,18 @@ enable_testing()
if(CMAKE_COMPILER_IS_GNUCC)
if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "11.0.0")
message(FATAL_ERROR "The minimum supported version of GCC is 11.0.0")
message(FATAL_ERROR "The minimum supported version of GCC is 11.0.0, found ${CMAKE_C_COMPILER_VERSION}")
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_COMPILER_IS_GNUCC AND ("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "8.0"))
message(FATAL_ERROR "The minimum supported version of CLANG is 8.0")
message(FATAL_ERROR "The minimum supported version of CLANG is 8.0, found ${CMAKE_C_COMPILER_VERSION}")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
if(MSVC_VERSION VERSION_LESS "1928")
# MSVC_VERSION is an internal version number, it doesn't map to something
# the end user would recognize as a version. Because of this, for MSVC we do
# not show the found number. When using our make.bat the actual VS version
# will be displayed on the console before starting the build, anyway.
message(FATAL_ERROR "The minimum supported version of MSVC is 2019 (16.9.16)")
endif()
endif()