1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 02:17:27 +08:00

Features: Add compiler version support to WriteCompilerDetectionHeader.

This commit is contained in:
Stephen Kelly
2014-06-05 13:16:56 +02:00
parent b70295760c
commit ddec418a8f
3 changed files with 69 additions and 1 deletions

View File

@@ -35,6 +35,10 @@ if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES)
return()
endif()
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" COMPILER_VERSION_MAJOR "${CMAKE_CXX_COMPILER_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINOR "${CMAKE_CXX_COMPILER_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_CXX_COMPILER_VERSION}")
macro(set_defines target true_defs false_defs)
set(defines)
foreach(def ${true_defs})
@@ -46,6 +50,9 @@ macro(set_defines target true_defs false_defs)
target_compile_definitions(${target}
PRIVATE
${defines}
EXPECTED_COMPILER_VERSION_MAJOR=${COMPILER_VERSION_MAJOR}
EXPECTED_COMPILER_VERSION_MINOR=${COMPILER_VERSION_MINOR}
EXPECTED_COMPILER_VERSION_PATCH=${COMPILER_VERSION_PATCH}
)
endmacro()

View File

@@ -13,6 +13,18 @@
#error cxx_variadic_templates expected availability did not match.
#endif
#if !CHECK(VERSION_MAJOR)
#error Compiler major version did not match.
#endif
#if !CHECK(VERSION_MINOR)
#error Compiler minor version did not match.
#endif
#if !CHECK(VERSION_PATCH)
#error Compiler patch version did not match.
#endif
int main()
{
return 0;