Selaa lähdekoodia

Compiler ID: Compiler versions must be a valid, numeric version string.

This test helps catch errors in compiler identification.
James Johnston 10 vuotta sitten
vanhempi
sitoutus
25211d756f

+ 7 - 0
Tests/CMakeOnly/CompilerIdC/CMakeLists.txt

@@ -12,3 +12,10 @@ foreach(v
     message(SEND_ERROR "${v} not set!")
   endif()
 endforeach()
+
+# Version numbers may only contain numbers and periods.
+if(NOT CMAKE_C_COMPILER_VERSION MATCHES
+    "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?$"
+    )
+  message(SEND_ERROR "Compiler version is not numeric!")
+endif()

+ 7 - 0
Tests/CMakeOnly/CompilerIdCXX/CMakeLists.txt

@@ -12,3 +12,10 @@ foreach(v
     message(SEND_ERROR "${v} not set!")
   endif()
 endforeach()
+
+# Version numbers may only contain numbers and periods.
+if(NOT CMAKE_CXX_COMPILER_VERSION MATCHES
+    "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?$"
+    )
+  message(SEND_ERROR "Compiler version is not numeric!")
+endif()

+ 7 - 0
Tests/CMakeOnly/CompilerIdFortran/CMakeLists.txt

@@ -12,3 +12,10 @@ foreach(v
     message(SEND_ERROR "${v} not set!")
   endif()
 endforeach()
+
+# Version numbers may only contain numbers and periods.
+if(NOT CMAKE_Fortran_COMPILER_VERSION MATCHES
+    "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?(\\.([0-9]+))?$"
+    )
+  message(SEND_ERROR "Compiler version is not numeric!")
+endif()