Skip to content

Commit 2271b9a

Browse files
committed
Merge pull request opencv#8443 from alalek:fix_coverage_trycompile
2 parents f70cc29 + 69df0ee commit 2271b9a

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ if(POLICY CMP0051)
9595
cmake_policy(SET CMP0051 NEW)
9696
endif()
9797

98+
if(POLICY CMP0056)
99+
cmake_policy(SET CMP0056 NEW)
100+
endif()
101+
98102
include(cmake/OpenCVUtils.cmake)
99103

100104
# must go before the project command

cmake/OpenCVCompilerOptions.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
192192
if(ENABLE_COVERAGE)
193193
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} --coverage")
194194
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} --coverage")
195+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
195196
endif()
196197

197198
if(ENABLE_INSTRUMENTATION)

cmake/OpenCVUtils.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
260260
TRY_COMPILE(${RESULT}
261261
"${CMAKE_BINARY_DIR}"
262262
"${_fname}"
263+
CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" # CMP0056 do this on new CMake
263264
COMPILE_DEFINITIONS "${FLAG}"
264265
OUTPUT_VARIABLE OUTPUT)
265266

0 commit comments

Comments
 (0)