From 380e39856b715614e657fdd8f24d5d5714e9024d Mon Sep 17 00:00:00 2001 From: Pawel Kurdybacha Date: Wed, 23 May 2018 18:34:44 +0100 Subject: [PATCH] Problem: draft build not enabled for git repo cppzmq does not follow other zeromq projects where draft builds are enabled by default for git repository. Solution: revert back code where ENABLE_DRAFTS in set to ON if .git directory exists --- .travis.yml | 4 ++-- CMakeLists.txt | 6 +++++- ci_build.sh | 15 ++++----------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index f1b472c..9cc0c96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: - os: osx osx_image: xcode9.1 compiler: clang - env: DRAFT=1 + env: ENABLE_DRAFTS=ON ########################################################## # GCC on Linux @@ -50,7 +50,7 @@ matrix: packages: - g++-7 env: - - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" DRAFT=1 + - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" ENABLE_DRAFTS=ON # - env: BUILD_TYPE=cmake DO_CLANG_FORMAT_CHECK=1 CLANG_FORMAT=/usr/local/clang-5.0.0/bin/clang-format # os: linux # addons: diff --git a/CMakeLists.txt b/CMakeLists.txt index 21670bb..8ac7b34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,11 @@ if (ZeroMQ_FOUND AND (NOT TARGET libzmq OR NOT TARGET libzmq-static)) message(FATAL_ERROR "ZeroMQ version not supported!") endif() -OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF) +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 () if (ENABLE_DRAFTS) ADD_DEFINITIONS (-DZMQ_BUILD_DRAFT_API) set (pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1") diff --git a/ci_build.sh b/ci_build.sh index 74db483..6b8e1d4 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -4,20 +4,13 @@ set -x set -e BUILD_TYPE=${BUILD_TYPE:-cmake} +ZMQ_VERSION=${ZMQ_VERSION:-4.2.5} +ENABLE_DRAFTS=${ENABLE_DRAFTS:-OFF} LIBZMQ=${PWD}/libzmq-build CPPZMQ=${PWD}/cppzmq-build -ZMQ_VERSION="4.2.5" -DRAFT=${DRAFT:-0} # Travis machines have 2 cores JOBS=2 -if [ "${DRAFT}" = "1" ] ; then - # if we enable drafts during the libzmq cmake build, the pkgconfig - # data should set ZMQ_BUILD_DRAFT_API in dependent builds, but this - # does not appear to work (TODO) - export ZEROMQ_CMAKE_FLAGS="-DENABLE_DRAFTS=ON" -fi - libzmq_install() { curl -L https://github.com/zeromq/libzmq/archive/v"${ZMQ_VERSION}".tar.gz \ >zeromq.tar.gz @@ -26,7 +19,7 @@ libzmq_install() { cmake -Hlibzmq-${ZMQ_VERSION} -B${LIBZMQ} -DWITH_PERF_TOOL=OFF \ -DZMQ_BUILD_TESTS=OFF \ -DCMAKE_BUILD_TYPE=Release \ - ${ZEROMQ_CMAKE_FLAGS} + -DENABLE_DRAFTS=${ENABLE_DRAFTS} cmake --build ${LIBZMQ} -- -j${JOBS} elif [ "${BUILD_TYPE}" = "pkgconfig" ] ; then pushd . @@ -46,7 +39,7 @@ cppzmq_build() { if [ "${BUILD_TYPE}" = "cmake" ] ; then export ZeroMQ_DIR=${LIBZMQ} fi - cmake -H. -B${CPPZMQ} ${ZEROMQ_CMAKE_FLAGS} + cmake -H. -B${CPPZMQ} -DENABLE_DRAFTS=${ENABLE_DRAFTS} cmake --build ${CPPZMQ} -- -j${JOBS} popd }