From 5c533522cb8be8390f2e2183a179e5ebab6edfbf Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Mon, 12 Nov 2018 12:52:34 +0100 Subject: [PATCH] cmake: make pkg-config package name independent of target name --- CMakeLists.txt | 2 +- cmake/Modules/GeneratePkgConfig.cmake | 4 +++- cmake/Modules/GeneratePkgConfig/generate-pkg-config.cmake.in | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3adbb0c79..03ad72e8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -408,7 +408,7 @@ foreach (s ${COMPILETIME_OPTIONS_LIST}) set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${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 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/cmake/Modules/GeneratePkgConfig.cmake b/cmake/Modules/GeneratePkgConfig.cmake index f7250e12b..3c4520b22 100644 --- a/cmake/Modules/GeneratePkgConfig.cmake +++ b/cmake/Modules/GeneratePkgConfig.cmake @@ -136,7 +136,7 @@ function(_expand_targets _targets _libraries_var _include_dirs_var _compile_opti endfunction() # 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 _expand_targets(${_target} _interface_link_libraries _interface_include_dirs @@ -147,6 +147,8 @@ function(generate_and_install_pkg_config_file _target) set(_output_name "${_target}") endif() + set(_package_name "${_packageName}") + # remove standard include directories foreach(d IN LISTS CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES) list(REMOVE_ITEM _interface_include_dirs "${d}") diff --git a/cmake/Modules/GeneratePkgConfig/generate-pkg-config.cmake.in b/cmake/Modules/GeneratePkgConfig/generate-pkg-config.cmake.in index 2bd230d12..252589adf 100644 --- a/cmake/Modules/GeneratePkgConfig/generate-pkg-config.cmake.in +++ b/cmake/Modules/GeneratePkgConfig/generate-pkg-config.cmake.in @@ -48,5 +48,5 @@ cmake_list_to_pkg_config(_interface_include_dirs "${_TARGET_INTERFACE_INCLUDE_DI set(_interface_compile_options "${_TARGET_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) -file(INSTALL "@_generate_target_dir@/@_output_name@.pc" DESTINATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/pkgconfig") +configure_file("@_pkg_config_file_template_filename@" "@_generate_target_dir@/@_package_name@.pc" @ONLY) +file(INSTALL "@_generate_target_dir@/@_package_name@.pc" DESTINATION "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/pkgconfig")