cmake: fix try_compile() with --coverage flags

pull/8443/head
Alexander Alekhin 8 years ago
parent f70cc29edb
commit 69df0eee77
  1. 4
      CMakeLists.txt
  2. 1
      cmake/OpenCVCompilerOptions.cmake
  3. 1
      cmake/OpenCVUtils.cmake

@ -95,6 +95,10 @@ if(POLICY CMP0051)
cmake_policy(SET CMP0051 NEW)
endif()
if(POLICY CMP0056)
cmake_policy(SET CMP0056 NEW)
endif()
include(cmake/OpenCVUtils.cmake)
# must go before the project command

@ -192,6 +192,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
if(ENABLE_COVERAGE)
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} --coverage")
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} --coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
if(ENABLE_INSTRUMENTATION)

@ -260,6 +260,7 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
TRY_COMPILE(${RESULT}
"${CMAKE_BINARY_DIR}"
"${_fname}"
CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" # CMP0056 do this on new CMake
COMPILE_DEFINITIONS "${FLAG}"
OUTPUT_VARIABLE OUTPUT)

Loading…
Cancel
Save