From 301de3ac5c7cf8a5eaaf3c58157251db781841d6 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 24 May 2018 14:59:39 -0700 Subject: fixes #486 Revisit SOVERSION and VERSION fixes #485 Honor BUILD_SHARED_LIBS fixes #483 Don't expose private symbols in shared library fixes #481 Export CMake target This is a "large" commit involving changes that don't affect the code directly, but which have an impact on how we package and build our project. The most significant of these changes is that we now build only either a shared or a static library, depending on the setting of the BUILD_SHARED_LIBS option. We also suppress private symbols from being exposed when the underlying toolchain lets us do so. Minor updates to the way we version the ABI are used, and we now have a nice exported CMake project. To import this project in another, simply do find_package(nng) and you can add target_link_libraries(nng::nng) to your targets. CMake does the rest for you. --- .circleci/build-and-test.sh | 4 +-- .circleci/build-demos.sh | 13 ++++++++++ .circleci/config.yml | 60 ++++++++++++++++++++++++++++++++++++++++----- .circleci/run-cmake.sh | 11 +++++++++ 4 files changed, 80 insertions(+), 8 deletions(-) create mode 100755 .circleci/build-demos.sh create mode 100755 .circleci/run-cmake.sh (limited to '.circleci') diff --git a/.circleci/build-and-test.sh b/.circleci/build-and-test.sh index 068f0f91..c4fb8eaa 100755 --- a/.circleci/build-and-test.sh +++ b/.circleci/build-and-test.sh @@ -4,12 +4,12 @@ # common build & test steps for CircleCI jobs # -uname -a cmake --version ninja --version mkdir build cd build -cmake -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} -DNNG_ENABLE_COVERAGE=${COVERAGE:-OFF} .. +cmake -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} -DNNG_ENABLE_COVERAGE=${COVERAGE:-OFF} -DBUILD_SHARED_LIBS=${SHARED_LIBS:=ON} .. ninja +ninja install env CTEST_OUTPUT_ON_FAILURE=1 ninja test diff --git a/.circleci/build-demos.sh b/.circleci/build-demos.sh new file mode 100755 index 00000000..488c142d --- /dev/null +++ b/.circleci/build-demos.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# +# build the demos to make sure they all build cleanly +# + +for dir in demo/*; do + demo=$(basename $dir) + mkdir build-demo-${demo} + ( cd build-demo-${demo} && + cmake -G Ninja ../demo/${demo} && + ninja ) || exit 1 +done diff --git a/.circleci/config.yml b/.circleci/config.yml index efe64900..2a3711f7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,7 +22,6 @@ jobs: - run: > apt-get install -y --allow-unauthenticated build-essential - curl asciidoctor cmake libmbedtls-dev @@ -32,6 +31,52 @@ jobs: - run: ./etc/format-check.sh - run: ./.circleci/build-and-test.sh + "gcc - static": + docker: + - image: ubuntu:16.04 + environment: + CC: gcc + CXX: g++ + SHARED_LIBS: OFF + CTEST_OUTPUT_ON_FAILURE: 1 + steps: + - checkout + - run: apt-get update -qq + - run: apt-get install -y software-properties-common + - run: add-apt-repository ppa:ubuntu-toolchain-r/test + - run: apt-get update -qq + - run: > + apt-get install -y --allow-unauthenticated + build-essential + cmake + libmbedtls-dev + ninja-build + - run: ./.circleci/build-and-test.sh + + "gcc - demos": + docker: + - image: ubuntu:16.04 + environment: + CC: gcc + CXX: g++ + CTEST_OUTPUT_ON_FAILURE: 1 + steps: + - checkout + - run: apt-get update -qq + - run: apt-get install -y software-properties-common + - run: add-apt-repository ppa:ubuntu-toolchain-r/test + - run: apt-get update -qq + - run: > + apt-get install -y --allow-unauthenticated + build-essential + cmake + libmbedtls-dev + ninja-build + - run: ./.circleci/run-cmake.sh + - run: ninja -C build + - run: ninja -C build install + - run: ./.circleci/build-demos.sh + "gcc - build, test, coverage": docker: - image: ubuntu:16.04 @@ -40,6 +85,7 @@ jobs: CXX: g++-8 COVERAGE: "ON" GCOV: gcov-8 + CTEST_OUTPUT_ON_FAILURE: 1 steps: - checkout - run: apt-get update -qq @@ -64,11 +110,13 @@ workflows: build_and_test: jobs: - "clang - build, test" + - "gcc - static" - "gcc - build, test, coverage" + - "gcc - demos" -notify: - webhooks: - # A list of hook hashes, containing the url field - # gitter hook - - url: ${GITTER_WEBHOOK} +#notify: +# webhooks: +# # A list of hook hashes, containing the url field +# # gitter hook +# - url: ${GITTER_WEBHOOK} diff --git a/.circleci/run-cmake.sh b/.circleci/run-cmake.sh new file mode 100755 index 00000000..ca0caaa4 --- /dev/null +++ b/.circleci/run-cmake.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# +# common build & test steps for CircleCI jobs +# +cmake --version +ninja --version + +mkdir build +cd build +cmake -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} -DNNG_ENABLE_COVERAGE=${COVERAGE:-OFF} -DBUILD_SHARED_LIBS=${SHARED_LIBS:=ON} .. -- cgit v1.2.3-70-g09d2