cmake: make pkg-config package name independent of target name

This commit is contained in:
Eugene Shalygin 2018-11-12 12:52:34 +01:00 committed by Arvid Norberg
parent a233d3cc28
commit 5c533522cb
3 changed files with 6 additions and 4 deletions

View File

@ -408,7 +408,7 @@ foreach (s ${COMPILETIME_OPTIONS_LIST})
set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}") set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}")
endforeach (s) endforeach (s)
generate_and_install_pkg_config_file(torrent-rasterbar) generate_and_install_pkg_config_file(torrent-rasterbar libtorrent-rasterbar)
install(TARGETS torrent-rasterbar EXPORT LibtorrentRasterbarTargets install(TARGETS torrent-rasterbar EXPORT LibtorrentRasterbarTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

View File

@ -136,7 +136,7 @@ function(_expand_targets _targets _libraries_var _include_dirs_var _compile_opti
endfunction() endfunction()
# Generates and installs a pkg-config file for a given target # Generates and installs a pkg-config file for a given target
function(generate_and_install_pkg_config_file _target) function(generate_and_install_pkg_config_file _target _packageName)
# collect target properties # collect target properties
_expand_targets(${_target} _expand_targets(${_target}
_interface_link_libraries _interface_include_dirs _interface_link_libraries _interface_include_dirs
@ -147,6 +147,8 @@ function(generate_and_install_pkg_config_file _target)
set(_output_name "${_target}") set(_output_name "${_target}")
endif() endif()
set(_package_name "${_packageName}")
# remove standard include directories # remove standard include directories
foreach(d IN LISTS CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES) foreach(d IN LISTS CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
list(REMOVE_ITEM _interface_include_dirs "${d}") list(REMOVE_ITEM _interface_include_dirs "${d}")

View File

@ -48,5 +48,5 @@ cmake_list_to_pkg_config(_interface_include_dirs "${_TARGET_INTERFACE_INCLUDE_DI
set(_interface_compile_options "${_TARGET_INTERFACE_COMPILE_OPTIONS}") set(_interface_compile_options "${_TARGET_INTERFACE_COMPILE_OPTIONS}")
string(REPLACE ";" " " _interface_compile_options "${_interface_compile_options}") string(REPLACE ";" " " _interface_compile_options "${_interface_compile_options}")
configure_file("@_pkg_config_file_template_filename@" "@_generate_target_dir@/@_output_name@.pc" @ONLY) configure_file("@_pkg_config_file_template_filename@" "@_generate_target_dir@/@_package_name@.pc" @ONLY)
file(INSTALL "@_generate_target_dir@/@_output_name@.pc" DESTINATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/pkgconfig") file(INSTALL "@_generate_target_dir@/@_package_name@.pc" DESTINATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/pkgconfig")