From: Alexander Alekhin Date: Fri, 7 Oct 2016 14:31:21 +0000 (+0300) Subject: cmake: fix ocv_check_compiler_flag X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1504^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6cfe4a85f765715ad4325a04fdf47c974abb5fa6;p=platform%2Fupstream%2Fopencv.git cmake: fix ocv_check_compiler_flag --- diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index c680281..34b4565 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -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)