The latest version (5.1.1) of the gnu compiler returns just its major version ("5") when given the "-dumpversion" argument. Gnu compiler developers don't consider this to be an error. A workaround for this case has been made.
This commit is contained in:
parent
484c68cbb8
commit
bbe007159a
@ -76,17 +76,27 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Typical output in CMAKE_OPENCV_GCC_VERSION_FULL: "c+//0 (whatever) 4.2.3 (...)"
|
||||
# Look for the version number
|
||||
# Look for the version number, major.minor.build
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
|
||||
if(NOT CMAKE_GCC_REGEX_VERSION)
|
||||
if(NOT CMAKE_GCC_REGEX_VERSION)#major.minor
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
|
||||
endif()
|
||||
|
||||
# Split the three parts:
|
||||
string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")
|
||||
if(CMAKE_GCC_REGEX_VERSION)
|
||||
# Split the parts:
|
||||
string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")
|
||||
|
||||
list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
|
||||
list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
|
||||
list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
|
||||
list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
|
||||
else()#compiler returned just the major version number
|
||||
string(REGEX MATCH "[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
|
||||
if(NOT CMAKE_GCC_REGEX_VERSION)#compiler did not return anything reasonable
|
||||
set(CMAKE_GCC_REGEX_VERSION "0")
|
||||
message(WARNING "GCC version not detected!")
|
||||
endif()
|
||||
set(CMAKE_OPENCV_GCC_VERSION_MAJOR ${CMAKE_GCC_REGEX_VERSION})
|
||||
set(CMAKE_OPENCV_GCC_VERSION_MINOR 0)
|
||||
endif()
|
||||
|
||||
set(CMAKE_OPENCV_GCC_VERSION ${CMAKE_OPENCV_GCC_VERSION_MAJOR}${CMAKE_OPENCV_GCC_VERSION_MINOR})
|
||||
math(EXPR CMAKE_OPENCV_GCC_VERSION_NUM "${CMAKE_OPENCV_GCC_VERSION_MAJOR}*100 + ${CMAKE_OPENCV_GCC_VERSION_MINOR}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user