From 064cd1fbfb3c173e452d487ec1be6d511ecc405e Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Mon, 2 May 2016 19:44:35 +0100 Subject: [PATCH] Problem: no support for DRAFT API in build systems Solution: add support for --enable-drafts/ENABLE_DRAFTS=ON in Autools and CMake. --- CMakeLists.txt | 14 ++++++++++++++ Makefile.am | 4 ++++ configure.ac | 27 +++++++++++++++++++++++++++ include/zmq.h | 10 ++++++++++ src/libzmq.pc.cmake.in | 2 +- src/libzmq.pc.in | 2 +- src/precompiled.hpp | 8 ++++++++ tests/CMakeLists.txt | 6 ++++++ 8 files changed, 71 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8030f0e..05ef4558 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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]") diff --git a/Makefile.am b/Makefile.am index d6d10f4b..87034bdf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 8e75203c..bad8a18e 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/include/zmq.h b/include/zmq.h index 39378674..df7dc826 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -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 diff --git a/src/libzmq.pc.cmake.in b/src/libzmq.pc.cmake.in index e11685d1..4a41b081 100644 --- a/src/libzmq.pc.cmake.in +++ b/src/libzmq.pc.cmake.in @@ -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@ diff --git a/src/libzmq.pc.in b/src/libzmq.pc.in index 52a39f72..8d362607 100644 --- a/src/libzmq.pc.in +++ b/src/libzmq.pc.in @@ -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@ diff --git a/src/precompiled.hpp b/src/precompiled.hpp index 3a840fb6..c6281cd7 100644 --- a/src/precompiled.hpp +++ b/src/precompiled.hpp @@ -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__ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4d3b417a..87afa06b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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)