mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
Merge topic 'FindPkgConfigAlwaysAddTarget'
6f14205e08FindPkgConfig: Always create the imported target07d6390728Tests: Add case covering FindPkgConfig creation of empty targets Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6113
This commit is contained in:
@@ -265,9 +265,7 @@ endfunction()
|
||||
|
||||
# create an imported target from all the information returned by pkg-config
|
||||
function(_pkg_create_imp_target _prefix _imp_target_global)
|
||||
# only create the target if it is linkable, i.e. no executables
|
||||
if (NOT TARGET PkgConfig::${_prefix}
|
||||
AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_LDFLAGS_OTHER OR ${_prefix}_CFLAGS_OTHER ))
|
||||
if (NOT TARGET PkgConfig::${_prefix})
|
||||
if(${_imp_target_global})
|
||||
set(_global_opt "GLOBAL")
|
||||
else()
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Prepare environment to reuse empty.pc
|
||||
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-empty/lib/pkgconfig" PC_PATH)
|
||||
if(UNIX)
|
||||
string(REPLACE "\\ " " " PC_PATH "${PC_PATH}")
|
||||
endif()
|
||||
set(ENV{PKG_CONFIG_PATH} "${PC_PATH}")
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_search_module(Empty REQUIRED empty IMPORTED_TARGET)
|
||||
|
||||
if(NOT Empty_MODULE_NAME STREQUAL "empty")
|
||||
message(FATAL_ERROR "Wrong value for Empty_MODULE_NAME. Expected: empty, got: ${Empty_MODULE_NAME}")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET PkgConfig::Empty)
|
||||
message(FATAL_ERROR "PkgConfig::Empty target not created")
|
||||
endif()
|
||||
@@ -29,4 +29,5 @@ if (PKG_CONFIG_FOUND)
|
||||
run_cmake(FindPkgConfig_IMPORTED_TARGET)
|
||||
run_cmake(FindPkgConfig_VERSION_OPERATORS)
|
||||
run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME)
|
||||
run_cmake(FindPkgConfig_empty_target)
|
||||
endif ()
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Name: Empty
|
||||
Description: Dummy package to test empty target
|
||||
Version: 1.0
|
||||
Libs:
|
||||
Cflags:
|
||||
Reference in New Issue
Block a user