Don't skip entire use_pkg_config_module if target exists

Otherwise the same library can not be added to another library
variable.
This commit is contained in:
Martchus 2019-07-09 18:36:28 +02:00
parent 1be20da35a
commit 81a3d4fa94
1 changed files with 19 additions and 21 deletions

View File

@ -235,11 +235,8 @@ function (use_pkg_config_module)
endif ()
endif ()
# skip if target has already been added
if (TARGET "${ARGS_TARGET_NAME}")
return()
endif ()
# add target only if it has not already been added; otherwise just add the existing target to the library variable
if (NOT TARGET "${ARGS_TARGET_NAME}")
find_package(PkgConfig)
pkg_check_modules(PKG_CHECK_MODULES_RESULT ${ARGS_PKG_CHECK_MODULES} ${ARGS_PKG_CONFIG_MODULES})
@ -258,6 +255,7 @@ function (use_pkg_config_module)
PROPERTY INTERFACE_COMPILE_OPTIONS "${PKG_CHECK_MODULES_RESULT${PKG_CONFIG_CHECK_SUFFIX}_CFLAGS_OTHER}")
set_property(TARGET ${ARGS_TARGET_NAME}
PROPERTY INTERFACE_LINK_OPTIONS "${PKG_CHECK_MODULES_RESULT${PKG_CONFIG_CHECK_SUFFIX}_LDFLAGS_OTHER}")
endif ()
set("${ARGS_PKG_CONFIG_MODULES_VARIABLE}" "${${ARGS_PKG_CONFIG_MODULES_VARIABLE}};${ARGS_TARGET_NAME}" PARENT_SCOPE)
set("${ARGS_LIBRARIES_VARIABLE}" "${${ARGS_LIBRARIES_VARIABLE}};${ARGS_TARGET_NAME}" PARENT_SCOPE)