From a70a39d2cc4288e5d34588b14bbda64f8b1d822f Mon Sep 17 00:00:00 2001 From: Florent Pruvost <florent.pruvost@inria.fr> Date: Fri, 24 Nov 2023 13:25:19 +0100 Subject: [PATCH] GenPkgConfig.cmake: fix windows case and add comments --- modules/GenPkgConfig.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/GenPkgConfig.cmake b/modules/GenPkgConfig.cmake index 70647cd..ef8fe04 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) -- GitLab