diff --git a/.github/workflows/cmake-find-boost-install.yml b/.github/workflows/cmake-find-boost-install.yml new file mode 100644 index 000000000..a5018d1d6 --- /dev/null +++ b/.github/workflows/cmake-find-boost-install.yml @@ -0,0 +1,61 @@ +############################################################################## +# GitHub Actions Workflow for Boost.Json +# +# Copyright (c) 2020 Mateusz Loskot +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +############################################################################## +name: cmake-find-boost-install + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Checkout submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: Uninstall Boost + run: | + sudo apt-get remove -y -q --purge libboost-all-dev libboost-doc libboost-tools-dev + sudo apt-get autoremove -y -q + sudo apt-get autoclean -y -q + + - name: Install Boost + run: | + git clone -b master --depth 1 https://github.com/boostorg/boost.git "$GITHUB_WORKSPACE/boost-root" + cd "$GITHUB_WORKSPACE/boost-root" + git submodule update -q --init libs/headers + git submodule update -q --init libs/system + git submodule update -q --init libs/utility + git submodule update -q --init tools/boost_install + git submodule update -q --init tools/boostdep + git submodule update -q --init tools/build + python tools/boostdep/depinst/depinst.py system + python tools/boostdep/depinst/depinst.py utility + ./bootstrap.sh + sudo ./b2 install variant=release --with-system + + - name: CMake + run: | + cmake -B "$GITHUB_WORKSPACE/build" -DCMAKE_VERBOSE_MAKEFILE=ON -DBOOST_JSON_FIND_BOOST=ON + + - name: Build + run: | + cmake --build "$GITHUB_WORKSPACE/build" --config Release + + - name: Test + run: | + cd "$GITHUB_WORKSPACE/build" + ctest --build-config Release --output-on-failure + + \ No newline at end of file diff --git a/.github/workflows/cmake-standalone.yml b/.github/workflows/cmake-standalone.yml new file mode 100644 index 000000000..105849bec --- /dev/null +++ b/.github/workflows/cmake-standalone.yml @@ -0,0 +1,37 @@ +############################################################################## +# GitHub Actions Workflow for Boost.Json +# +# Copyright (c) 2020 Mateusz Loskot +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +############################################################################## +name: cmake-standalone + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Uninstall Boost + run: | + sudo apt-get remove -y -q --purge libboost-all-dev libboost-doc libboost-tools-dev + sudo apt-get autoremove -y -q + sudo apt-get autoclean -y -q + + - uses: actions/checkout@v2 + + - name: CMake + run: | + cmake -B "$GITHUB_WORKSPACE/build" -DCMAKE_VERBOSE_MAKEFILE=ON -DBOOST_JSON_STANDALONE=ON + + - name: Build + run: | + cmake --build "$GITHUB_WORKSPACE/build" --config Release + + - name: Test + run: | + cd "$GITHUB_WORKSPACE/build" + ctest --build-config Release --output-on-failure diff --git a/.github/workflows/cmake-with-boost-stage.yml b/.github/workflows/cmake-with-boost-stage.yml new file mode 100644 index 000000000..ca28be70f --- /dev/null +++ b/.github/workflows/cmake-with-boost-stage.yml @@ -0,0 +1,83 @@ +############################################################################## +# GitHub Actions Workflow for Boost.Json +# +# Copyright (c) 2020 Mateusz Loskot +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +############################################################################## +name: cmake-with-boost-stage + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up environment + id: setenv + run: | + if [[ "$GITHUB_REF" == *master ]]; then + echo "::set-env name=BOOST_BRANCH::master" + else + echo "::set-env name=BOOST_BRANCH::develop" + fi + echo "::set-env name=BOOST_SELF::$(basename $GITHUB_WORKSPACE)" + echo "::set-env name=BOOST_ROOT::$GITHUB_WORKSPACE/boost-root" + echo "::set-output name=boost_self::$(basename $GITHUB_WORKSPACE)" + echo "::set-output name=boost_root::$GITHUB_WORKSPACE/boost-root" + + - name: Uninstall Boost + run: | + sudo apt-get remove -y -q --purge libboost-all-dev libboost-doc libboost-tools-dev + sudo apt-get autoremove -y -q + sudo apt-get autoclean -y -q + + - name: Clone Boost + run: | + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git $BOOST_ROOT + cd $BOOST_ROOT + git submodule update -q --init libs/headers + git submodule update -q --init tools/boost_install + git submodule update -q --init tools/boostdep + git submodule update -q --init tools/build + + - uses: actions/checkout@v2 + with: + path: ${{ steps.setenv.outputs.boost_root }}/libs/${{ steps.setenv.outputs.boost_self }} + + - name: Checkout submodules + shell: bash + run: | + cd "$BOOST_ROOT/libs/$BOOST_SELF" + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: Run tools/boostdep/depinst/depinst.py + run: | + cd $BOOST_ROOT + python tools/boostdep/depinst/depinst.py --include bench --include benchmark --include example --include examples --include tools $BOOST_SELF + + - name: Bootstrap Boost + run: | + cd $BOOST_ROOT + ./bootstrap.sh + ./b2 headers + ./b2 variant=release --no-cmake-config --with-system stage + + - name: CMake + run: | + cd "$BOOST_ROOT/libs/$BOOST_SELF" + cmake -B "$GITHUB_WORKSPACE/build" -DCMAKE_VERBOSE_MAKEFILE=ON + + - name: Build + run: | + export VER + cmake --build "$GITHUB_WORKSPACE/build" --config Release + + - name: Test + run: | + cd "$GITHUB_WORKSPACE/build" + ctest --build-config Release --output-on-failure diff --git a/.gitignore b/.gitignore index b3a18d090..42d344c21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /bin /bin64 +/_build* temp # Emacs diff --git a/CMakeLists.txt b/CMakeLists.txt index 056e83a21..ec2bac7ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,11 @@ if(BOOST_SUPERPROJECT_VERSION) set(BOOST_JSON_VERSION ${BOOST_SUPERPROJECT_VERSION}) endif() -project(boost_json VERSION ${BOOST_JSON_VERSION} LANGUAGES CXX) +if (BOOST_SUPERPROJECT_VERSION) + project(boost_json VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) +else() + project(boost_json VERSION "${BOOST_JSON_VERSION}" LANGUAGES CXX) +endif() file(GLOB_RECURSE BOOST_JSON_HEADERS CONFIGURE_DEPENDS include/boost/*.hpp @@ -33,11 +37,15 @@ if(${CMAKE_VERSION} VERSION_GREATER 3.7.2) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "" FILES ${BOOST_JSON_SOURCES}) endif() +# TODO: For Boost superproject, do we want to support header-only mode? +# Then, this needs to read `add_library(boost_json INTERFACE)` +# and related settings need to be INTERFACE-ed as well. add_library(boost_json ${BOOST_JSON_HEADERS} ${BOOST_JSON_SOURCES}) add_library(Boost::json ALIAS boost_json) target_compile_features(boost_json PUBLIC cxx_constexpr) +# TODO: For Boost superproject, this may need to be INTERFACE setting target_include_directories(boost_json PUBLIC include) target_compile_definitions(boost_json PUBLIC BOOST_JSON_NO_LIB=1) @@ -53,13 +61,15 @@ include(CTest) option(BOOST_JSON_STANDALONE "Build boost::json as a static standalone library" FALSE) if(BOOST_JSON_STANDALONE) + # + # Building standalone, out of Boost superproject tree, without Boost as dependency. + # target_compile_features(boost_json PUBLIC cxx_std_17) target_compile_definitions(boost_json PUBLIC BOOST_JSON_STANDALONE) - add_subdirectory(example) elseif(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) # - # Root project such as on Travis or other CI, - # or when producing Visual Studio Solution and Projects + # Building as root project, out of Boost superproject tree, with Boost as dependency. + # e.g. on Travis or other CI, or when producing Visual Studio Solution and Projects. # if(${CMAKE_VERSION} VERSION_LESS 3.16) message(FATAL_ERROR "Boost.JSON development requires CMake 3.16 or newer.") @@ -73,15 +83,12 @@ elseif(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) target_include_directories(boost_json PUBLIC ${BOOST_ROOT}) target_link_directories(boost_json PUBLIC ${BOOST_ROOT}/stage/lib) endif() - - add_subdirectory(bench) - add_subdirectory(example) - add_subdirectory(test) - elseif(BOOST_SUPERPROJECT_VERSION) # - # Building with Boost superproject cmake + # Building as part of Boost superproject tree, with Boost as dependency. # + # TODO: This CMake support for Boost.Json is currently experimental. + # This needs to be reviewed, tested target_link_libraries(boost_json PUBLIC Boost::assert @@ -91,6 +98,9 @@ elseif(BOOST_SUPERPROJECT_VERSION) Boost::system Boost::utility ) + + include(BoostInstall) + boost_install(TARGETS boost_json HEADER_DIRECTORY include/) else() # # Out-of-tree, non-standalone build @@ -100,11 +110,13 @@ else() PUBLIC Boost::system ) +endif() - if (BUILD_TESTING) - add_subdirectory(bench) - add_subdirectory(example) - add_subdirectory(test) - endif() +if (BUILD_TESTING) + add_subdirectory(test) +endif() +if (BUILD_TESTING AND NOT BOOST_SUPERPROJECT_VERSION) + add_subdirectory(bench) + add_subdirectory(example) endif() diff --git a/README.md b/README.md index 1b191eef4..903245952 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ Branch | Travis | Appveyor | Azure Pipelines | codecov.io | Docs | Matrix | :-------------: | ------ | -------- | --------------- | ---------- | ---- | ------ | -[`master`](https://github.com/vinniefalco/json/tree/master) | [![Build Status](https://travis-ci.org/vinniefalco/json.svg?branch=master)](https://travis-ci.org/vinniefalco/json) | [![Build status](https://ci.appveyor.com/api/projects/status/github/vinniefalco/json?branch=master&svg=true)](https://ci.appveyor.com/project/vinniefalco/json/branch/master) | [![Build Status](https://img.shields.io/azure-devops/build/vinniefalco/2571d415-8cc8-4120-a762-c03a8eda0659/1/master)](https://vinniefalco.visualstudio.com/json/_build/latest?definitionId=1&branchName=master) | [![codecov](https://codecov.io/gh/vinniefalco/json/branch/master/graph/badge.svg)](https://codecov.io/gh/vinniefalco/json/branch/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://vinniefalco.github.com/doc/json/index.html) | [![Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/json.html) -[`develop`](https://github.com/vinniefalco/json/tree/develop) | [![Build Status](https://travis-ci.org/vinniefalco/json.svg?branch=develop)](https://travis-ci.org/vinniefalco/json) | [![Build status](https://ci.appveyor.com/api/projects/status/github/vinniefalco/json?branch=develop&svg=true)](https://ci.appveyor.com/project/vinniefalco/json/branch/develop) | [![Build Status](https://img.shields.io/azure-devops/build/vinniefalco/2571d415-8cc8-4120-a762-c03a8eda0659/1/develop)](https://vinniefalco.visualstudio.com/json/_build/latest?definitionId=1&branchName=develop) | [![codecov](https://codecov.io/gh/vinniefalco/json/branch/develop/graph/badge.svg)](https://codecov.io/gh/vinniefalco/json/branch/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://vinniefalco.github.com/doc/json/index.html) | [![Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/json.html) +[`master`](https://github.com/CPPAlliance/json/tree/master) | [![Build Status](https://travis-ci.org/CPPAlliance/json.svg?branch=master)](https://travis-ci.org/CPPAlliance/json) | [![Build status](https://ci.appveyor.com/api/projects/status/github/CPPAlliance/json?branch=master&svg=true)](https://ci.appveyor.com/project/CPPAlliance/json/branch/master) | [![Build Status](https://img.shields.io/azure-devops/build/vinniefalco/2571d415-8cc8-4120-a762-c03a8eda0659/1/master)](https://vinniefalco.visualstudio.com/json/_build/latest?definitionId=1&branchName=master) | [![codecov](https://codecov.io/gh/CPPAlliance/json/branch/master/graph/badge.svg)](https://codecov.io/gh/CPPAlliance/json/branch/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://vinniefalco.github.com/doc/json/index.html) | [![Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/json.html) +[`develop`](https://github.com/CPPAlliance/json/tree/develop) | [![Build Status](https://travis-ci.org/CPPAlliance/json.svg?branch=develop)](https://travis-ci.org/CPPAlliance/json) | [![Build status](https://ci.appveyor.com/api/projects/status/github/CPPAlliance/json?branch=develop&svg=true)](https://ci.appveyor.com/project/CPPAlliance/json/branch/develop) | [![Build Status](https://img.shields.io/azure-devops/build/vinniefalco/2571d415-8cc8-4120-a762-c03a8eda0659/1/develop)](https://vinniefalco.visualstudio.com/json/_build/latest?definitionId=1&branchName=develop) | [![codecov](https://codecov.io/gh/CPPAlliance/json/branch/develop/graph/badge.svg)](https://codecov.io/gh/CPPAlliance/json/branch/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://vinniefalco.github.com/doc/json/index.html) | [![Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/json.html) # Boost.JSON