Browse Source

Improve pkg-config file generation

* Don't refer to bundles libraries via its imported location
* Add dependencies of imported targets
sendfile
Martchus 3 years ago
parent
commit
79855f285d
  1. 29
      cmake/modules/LibraryTarget.cmake

29
cmake/modules/LibraryTarget.cmake

@ -294,24 +294,39 @@ macro (compute_dependencies_for_package_config
continue()
endif ()
# add library location of the target
if (META_CURRENT_CONFIGURATION)
set(HAS_LIBRARY_LOCATION NO)
if (DEPENDENCY IN_LIST BUNDLED_TARGET)
set(${OUTPUT_VAR_LIBS} "${${OUTPUT_VAR_LIBS}} -l${DEPENDENCY}")
set(HAS_LIBRARY_LOCATION YES)
endif ()
if (NOT HAS_LIBRARY_LOCATION AND META_CURRENT_CONFIGURATION)
get_target_property("${DEPENDENCY_VARNAME}_IMPORTED_LOCATION_${META_CURRENT_CONFIGURATION}" "${DEPENDENCY}"
"IMPORTED_LOCATION_${META_CURRENT_CONFIGURATION}")
if (EXISTS "${${DEPENDENCY_VARNAME}_IMPORTED_LOCATION_${META_CURRENT_CONFIGURATION}}")
set(${OUTPUT_VAR_LIBS}
"${${OUTPUT_VAR_LIBS}} ${${DEPENDENCY_VARNAME}_IMPORTED_LOCATION_${META_CURRENT_CONFIGURATION}}")
continue()
set(HAS_LIBRARY_LOCATION YES)
endif ()
endif ()
get_target_property("${DEPENDENCY_VARNAME}_IMPORTED_LOCATION" "${DEPENDENCY}" IMPORTED_LOCATION)
if (EXISTS "${${DEPENDENCY_VARNAME}_IMPORTED_LOCATION}")
set(${OUTPUT_VAR_LIBS} "${${OUTPUT_VAR_LIBS}} ${${DEPENDENCY_VARNAME}_IMPORTED_LOCATION}")
continue()
if (NOT HAS_LIBRARY_LOCATION)
get_target_property("${DEPENDENCY_VARNAME}_IMPORTED_LOCATION" "${DEPENDENCY}" IMPORTED_LOCATION)
if (EXISTS "${${DEPENDENCY_VARNAME}_IMPORTED_LOCATION}")
set(${OUTPUT_VAR_LIBS} "${${OUTPUT_VAR_LIBS}} ${${DEPENDENCY_VARNAME}_IMPORTED_LOCATION}")
set(HAS_LIBRARY_LOCATION YES)
endif ()
endif ()
# assume the target is a 3rd party library built within the current project as a bundled dependency -> the target
# is supposed to be installed in either a standard search directory or the same directory as this library so a
# simple -l flag should be sufficient
set(${OUTPUT_VAR_LIBS} "${${OUTPUT_VAR_LIBS}} -l${DEPENDENCY}")
if (NOT HAS_LIBRARY_LOCATION)
set(${OUTPUT_VAR_LIBS} "${${OUTPUT_VAR_LIBS}} -l${DEPENDENCY}")
endif ()
get_target_property("${DEPENDENCY_VARNAME}_IMPORTED_LINK_INTERFACE_LIBRARIES" "${DEPENDENCY}" "IMPORTED_LINK_INTERFACE_LIBRARIES")
foreach (LIBRARY ${${DEPENDENCY_VARNAME}_IMPORTED_LINK_INTERFACE_LIBRARIES})
if (NOT TARGET ${LIBRARY} AND EXISTS ${LIBRARY})
set(${OUTPUT_VAR_LIBS} "${${OUTPUT_VAR_LIBS}} ${LIBRARY}")
endif ()
endforeach ()
else ()
# add raw dependency
set(${OUTPUT_VAR_LIBS} "${${OUTPUT_VAR_LIBS}} ${DEPENDENCY}")

Loading…
Cancel
Save