From f425a3818abe653d5fffd358a3fb2e50478c7e93 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 05b390c2f..8c7dfe0b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -740,7 +740,7 @@ if(developer-options) ENABLED TORRENT_PROFILE_CALLS=1) endif() -generate_and_install_pkg_config_file(torrent-rasterbar) +generate_and_install_pkg_config_file(torrent-rasterbar libtorrent-rasterbar) include(CheckCXXCompilerFlag) 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")