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) 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}) string(REGEX REPLACE "^lib" "-l" LINK ${NAME})
elseif(${NAME} MATCHES "^-") elseif (${NAME} MATCHES "^-")
set(LINK ${NAME}) set(LINK ${NAME})
else() else()
string(CONCAT LINK "-l" ${NAME}) string(CONCAT LINK "-l" ${NAME})
endif() endif()
set(${REL} ${LINK} PARENT_SCOPE) set(${OUTPUT} ${LINK} PARENT_SCOPE)
endfunction() endfunction()
function(generate_pkgconfig TARGET DESCRIPTION) function(generate_pkgconfig TARGET DESCRIPTION)
@ -17,24 +19,26 @@ function(generate_pkgconfig TARGET DESCRIPTION)
get_target_property(LIST ${TARGET} LINK_LIBRARIES) get_target_property(LIST ${TARGET} LINK_LIBRARIES)
set(REQS "") set(REQS "")
set(LIBS "") set(LIBS "")
foreach(LIB ${LIST}) foreach (LIB ${LIST})
if(TARGET ${LIB}) if (TARGET ${LIB})
set(HAS_REQS 1) set(HAS_REQS 1)
list(APPEND REQS ${LIB}) list(APPEND REQS ${LIB})
else() else()
set(HAS_LIBS 1) set(HAS_LIBS 1)
get_relative_link(LINK ${LIB}) get_relative_link(LINK ${LIB})
list(APPEND LIBS ${LINK}) if (NOT LINK EQUAL "")
list(APPEND LIBS ${LINK})
endif()
endif() endif()
endforeach() endforeach()
if(HAS_REQS) if (HAS_REQS)
set(REQUIRES "\nRequires.private:") set(REQUIRES "\nRequires.private:")
foreach (REQ ${REQS}) foreach (REQ ${REQS})
set(REQUIRES "${REQUIRES} ${REQ}") set(REQUIRES "${REQUIRES} ${REQ}")
endforeach() endforeach()
endif() endif()
if(HAS_LIBS) if (HAS_LIBS)
set(LIBRARIES "\nLibs.private:") set(LIBRARIES "\nLibs.private:")
foreach (LIB ${LIBS}) foreach (LIB ${LIBS})
set(LIBRARIES "${LIBRARIES} ${LIB}") set(LIBRARIES "${LIBRARIES} ${LIB}")