cmake: fix ocv_check_compiler_flag

This commit is contained in:
Alexander Alekhin 2016-10-07 17:31:21 +03:00 committed by Alexander Alekhin
parent dd379ec9fd
commit 6cfe4a85f7

View File

@ -199,7 +199,7 @@ set(OCV_COMPILER_FAIL_REGEX
"[Uu]nknown option" # HP
"[Ww]arning: [Oo]ption" # SunPro
"command option .* is not recognized" # XL
"not supported in this configuration; ignored" # AIX
"not supported in this configuration, ignored" # AIX (';' is replaced with ',')
"File with unknown suffix passed to linker" # PGI
"WARNING: unknown flag:" # Open64
)
@ -238,12 +238,25 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
COMPILE_DEFINITIONS "${FLAG}"
OUTPUT_VARIABLE OUTPUT)
FOREACH(_regex ${OCV_COMPILER_FAIL_REGEX})
IF("${OUTPUT}" MATCHES "${_regex}")
SET(${RESULT} 0)
break()
ENDIF()
ENDFOREACH()
if(${RESULT})
string(REPLACE ";" "," OUTPUT_LINES "${OUTPUT}")
string(REPLACE "\n" ";" OUTPUT_LINES "${OUTPUT_LINES}")
foreach(_regex ${OCV_COMPILER_FAIL_REGEX})
if(NOT ${RESULT})
break()
endif()
foreach(_line ${OUTPUT_LINES})
if("${_line}" MATCHES "${_regex}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Build output check failed:\n"
" Regex: '${_regex}'\n"
" Output line: '${_line}'\n")
set(${RESULT} 0)
break()
endif()
endforeach()
endforeach()
endif()
IF(${RESULT})
SET(${RESULT} 1 CACHE INTERNAL "Test ${RESULT}")
@ -251,6 +264,13 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
ELSE(${RESULT})
MESSAGE(STATUS "Performing Test ${RESULT} - Failed")
SET(${RESULT} "" CACHE INTERNAL "Test ${RESULT}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Compilation failed:\n"
" source file: '${_fname}'\n"
" check option: '${FLAG}'\n"
"===== BUILD LOG =====\n"
"${OUTPUT}\n"
"===== END =====\n\n")
ENDIF(${RESULT})
else()
SET(${RESULT} 0)