|
@@ -183,8 +183,8 @@ endfunction()
|
|
|
|
|
|
|
|
# scan the LDFLAGS returned by pkg-config for library directories and
|
|
# scan the LDFLAGS returned by pkg-config for library directories and
|
|
|
# libraries, figure out the absolute paths of that libraries in the
|
|
# libraries, figure out the absolute paths of that libraries in the
|
|
|
-# given directories, and create an imported target from them
|
|
|
|
|
-function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_path)
|
|
|
|
|
|
|
+# given directories
|
|
|
|
|
+function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path)
|
|
|
unset(_libs)
|
|
unset(_libs)
|
|
|
unset(_find_opts)
|
|
unset(_find_opts)
|
|
|
|
|
|
|
@@ -221,18 +221,23 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
|
|
|
list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}")
|
|
list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}")
|
|
|
endforeach()
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
+ set(${_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE)
|
|
|
|
|
+endfunction()
|
|
|
|
|
+
|
|
|
|
|
+# create an imported target from all the information returned by pkg-config
|
|
|
|
|
+function(_pkg_create_imp_target _prefix)
|
|
|
# only create the target if it is linkable, i.e. no executables
|
|
# only create the target if it is linkable, i.e. no executables
|
|
|
if (NOT TARGET PkgConfig::${_prefix}
|
|
if (NOT TARGET PkgConfig::${_prefix}
|
|
|
- AND ( ${_prefix}_INCLUDE_DIRS OR _libs OR ${_prefix}_CFLAGS_OTHER ))
|
|
|
|
|
|
|
+ AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_CFLAGS_OTHER ))
|
|
|
add_library(PkgConfig::${_prefix} INTERFACE IMPORTED)
|
|
add_library(PkgConfig::${_prefix} INTERFACE IMPORTED)
|
|
|
|
|
|
|
|
if(${_prefix}_INCLUDE_DIRS)
|
|
if(${_prefix}_INCLUDE_DIRS)
|
|
|
set_property(TARGET PkgConfig::${_prefix} PROPERTY
|
|
set_property(TARGET PkgConfig::${_prefix} PROPERTY
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}")
|
|
INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}")
|
|
|
endif()
|
|
endif()
|
|
|
- if(_libs)
|
|
|
|
|
|
|
+ if(${_prefix}_LINK_LIBRARIES)
|
|
|
set_property(TARGET PkgConfig::${_prefix} PROPERTY
|
|
set_property(TARGET PkgConfig::${_prefix} PROPERTY
|
|
|
- INTERFACE_LINK_LIBRARIES "${_libs}")
|
|
|
|
|
|
|
+ INTERFACE_LINK_LIBRARIES "${${_prefix}_LINK_LIBRARIES}")
|
|
|
endif()
|
|
endif()
|
|
|
if(${_prefix}_CFLAGS_OTHER)
|
|
if(${_prefix}_CFLAGS_OTHER)
|
|
|
set_property(TARGET PkgConfig::${_prefix} PROPERTY
|
|
set_property(TARGET PkgConfig::${_prefix} PROPERTY
|
|
@@ -241,6 +246,15 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
|
|
|
endif()
|
|
endif()
|
|
|
endfunction()
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
+# recalculate the dynamic output
|
|
|
|
|
+# this is a macro and not a function so the result of _pkg_find_libs is automatically propagated
|
|
|
|
|
+macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target)
|
|
|
|
|
+ _pkg_find_libs(${_prefix} ${_no_cmake_path} ${_no_cmake_environment_path})
|
|
|
|
|
+ if(${_imp_target})
|
|
|
|
|
+ _pkg_create_imp_target(${_prefix})
|
|
|
|
|
+ endif()
|
|
|
|
|
+endmacro()
|
|
|
|
|
+
|
|
|
###
|
|
###
|
|
|
macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _prefix)
|
|
macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _prefix)
|
|
|
_pkgconfig_unset(${_prefix}_FOUND)
|
|
_pkgconfig_unset(${_prefix}_FOUND)
|
|
@@ -460,9 +474,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
|
|
|
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags )
|
|
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags )
|
|
|
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other )
|
|
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other )
|
|
|
|
|
|
|
|
- if (_imp_target)
|
|
|
|
|
- _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path})
|
|
|
|
|
- endif()
|
|
|
|
|
|
|
+ _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target})
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT "${_extra_paths}" STREQUAL "")
|
|
if(NOT "${_extra_paths}" STREQUAL "")
|
|
@@ -525,6 +537,7 @@ endmacro()
|
|
|
|
|
|
|
|
<XXX>_FOUND ... set to 1 if module(s) exist
|
|
<XXX>_FOUND ... set to 1 if module(s) exist
|
|
|
<XXX>_LIBRARIES ... only the libraries (without the '-l')
|
|
<XXX>_LIBRARIES ... only the libraries (without the '-l')
|
|
|
|
|
+ <XXX>_LINK_LIBRARIES ... the libraries and their absolute paths
|
|
|
<XXX>_LIBRARY_DIRS ... the paths of the libraries (without the '-L')
|
|
<XXX>_LIBRARY_DIRS ... the paths of the libraries (without the '-L')
|
|
|
<XXX>_LDFLAGS ... all required linker flags
|
|
<XXX>_LDFLAGS ... all required linker flags
|
|
|
<XXX>_LDFLAGS_OTHER ... all other linker flags
|
|
<XXX>_LDFLAGS_OTHER ... all other linker flags
|
|
@@ -592,8 +605,10 @@ macro(pkg_check_modules _prefix _module0)
|
|
|
if (${_prefix}_FOUND)
|
|
if (${_prefix}_FOUND)
|
|
|
_pkgconfig_set(__pkg_config_arguments_${_prefix} "${_module0};${ARGN}")
|
|
_pkgconfig_set(__pkg_config_arguments_${_prefix} "${_module0};${ARGN}")
|
|
|
endif()
|
|
endif()
|
|
|
- elseif (${_prefix}_FOUND AND ${_imp_target})
|
|
|
|
|
- _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path})
|
|
|
|
|
|
|
+ else()
|
|
|
|
|
+ if (${_prefix}_FOUND)
|
|
|
|
|
+ _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target})
|
|
|
|
|
+ endif()
|
|
|
endif()
|
|
endif()
|
|
|
endmacro()
|
|
endmacro()
|
|
|
|
|
|
|
@@ -646,8 +661,8 @@ macro(pkg_search_module _prefix _module0)
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
|
|
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
|
|
|
- elseif (${_prefix}_FOUND AND ${_imp_target})
|
|
|
|
|
- _pkg_create_imp_target("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path})
|
|
|
|
|
|
|
+ elseif (${_prefix}_FOUND)
|
|
|
|
|
+ _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target})
|
|
|
endif()
|
|
endif()
|
|
|
endmacro()
|
|
endmacro()
|
|
|
|
|
|