diff --git a/cmake/OpenCVGenPkgconfig.cmake b/cmake/OpenCVGenPkgconfig.cmake index 7bfc7bc5a..a36b70e94 100644 --- a/cmake/OpenCVGenPkgconfig.cmake +++ b/cmake/OpenCVGenPkgconfig.cmake @@ -57,8 +57,17 @@ endforeach() # add extra dependencies required for OpenCV set(OpenCV_LIB_COMPONENTS ${OpenCV_LIB_COMPONENTS_}) if(OpenCV_EXTRA_COMPONENTS) - string(REPLACE ";" " " OpenCV_EXTRA_COMPONENTS "${OpenCV_EXTRA_COMPONENTS}") - set(OpenCV_LIB_COMPONENTS "${OpenCV_LIB_COMPONENTS} ${OpenCV_EXTRA_COMPONENTS}") + foreach(extra_component ${OpenCV_EXTRA_COMPONENTS}) + + if(extra_component MATCHES "^-[lL]" OR extra_component MATCHES "[\\/]") + set(maybe_l_prefix "") + else() + set(maybe_l_prefix "-l") + endif() + + set(OpenCV_LIB_COMPONENTS "${OpenCV_LIB_COMPONENTS} ${maybe_l_prefix}${extra_component}") + + endforeach() endif() #generate the .pc file