From 56b5a7d9772c75795d0b2d644c9ddcbcc42ef03d Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 3 Jul 2020 19:31:41 +0000 Subject: [PATCH] cmake: fix ENABLE_PROFILING --- cmake/OpenCVCompilerOptions.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake index 476156f256..9ac671dd34 100644 --- a/cmake/OpenCVCompilerOptions.cmake +++ b/cmake/OpenCVCompilerOptions.cmake @@ -189,7 +189,6 @@ if(CV_GCC OR CV_CLANG) # Profiling? if(ENABLE_PROFILING) - add_extra_compiler_option("-pg -g") # turn off incompatible options foreach(flags CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG OPENCV_EXTRA_FLAGS_RELEASE OPENCV_EXTRA_FLAGS_DEBUG OPENCV_EXTRA_C_FLAGS OPENCV_EXTRA_CXX_FLAGS) @@ -197,6 +196,9 @@ if(CV_GCC OR CV_CLANG) string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}") string(REPLACE "-fdata-sections" "" ${flags} "${${flags}}") endforeach() + # -pg should be placed both in the linker and in the compiler settings + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") + add_extra_compiler_option("-pg -g") else() if(MSVC) # TODO: Clang/C2 is not supported