cmake: fix ocv_check_compiler_flag

pull/7428/head
Alexander Alekhin 8 years ago committed by Alexander Alekhin
parent dd379ec9fd
commit 6cfe4a85f7
  1. 34
      cmake/OpenCVUtils.cmake

@ -199,7 +199,7 @@ set(OCV_COMPILER_FAIL_REGEX
"[Uu]nknown option" # HP "[Uu]nknown option" # HP
"[Ww]arning: [Oo]ption" # SunPro "[Ww]arning: [Oo]ption" # SunPro
"command option .* is not recognized" # XL "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 "File with unknown suffix passed to linker" # PGI
"WARNING: unknown flag:" # Open64 "WARNING: unknown flag:" # Open64
) )
@ -238,12 +238,25 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
COMPILE_DEFINITIONS "${FLAG}" COMPILE_DEFINITIONS "${FLAG}"
OUTPUT_VARIABLE OUTPUT) OUTPUT_VARIABLE OUTPUT)
FOREACH(_regex ${OCV_COMPILER_FAIL_REGEX}) if(${RESULT})
IF("${OUTPUT}" MATCHES "${_regex}") string(REPLACE ";" "," OUTPUT_LINES "${OUTPUT}")
SET(${RESULT} 0) string(REPLACE "\n" ";" OUTPUT_LINES "${OUTPUT_LINES}")
break() foreach(_regex ${OCV_COMPILER_FAIL_REGEX})
ENDIF() if(NOT ${RESULT})
ENDFOREACH() 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}) IF(${RESULT})
SET(${RESULT} 1 CACHE INTERNAL "Test ${RESULT}") SET(${RESULT} 1 CACHE INTERNAL "Test ${RESULT}")
@ -251,6 +264,13 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
ELSE(${RESULT}) ELSE(${RESULT})
MESSAGE(STATUS "Performing Test ${RESULT} - Failed") MESSAGE(STATUS "Performing Test ${RESULT} - Failed")
SET(${RESULT} "" CACHE INTERNAL "Test ${RESULT}") 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}) ENDIF(${RESULT})
else() else()
SET(${RESULT} 0) SET(${RESULT} 0)

Loading…
Cancel
Save