0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-26 06:41:03 +08:00

Problem: no support for DRAFT API in build systems

Solution: add support for --enable-drafts/ENABLE_DRAFTS=ON in
Autools and CMake.
This commit is contained in:
Luca Boccassi 2016-05-02 19:44:35 +01:00
parent f0a34e0ff5
commit 064cd1fbfb
8 changed files with 71 additions and 2 deletions

View File

@ -57,6 +57,20 @@ else ()
set (ZMQ_HAVE_CURVE 1)
endif ()
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
if (EXISTS "${SOURCE_DIR}/.git")
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON)
else ()
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF)
endif ()
IF (ENABLE_DRAFTS)
ADD_DEFINITIONS (-DZMQ_BUILD_DRAFT_API)
set (pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1")
ELSE (ENABLE_DRAFTS)
set (pkg_config_defines "")
ENDIF (ENABLE_DRAFTS)
set (POLLER "" CACHE STRING "Choose polling system. valid values are
kqueue, epoll, devpoll, poll or select [default=autodetect]")

View File

@ -740,6 +740,10 @@ test_reqrep_vmci_CXXFLAGS = @LIBZMQ_VMCI_CXXFLAGS@
endif
if ENABLE_DRAFTS
test_apps +=
endif
check_PROGRAMS = ${test_apps}
# Run the test cases

View File

@ -605,6 +605,33 @@ LIBZMQ_CHECK_TCP_KEEPALIVE([
AM_CONDITIONAL(HAVE_FORK, test "x$ac_cv_func_fork" = "xyes")
if test "x$cross_compiling" = "xyes"; then
# Enable draft by default when cross-compiling
defaultval=yes
else
# enable draft API by default if we're in a git repository
# else disable it by default; then allow --enable-drafts=yes/no override
AC_CHECK_FILE($srcdir/.git, [defaultval=yes], [defaultval=no])
fi
AC_ARG_ENABLE([drafts],
AS_HELP_STRING([--enable-drafts],
[Build and install draft classes and methods [default=yes]]),
[enable_drafts=$enableval],
[enable_drafts=$defaultval])
AM_CONDITIONAL([ENABLE_DRAFTS], [test x$enable_drafts != xno])
if test "x$enable_drafts" = "xyes"; then
AC_MSG_NOTICE([Building stable and legacy API + draft API])
AC_DEFINE(ZMQ_BUILD_DRAFT_API, 1, [Provide draft classes and methods])
AC_SUBST(pkg_config_defines, "-DZMQ_BUILD_DRAFT_API=1")
# CPPFLAGS="-DZMQ_BUILD_DRAFT_API=1 $CPPFLAGS"
else
AC_MSG_NOTICE([Building stable and legacy API (no draft API)])
AC_SUBST(pkg_config_defines, "")
fi
# Subst LIBZMQ_EXTRA_CFLAGS & CXXFLAGS & LDFLAGS
AC_SUBST(LIBZMQ_EXTRA_CFLAGS)
AC_SUBST(LIBZMQ_EXTRA_CXXFLAGS)

View File

@ -575,6 +575,16 @@ ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn* func, void* arg);
ZMQ_EXPORT void zmq_threadclose (void* thread);
/******************************************************************************/
/* These functions are DRAFT and disabled in stable releases, and subject to */
/* change at ANY time until declared stable. */
/******************************************************************************/
#ifdef ZMQ_BUILD_DRAFT_API
#endif // ZMQ_BUILD_DRAFT_API
#undef ZMQ_EXPORT
#ifdef __cplusplus

View File

@ -8,4 +8,4 @@ Description: 0MQ c++ library
Version: @ZMQ_VERSION_MAJOR@.@ZMQ_VERSION_MINOR@.@ZMQ_VERSION_PATCH@
Libs: -L${libdir} -lzmq
Libs.private: -lstdc++
Cflags: -I${includedir}
Cflags: -I${includedir} @pkg_config_defines@

View File

@ -8,4 +8,4 @@ Description: 0MQ c++ library
Version: @VERSION@
Libs: -L${libdir} -lzmq
Libs.private: -lstdc++
Cflags: -I${includedir}
Cflags: -I${includedir} @pkg_config_defines@

View File

@ -145,5 +145,13 @@
#include "platform.hpp"
#include "../include/zmq.h"
/******************************************************************************/
/* These functions are DRAFT and disabled in stable releases, and subject to */
/* change at ANY time until declared stable. */
/******************************************************************************/
#ifndef ZMQ_BUILD_DRAFT_API
#endif // ZMQ_BUILD_DRAFT_API
#endif //ifndef __ZMQ_PRECOMPILED_HPP_INCLUDED__

View File

@ -117,6 +117,12 @@ if(WITH_VMCI)
)
endif()
IF (ENABLE_DRAFTS)
list(APPEND tests
)
ENDIF (ENABLE_DRAFTS)
# add location of platform.hpp for Windows builds
if(WIN32)
add_definitions(-DZMQ_CUSTOM_PLATFORM_HPP)