1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-29 01:33:46 +00:00
dindexer/cmake/Modules/gccversion.cmake

31 lines
1.3 KiB
CMake

if (CMAKE_COMPILER_IS_GNUCXX)
exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE version_string)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CMAKE_CXX_COMPILER_VERSION "${version_string}")
string(REGEX MATCHALL "[0-9]+" version_nums "${CMAKE_CXX_COMPILER_VERSION}")
list(GET version_nums 0 CMAKE_CXX_COMPILER_VERSION_MAJOR)
list(GET version_nums 1 CMAKE_CXX_COMPILER_VERSION_MINOR)
list(GET version_nums 2 CMAKE_CXX_COMPILER_VERSION_PATCH)
unset(version_nums)
unset(version_string)
else()
set(CMAKE_CXX_COMPILER_VERSION "0.0.0")
set(CMAKE_CXX_COMPILER_VERSION_MAJOR "0")
set(CMAKE_CXX_COMPILER_VERSION_MINOR "0")
set(CMAKE_CXX_COMPILER_VERSION_PATCH "0")
endif()
if (CMAKE_COMPILER_IS_GNUCC)
exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE version_string)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CMAKE_C_COMPILER_VERSION "${version_string}")
string(REGEX MATCHALL "[0-9]+" version_nums "${CMAKE_C_COMPILER_VERSION}")
list(GET version_nums 0 CMAKE_C_COMPILER_VERSION_MAJOR)
list(GET version_nums 1 CMAKE_C_COMPILER_VERSION_MINOR)
list(GET version_nums 2 CMAKE_C_COMPILER_VERSION_PATCH)
unset(version_nums)
unset(version_string)
else()
set(CMAKE_C_COMPILER_VERSION "0.0.0")
set(CMAKE_C_COMPILER_VERSION_MAJOR "0")
set(CMAKE_C_COMPILER_VERSION_MINOR "0")
set(CMAKE_C_COMPILER_VERSION_PATCH "0")
endif()