OpenCV SuperBuild fails with gcc 7+
Description
At some point gcc changed the output of its -dumpversion
argument. This breaks OpenCV's cmake/OpenCVDetectCXXCompiler.cmake
which parses this output.
When building OTB SuperBuild the error in OPENCV/src/OPENCV-stamp/OPENCV-configure-err.log
is:
CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:82 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:91 (include)
CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:83 (list):
list GET given empty list
Call Stack (most recent call first):
CMakeLists.txt:91 (include)
CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:86 (math):
math cannot parse the expression: "*100 + ": syntax error, unexpected
exp_TIMES, expecting exp_PLUS or exp_MINUS or exp_OPENPARENT or exp_NUMBER
(1)
Call Stack (most recent call first):
CMakeLists.txt:91 (include)
CMake Error at cmake/OpenCVCompilerOptions.cmake:21 (else):
A duplicate ELSE command was found inside an IF block.
Call Stack (most recent call first):
CMakeLists.txt:432 (include)
This is fixed in more recent version of OpenCV. See this commit from 2015 for example: https://github.com/opencv/opencv/commit/bbe007159ad6b99e15f47171b7b6be7c892ca9fa#diff-b119273dbadd24865d7eb8b2c2aa1f47
The latest version of that file in OpenCV does not even rely on -dumpversion anymore.
What is the proper OTB fix? A superbuild patch or maybe upgrade opencv?
Steps to reproduce
SuperBuild with gcc 7.
Configuration information
Ubuntu 17.10, gcc 7.
Edited by Victor Poughon