From 099bcfc4a41424a0b66a2b5439743684ff3137f9 Mon Sep 17 00:00:00 2001 From: Pawel Kurdybacha Date: Sun, 20 May 2018 07:00:08 +0100 Subject: [PATCH] Problem: cppzmq build broken with C++11 compiler and git cloned repo. Default build, ./ci_build.sh without any arguments, which causes to run with draft disabled, does not work properly for git cloned repository and C++11 compiler. Two issues: 1. For git cloned repository ENABLE_DRAFTS is ON by default but libzmq compiled build without drafts .Travis did not catch that because default build runs on non C++11 compiler. 2. testutil.hpp does not build because of missing draft guards. Solution 1: Remove check for presence of .git for enabling draft API as it is confusing to use with ENABLE_DRAFTS flag and there should be only one explicit way to enable draft build. Solution 2: add missing draft guards in testutil.hpp for server/client socket in use there. Solution 3: add extra Travis build covering C++11 compiler and non draft enabled build. --- .travis.yml | 13 ++++++++++++- CMakeLists.txt | 6 +----- tests/testutil.hpp | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 401db01..f1b472c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,18 @@ matrix: # GCC default, draft disabled, default libzmq (defined in ci_build.sh) - os: linux - # GCC 7, draft enabled (default), latest libzmq (default) + # GCC 6, draft disabled (default), latest libzmq (default) + - os: linux + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-6 + env: + - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" + + # GCC 7, draft enabled, latest libzmq (default) - os: linux addons: apt: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ac7b34..21670bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,11 +19,7 @@ if (ZeroMQ_FOUND AND (NOT TARGET libzmq OR NOT TARGET libzmq-static)) message(FATAL_ERROR "ZeroMQ version not supported!") endif() -if (EXISTS "${CMAKE_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 () +OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF) if (ENABLE_DRAFTS) ADD_DEFINITIONS (-DZMQ_BUILD_DRAFT_API) set (pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1") diff --git a/tests/testutil.hpp b/tests/testutil.hpp index 845d6db..1ac5078 100644 --- a/tests/testutil.hpp +++ b/tests/testutil.hpp @@ -3,7 +3,7 @@ #include #include -#if defined(ZMQ_CPP11) +#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) #include class loopback_ip4_binder