mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-26 23:01:04 +08:00
Problem: pkg-config file cannot be used for static linking
Solution: use requires.private, which pkg-config expands recursively so that dependencies of dependencies can be linked against when using pkg-config --static
This commit is contained in:
parent
9d06e29cb2
commit
28d5ce3dfa
@ -70,6 +70,7 @@ endif()
|
|||||||
|
|
||||||
# Will be used to add flags to pkg-config useful when apps want to statically link
|
# Will be used to add flags to pkg-config useful when apps want to statically link
|
||||||
set(pkg_config_libs_private "")
|
set(pkg_config_libs_private "")
|
||||||
|
set(pkg_config_names_private "")
|
||||||
|
|
||||||
option(WITH_OPENPGM "Build with support for OpenPGM" OFF)
|
option(WITH_OPENPGM "Build with support for OpenPGM" OFF)
|
||||||
option(WITH_VMCI "Build with support for VMware VMCI socket" OFF)
|
option(WITH_VMCI "Build with support for VMware VMCI socket" OFF)
|
||||||
@ -94,7 +95,6 @@ elseif(WITH_LIBSODIUM)
|
|||||||
include_directories(${SODIUM_INCLUDE_DIRS})
|
include_directories(${SODIUM_INCLUDE_DIRS})
|
||||||
set(ZMQ_USE_LIBSODIUM 1)
|
set(ZMQ_USE_LIBSODIUM 1)
|
||||||
set(ZMQ_HAVE_CURVE 1)
|
set(ZMQ_HAVE_CURVE 1)
|
||||||
set(pkg_config_libs_private "${pkg_config_libs_private} -lsodium")
|
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"libsodium is not installed. Install it, then run CMake again")
|
"libsodium is not installed. Install it, then run CMake again")
|
||||||
@ -289,6 +289,9 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_library(RT_LIBRARY rt)
|
find_library(RT_LIBRARY rt)
|
||||||
|
if(RT_LIBRARY)
|
||||||
|
set(pkg_config_libs_private "${pkg_config_libs_private} -lrt")
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
|
|
||||||
@ -529,6 +532,7 @@ else()
|
|||||||
|
|
||||||
if(OPENPGM_FOUND)
|
if(OPENPGM_FOUND)
|
||||||
message(STATUS ${OPENPGM_PKGCONFIG_NAME}" found")
|
message(STATUS ${OPENPGM_PKGCONFIG_NAME}" found")
|
||||||
|
set(pkg_config_names_private "${pkg_config_names_private} ${OPENPGM_PKGCONFIG_NAME}")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
${OPENPGM_PKGCONFIG_NAME}" not found. openpgm is searchd via `pkg-config ${OPENPGM_PKGCONFIG_NAME}`. Consider providing a valid OPENPGM_PKGCONFIG_NAME")
|
${OPENPGM_PKGCONFIG_NAME}" not found. openpgm is searchd via `pkg-config ${OPENPGM_PKGCONFIG_NAME}`. Consider providing a valid OPENPGM_PKGCONFIG_NAME")
|
||||||
|
@ -6,12 +6,20 @@
|
|||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
include(FindPkgConfig)
|
include(FindPkgConfig)
|
||||||
pkg_check_modules(PC_SODIUM "libsodium")
|
pkg_check_modules(PC_SODIUM "libsodium")
|
||||||
|
if (PC_SODIUM_FOUND)
|
||||||
|
set(pkg_config_names_private "${pkg_config_names_private} libsodium")
|
||||||
|
endif()
|
||||||
if (NOT PC_SODIUM_FOUND)
|
if (NOT PC_SODIUM_FOUND)
|
||||||
pkg_check_modules(PC_SODIUM "sodium")
|
pkg_check_modules(PC_SODIUM "sodium")
|
||||||
|
if (PC_SODIUM_FOUND)
|
||||||
|
set(pkg_config_names_private "${pkg_config_names_private} sodium")
|
||||||
|
endif()
|
||||||
endif (NOT PC_SODIUM_FOUND)
|
endif (NOT PC_SODIUM_FOUND)
|
||||||
if (PC_SODIUM_FOUND)
|
if (PC_SODIUM_FOUND)
|
||||||
set(SODIUM_INCLUDE_HINTS ${PC_SODIUM_INCLUDE_DIRS} ${PC_SODIUM_INCLUDE_DIRS}/*)
|
set(SODIUM_INCLUDE_HINTS ${PC_SODIUM_INCLUDE_DIRS} ${PC_SODIUM_INCLUDE_DIRS}/*)
|
||||||
set(SODIUM_LIBRARY_HINTS ${PC_SODIUM_LIBRARY_DIRS} ${PC_SODIUM_LIBRARY_DIRS}/*)
|
set(SODIUM_LIBRARY_HINTS ${PC_SODIUM_LIBRARY_DIRS} ${PC_SODIUM_LIBRARY_DIRS}/*)
|
||||||
|
else()
|
||||||
|
set(pkg_config_libs_private "${pkg_config_libs_private} -lsodium")
|
||||||
endif()
|
endif()
|
||||||
endif (NOT MSVC)
|
endif (NOT MSVC)
|
||||||
|
|
||||||
|
46
configure.ac
46
configure.ac
@ -176,6 +176,7 @@ CXXFLAGS="-Wno-long-long $CXXFLAGS"
|
|||||||
|
|
||||||
# Will be used to add flags to pkg-config useful when apps want to statically link
|
# Will be used to add flags to pkg-config useful when apps want to statically link
|
||||||
PKGCFG_LIBS_PRIVATE=""
|
PKGCFG_LIBS_PRIVATE=""
|
||||||
|
PKGCFG_NAMES_PRIVATE=""
|
||||||
|
|
||||||
# For host type checks
|
# For host type checks
|
||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
@ -340,7 +341,13 @@ fi
|
|||||||
|
|
||||||
# Checks for libraries
|
# Checks for libraries
|
||||||
AC_CHECK_LIB([pthread], [pthread_create])
|
AC_CHECK_LIB([pthread], [pthread_create])
|
||||||
|
if test "x$ac_cv_lib_pthread_pthread_create" = "xyes"; then
|
||||||
|
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lpthread"
|
||||||
|
fi
|
||||||
AC_CHECK_LIB([rt], [clock_gettime])
|
AC_CHECK_LIB([rt], [clock_gettime])
|
||||||
|
if test "x$ac_cv_lib_rt_clock_gettime" = "xyes"; then
|
||||||
|
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lrt"
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check if the compiler supports -fvisibility=hidden flag. MinGW uses __declspec
|
# Check if the compiler supports -fvisibility=hidden flag. MinGW uses __declspec
|
||||||
@ -464,11 +471,14 @@ AC_ARG_WITH([libgssapi_krb5], [AS_HELP_STRING([--with-libgssapi_krb5],
|
|||||||
|
|
||||||
# conditionally require libgssapi_krb5
|
# conditionally require libgssapi_krb5
|
||||||
if test "x$require_libgssapi_krb5_ext" != "xno"; then
|
if test "x$require_libgssapi_krb5_ext" != "xno"; then
|
||||||
PKG_CHECK_MODULES([gssapi_krb5], [krb5-gssapi], [], [
|
PKG_CHECK_MODULES([gssapi_krb5], [krb5-gssapi], [
|
||||||
|
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE krb5-gssapi"
|
||||||
|
], [
|
||||||
AC_CHECK_HEADERS(gssapi/gssapi_generic.h)
|
AC_CHECK_HEADERS(gssapi/gssapi_generic.h)
|
||||||
AC_SEARCH_LIBS([gss_init_sec_context], [gssapi_krb5 gssapi],
|
AC_SEARCH_LIBS([gss_init_sec_context], [gssapi_krb5 gssapi],
|
||||||
AC_DEFINE(HAVE_LIBGSSAPI_KRB5, [1], [Enabled GSSAPI security]),
|
AC_DEFINE(HAVE_LIBGSSAPI_KRB5, [1], [Enabled GSSAPI security]),
|
||||||
AC_MSG_ERROR(libgssapi_krb5 is needed for GSSAPI security))
|
AC_MSG_ERROR(libgssapi_krb5 is needed for GSSAPI security))
|
||||||
|
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -lgssapi_krb5"
|
||||||
])
|
])
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(BUILD_GSSAPI, test "x$require_libgssapi_krb5_ext" != "xno")
|
AM_CONDITIONAL(BUILD_GSSAPI, test "x$require_libgssapi_krb5_ext" != "xno")
|
||||||
@ -509,7 +519,7 @@ elif test "x$with_libsodium" = "xyes"; then
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $sodium_LIBS"
|
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE libsodium"
|
||||||
else
|
else
|
||||||
AC_MSG_NOTICE([Using tweetnacl for CURVE security])
|
AC_MSG_NOTICE([Using tweetnacl for CURVE security])
|
||||||
AC_DEFINE(ZMQ_HAVE_CURVE, [1], [Using curve encryption])
|
AC_DEFINE(ZMQ_HAVE_CURVE, [1], [Using curve encryption])
|
||||||
@ -536,14 +546,19 @@ AC_ARG_WITH([pgm], [AS_HELP_STRING([--with-pgm],
|
|||||||
|
|
||||||
# conditionally require pgm package
|
# conditionally require pgm package
|
||||||
if test "x$with_pgm_ext" != "xno"; then
|
if test "x$with_pgm_ext" != "xno"; then
|
||||||
PKG_CHECK_MODULES([pgm], [openpgm-5.2 >= 5.2], [ have_pgm_library="yes" ],
|
PKG_CHECK_MODULES([pgm], [openpgm-5.2 >= 5.2], [
|
||||||
[PKG_CHECK_MODULES([pgm], [openpgm-5.1 >= 5.1],
|
have_pgm_library="yes"
|
||||||
[ have_pgm_library="yes" ])])
|
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE openpgm-5.2 >= 5.2"
|
||||||
|
], [
|
||||||
|
PKG_CHECK_MODULES([pgm], [openpgm-5.1 >= 5.1], [
|
||||||
|
have_pgm_library="yes"
|
||||||
|
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE openpgm-5.1 >= 5.1"
|
||||||
|
])
|
||||||
|
])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$have_pgm_library" = "xyes"; then
|
if test "x$have_pgm_library" = "xyes"; then
|
||||||
AC_DEFINE(ZMQ_HAVE_OPENPGM, [1], [Have OpenPGM extension])
|
AC_DEFINE(ZMQ_HAVE_OPENPGM, [1], [Have OpenPGM extension])
|
||||||
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $pgm_LIBS"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_PGM, test "x$have_pgm_library" = "xyes")
|
AM_CONDITIONAL(HAVE_PGM, test "x$have_pgm_library" = "xyes")
|
||||||
@ -561,7 +576,10 @@ AC_ARG_WITH([norm],
|
|||||||
AC_MSG_CHECKING("with_norm_ext = ${with_norm_ext}")
|
AC_MSG_CHECKING("with_norm_ext = ${with_norm_ext}")
|
||||||
|
|
||||||
if test "x$with_norm_ext" != "xno"; then
|
if test "x$with_norm_ext" != "xno"; then
|
||||||
PKG_CHECK_MODULES([norm], [norm], [ have_norm_library="yes" ], [
|
PKG_CHECK_MODULES([norm], [norm], [
|
||||||
|
have_norm_library="yes"
|
||||||
|
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE norm"
|
||||||
|
], [
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
|
|
||||||
norm_LIBS=""
|
norm_LIBS=""
|
||||||
@ -573,6 +591,7 @@ if test "x$with_norm_ext" != "xno"; then
|
|||||||
fi
|
fi
|
||||||
norm_LIBS="${norm_LIBS} -lnorm"
|
norm_LIBS="${norm_LIBS} -lnorm"
|
||||||
have_norm_library="yes"
|
have_norm_library="yes"
|
||||||
|
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $norm_LIBS"
|
||||||
AC_SUBST(norm_LIBS)
|
AC_SUBST(norm_LIBS)
|
||||||
AC_SUBST(norm_CFLAGS)
|
AC_SUBST(norm_CFLAGS)
|
||||||
])
|
])
|
||||||
@ -581,7 +600,6 @@ else
|
|||||||
fi
|
fi
|
||||||
if test "x$have_norm_library" = "xyes"; then
|
if test "x$have_norm_library" = "xyes"; then
|
||||||
AC_DEFINE(ZMQ_HAVE_NORM, [1], [Have NORM protocol extension])
|
AC_DEFINE(ZMQ_HAVE_NORM, [1], [Have NORM protocol extension])
|
||||||
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE $norm_LIBS"
|
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(HAVE_NORM, test "x$have_norm_library" = "xyes")
|
AM_CONDITIONAL(HAVE_NORM, test "x$have_norm_library" = "xyes")
|
||||||
|
|
||||||
@ -808,7 +826,16 @@ if test "x$enable_libunwind" != "xno"; then
|
|||||||
AC_DEFINE(HAVE_LIBUNWIND, 1, [The libunwind library is to be used])
|
AC_DEFINE(HAVE_LIBUNWIND, 1, [The libunwind library is to be used])
|
||||||
AC_SUBST([LIBUNWIND_CFLAGS])
|
AC_SUBST([LIBUNWIND_CFLAGS])
|
||||||
AC_SUBST([LIBUNWIND_LIBS])
|
AC_SUBST([LIBUNWIND_LIBS])
|
||||||
AC_SEARCH_LIBS([dladdr], [dl dld])
|
AC_CHECK_LIB([dl], [dladdr], [
|
||||||
|
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -ldl"
|
||||||
|
LIBS="-ldl $LIBS"
|
||||||
|
], [
|
||||||
|
AC_CHECK_LIB([dld], [dladdr], [
|
||||||
|
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE -ldld"
|
||||||
|
LIBS="-ldld $LIBS"
|
||||||
|
])
|
||||||
|
])
|
||||||
|
PKGCFG_NAMES_PRIVATE="$PKGCFG_NAMES_PRIVATE libunwind"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
if test "x$enable_libunwind" = "xyes"; then
|
if test "x$enable_libunwind" = "xyes"; then
|
||||||
@ -871,6 +898,7 @@ AC_SUBST(LIBZMQ_VMCI_CXXFLAGS)
|
|||||||
AC_SUBST(LIBZMQ_VMCI_LDFLAGS)
|
AC_SUBST(LIBZMQ_VMCI_LDFLAGS)
|
||||||
|
|
||||||
AC_SUBST(pkg_config_libs_private, $PKGCFG_LIBS_PRIVATE)
|
AC_SUBST(pkg_config_libs_private, $PKGCFG_LIBS_PRIVATE)
|
||||||
|
AC_SUBST(pkg_config_names_private, $PKGCFG_NAMES_PRIVATE)
|
||||||
|
|
||||||
# set pkgconfigdir, allow override
|
# set pkgconfigdir, allow override
|
||||||
AC_ARG_WITH([pkgconfigdir],
|
AC_ARG_WITH([pkgconfigdir],
|
||||||
|
@ -8,4 +8,5 @@ Description: 0MQ c++ library
|
|||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Libs: -L${libdir} -lzmq
|
Libs: -L${libdir} -lzmq
|
||||||
Libs.private: -lstdc++ @pkg_config_libs_private@
|
Libs.private: -lstdc++ @pkg_config_libs_private@
|
||||||
|
Requires.private: @pkg_config_names_private@
|
||||||
Cflags: -I${includedir} @pkg_config_defines@
|
Cflags: -I${includedir} @pkg_config_defines@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user