mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
Problem: pkgconfig file does not support static link
Solution: add dependencies, if necessary, to the .private Libs and Requires field of the pkgconfig file at build time. This way pkg-config --static --libs libzmq will correctly print dependencies if they were used to build the static libzmq.a library.
This commit is contained in:
parent
131a2627b9
commit
6d9411607d
@ -16,6 +16,10 @@ if(COMPILER_SUPPORTS_C11)
|
|||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Will be used to add flags to pkg-config useful when apps want to statically link
|
||||||
|
set (pkg_config_requires_private "")
|
||||||
|
set (pkg_config_libs_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)
|
||||||
|
|
||||||
@ -45,6 +49,7 @@ elseif (WITH_LIBSODIUM)
|
|||||||
endif ()
|
endif ()
|
||||||
set (ZMQ_USE_LIBSODIUM 1)
|
set (ZMQ_USE_LIBSODIUM 1)
|
||||||
set (ZMQ_HAVE_CURVE 1)
|
set (ZMQ_HAVE_CURVE 1)
|
||||||
|
list (APPEND pkg_config_requires_private "libsodium")
|
||||||
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")
|
||||||
|
19
configure.ac
19
configure.ac
@ -140,6 +140,10 @@ libzmq_on_gnu="no"
|
|||||||
# Set some default features required by ZeroMQ code
|
# Set some default features required by ZeroMQ code
|
||||||
CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -Wno-long-long $CPPFLAGS"
|
CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -Wno-long-long $CPPFLAGS"
|
||||||
|
|
||||||
|
# Will be used to add flags to pkg-config useful when apps want to statically link
|
||||||
|
PKGCFG_REQUIRES_PRIVATE=""
|
||||||
|
PKGCFG_LIBS_PRIVATE=""
|
||||||
|
|
||||||
# For host type checks
|
# For host type checks
|
||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
|
|
||||||
@ -450,6 +454,8 @@ elif test "x$with_libsodium" = "xyes"; then
|
|||||||
libzmq_werror="no"
|
libzmq_werror="no"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
PKGCFG_REQUIRES_PRIVATE="$PKGCFG_REQUIRES_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])
|
||||||
@ -471,9 +477,14 @@ 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], [
|
||||||
|
have_pgm_library="yes"
|
||||||
|
PKGCFG_REQUIRES_PRIVATE="$PKGCFG_REQUIRES_PRIVATE openpgm-5.2" ],
|
||||||
[PKG_CHECK_MODULES([pgm], [openpgm-5.1 >= 5.1],
|
[PKG_CHECK_MODULES([pgm], [openpgm-5.1 >= 5.1],
|
||||||
[ have_pgm_library="yes" ])])
|
[
|
||||||
|
have_pgm_library="yes"
|
||||||
|
PKGCFG_REQUIRES_PRIVATE="$PKGCFG_REQUIRES_PRIVATE openpgm-5.1"
|
||||||
|
])])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$have_pgm_library" = "xyes"; then
|
if test "x$have_pgm_library" = "xyes"; then
|
||||||
@ -504,6 +515,7 @@ if test "x$with_norm_ext" != "xno"; then
|
|||||||
LIBZMQ_EXTRA_LDFLAGS="-L${norm_path}/lib ${LIBZMQ_EXTRA_LDFLAGS}"
|
LIBZMQ_EXTRA_LDFLAGS="-L${norm_path}/lib ${LIBZMQ_EXTRA_LDFLAGS}"
|
||||||
fi
|
fi
|
||||||
LIBS="-L${norm_path}/lib -lnorm $LIBS"
|
LIBS="-L${norm_path}/lib -lnorm $LIBS"
|
||||||
|
PKGCFG_LIBS_PRIVATE="$PKGCFG_LIBS_PRIVATE libnorm.a"
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
fi
|
fi
|
||||||
@ -649,6 +661,9 @@ AC_SUBST(LIBZMQ_EXTRA_LDFLAGS)
|
|||||||
AC_SUBST(LIBZMQ_VMCI_CXXFLAGS)
|
AC_SUBST(LIBZMQ_VMCI_CXXFLAGS)
|
||||||
AC_SUBST(LIBZMQ_VMCI_LDFLAGS)
|
AC_SUBST(LIBZMQ_VMCI_LDFLAGS)
|
||||||
|
|
||||||
|
AC_SUBST(pkg_config_requires_private, $PKGCFG_REQUIRES_PRIVATE)
|
||||||
|
AC_SUBST(pkg_config_libs_private, $PKGCFG_LIBS_PRIVATE)
|
||||||
|
|
||||||
# set pkgconfigdir, allow override
|
# set pkgconfigdir, allow override
|
||||||
AC_ARG_WITH([pkgconfigdir],
|
AC_ARG_WITH([pkgconfigdir],
|
||||||
AS_HELP_STRING([--with-pkgconfigdir=PATH],
|
AS_HELP_STRING([--with-pkgconfigdir=PATH],
|
||||||
|
@ -7,5 +7,6 @@ Name: libzmq
|
|||||||
Description: 0MQ c++ library
|
Description: 0MQ c++ library
|
||||||
Version: @ZMQ_VERSION_MAJOR@.@ZMQ_VERSION_MINOR@.@ZMQ_VERSION_PATCH@
|
Version: @ZMQ_VERSION_MAJOR@.@ZMQ_VERSION_MINOR@.@ZMQ_VERSION_PATCH@
|
||||||
Libs: -L${libdir} -lzmq
|
Libs: -L${libdir} -lzmq
|
||||||
Libs.private: -lstdc++
|
Libs.private: -lstdc++ @pkg_config_libs_private@
|
||||||
|
Requires.private: @pkg_config_requires_private@
|
||||||
Cflags: -I${includedir} @pkg_config_defines@
|
Cflags: -I${includedir} @pkg_config_defines@
|
||||||
|
@ -7,5 +7,6 @@ Name: libzmq
|
|||||||
Description: 0MQ c++ library
|
Description: 0MQ c++ library
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Libs: -L${libdir} -lzmq
|
Libs: -L${libdir} -lzmq
|
||||||
Libs.private: -lstdc++
|
Libs.private: -lstdc++ @pkg_config_libs_private@
|
||||||
|
Requires.private: @pkg_config_requires_private@
|
||||||
Cflags: -I${includedir} @pkg_config_defines@
|
Cflags: -I${includedir} @pkg_config_defines@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user