diff --git a/CMake/GeneratePkgConfig.cmake b/CMake/GeneratePkgConfig.cmake index 653300ea1..dc26c0d21 100644 --- a/CMake/GeneratePkgConfig.cmake +++ b/CMake/GeneratePkgConfig.cmake @@ -1,13 +1,15 @@ -function(get_relative_link REL PATH) +function(get_relative_link OUTPUT PATH) get_filename_component(NAME ${PATH} NAME_WE) - if(${NAME} MATCHES "^lib") + if (${PATH} MATCHES "^[$]<[$]:") + set(LINK "") + elseif (${NAME} MATCHES "^lib") string(REGEX REPLACE "^lib" "-l" LINK ${NAME}) - elseif(${NAME} MATCHES "^-") + elseif (${NAME} MATCHES "^-") set(LINK ${NAME}) else() string(CONCAT LINK "-l" ${NAME}) endif() - set(${REL} ${LINK} PARENT_SCOPE) + set(${OUTPUT} ${LINK} PARENT_SCOPE) endfunction() function(generate_pkgconfig TARGET DESCRIPTION) @@ -17,24 +19,26 @@ function(generate_pkgconfig TARGET DESCRIPTION) get_target_property(LIST ${TARGET} LINK_LIBRARIES) set(REQS "") set(LIBS "") - foreach(LIB ${LIST}) - if(TARGET ${LIB}) + foreach (LIB ${LIST}) + if (TARGET ${LIB}) set(HAS_REQS 1) list(APPEND REQS ${LIB}) else() set(HAS_LIBS 1) get_relative_link(LINK ${LIB}) - list(APPEND LIBS ${LINK}) + if (NOT LINK EQUAL "") + list(APPEND LIBS ${LINK}) + endif() endif() endforeach() - if(HAS_REQS) + if (HAS_REQS) set(REQUIRES "\nRequires.private:") foreach (REQ ${REQS}) set(REQUIRES "${REQUIRES} ${REQ}") endforeach() endif() - if(HAS_LIBS) + if (HAS_LIBS) set(LIBRARIES "\nLibs.private:") foreach (LIB ${LIBS}) set(LIBRARIES "${LIBRARIES} ${LIB}")