Skip to content

Commit 56b5a7d

Browse files
committed
cmake: fix ENABLE_PROFILING
1 parent 65dbbf7 commit 56b5a7d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cmake/OpenCVCompilerOptions.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,16 @@ if(CV_GCC OR CV_CLANG)
189189

190190
# Profiling?
191191
if(ENABLE_PROFILING)
192-
add_extra_compiler_option("-pg -g")
193192
# turn off incompatible options
194193
foreach(flags CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG
195194
OPENCV_EXTRA_FLAGS_RELEASE OPENCV_EXTRA_FLAGS_DEBUG OPENCV_EXTRA_C_FLAGS OPENCV_EXTRA_CXX_FLAGS)
196195
string(REPLACE "-fomit-frame-pointer" "" ${flags} "${${flags}}")
197196
string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}")
198197
string(REPLACE "-fdata-sections" "" ${flags} "${${flags}}")
199198
endforeach()
199+
# -pg should be placed both in the linker and in the compiler settings
200+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
201+
add_extra_compiler_option("-pg -g")
200202
else()
201203
if(MSVC)
202204
# TODO: Clang/C2 is not supported

0 commit comments

Comments
 (0)