diff --git a/modules/GenPkgConfig.cmake b/modules/GenPkgConfig.cmake index 70647cd29c11562ec01420ea87b7b5fd9374c335..ef8fe04ab709e1df5fdecd86a690ee5096fda6e5 100644 --- a/modules/GenPkgConfig.cmake +++ b/modules/GenPkgConfig.cmake @@ -97,8 +97,10 @@ macro(gpc_convert_libstyle_to_pkgconfig _liblist) # Convert to pkg-config file format set(${_liblist}_CPY "${${_liblist}}") set(${_liblist} "") + # we consider a list of libraries as input foreach(_dep ${${_liblist}_CPY}) - if (${_dep} MATCHES "^/") + if (${_dep} MATCHES "^/|^[A-Z]:/") + # case library is an absolute path (e.g. /opt/foo/lib/libfoo.so) get_filename_component(dep_libname ${_dep} NAME) get_filename_component(dep_libdir ${_dep} PATH) foreach( _ext ${CMAKE_FIND_LIBRARY_SUFFIXES} ) @@ -106,10 +108,12 @@ macro(gpc_convert_libstyle_to_pkgconfig _liblist) endforeach() string(REGEX REPLACE "^lib" "" dep_libname "${dep_libname}") list(APPEND ${_liblist} -L${dep_libdir} -l${dep_libname}) - elseif(NOT ${_dep} MATCHES "^-") - list(APPEND ${_liblist} "-l${_dep}") - else() + elseif(${_dep} MATCHES "^-l") + # case library given with -l (e.g. -lfoo) list(APPEND ${_liblist} ${_dep}) + else() + # case library given by name (e.g. foo) + list(APPEND ${_liblist} "-l${_dep}") endif() endforeach() endmacro(gpc_convert_libstyle_to_pkgconfig)