GeneratePkgConfig: ignore DEBUG-only dependencies.

GitOrigin-RevId: f4c551006003879bdb079d36fdf3ef76eb553a14
This commit is contained in:
levlam 2020-10-12 23:10:28 +03:00
parent 885a9d8e9c
commit cb0688d792

View File

@ -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 "^[$]<[$]<CONFIG:DEBUG>:")
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}")