diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 42d94d34..38663422 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -374,39 +374,18 @@ jobs:
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
rm -rf boost-ci-cloned
- name: Setup Boost
- env: {B2_DONT_BOOTSTRAP: 1}
+ env:
+ B2_DONT_BOOTSTRAP: 1
+ BCM_GENERATOR: ${{matrix.generator}}
+ BCM_BUILD_TYPE: ${{matrix.build_type}}
+ BCM_SHARED_LIBS: ${{matrix.build_shared}}
run: source ci/github/install.sh
- name: Run CMake tests
- run: |
- cd "$BOOST_ROOT"
- mkdir __build_cmake_test__ && cd __build_cmake_test__
- cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON ..
- cmake --build . --target tests --config ${{matrix.build_type}}
- ctest --output-on-failure --build-config ${{matrix.build_type}}
+ run: ci/cmake_test.sh
- name: Run CMake subdir tests
- run: |
- cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder
- [ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_subdir_test"
- cd "$cmake_test_folder"
- mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__
- cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=OFF -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} ..
- cmake --build . --config ${{matrix.build_type}}
- ctest --output-on-failure --build-config ${{matrix.build_type}}
-
- - name: Install Library
- run: |
- cd "$BOOST_ROOT"
- mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
- cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBoost_DEBUG=ON ..
- cmake --build . --target install --config ${{matrix.build_type}}
+ run: ci/cmake_subdir_test.sh
+
- name: Run CMake install tests
- run: |
- cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder
- [ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_install_test"
- cd "$cmake_test_folder"
- mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
- cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_PREFIX_PATH=~/.local ..
- cmake --build . --config ${{matrix.build_type}}
- ctest --output-on-failure --build-config ${{matrix.build_type}}
+ run: ci/cmake_install_test.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2c1630d4..09f5ec45 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,16 +7,22 @@ cmake_minimum_required(VERSION 3.5...3.16)
project(boost_ci VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
-add_library(boost_boost_ci INTERFACE)
+add_library(boost_boost_ci src/boost_ci.cpp)
add_library(Boost::boost_ci ALIAS boost_boost_ci)
-target_include_directories(boost_boost_ci INTERFACE include)
+target_include_directories(boost_boost_ci PUBLIC include)
target_link_libraries(boost_boost_ci
- INTERFACE
+ PUBLIC
Boost::config
+ PRIVATE
+ Boost::atomic
)
+if(BUILD_SHARED_LIBS)
+ target_compile_definitions(boost_boost_ci PUBLIC BOOST_BOOST_CI_DYN_LINK)
+endif()
+
if(BUILD_TESTING)
add_subdirectory(test)
endif()
diff --git a/build/Jamfile.v2 b/build/Jamfile.v2
new file mode 100644
index 00000000..40239514
--- /dev/null
+++ b/build/Jamfile.v2
@@ -0,0 +1,25 @@
+# Boost CI Test Build Jamfile
+
+# Copyright (c) 2022 Alexander Grund
+#
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE or www.boost.org/LICENSE_1_0.txt)
+
+import configure ;
+
+local requirements =
+ shared:BOOST_BOOST_CI_DYN_LINK=1
+ /boost/atomic//boost_atomic
+ ;
+
+project boost/ci
+ : source-location ../src
+ : requirements $(requirements)
+ : usage-requirements $(requirements)
+ ;
+
+lib boost_ci
+ : boost_ci.cpp
+ ;
+
+boost-install boost_ci ;
diff --git a/ci/cmake_build.sh b/ci/cmake_build.sh
new file mode 100644
index 00000000..740023fe
--- /dev/null
+++ b/ci/cmake_build.sh
@@ -0,0 +1,35 @@
+#! /bin/bash
+#
+# Copyright 2022 Alexander Grund
+# Distributed under 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)
+#
+# Bash script to perform a CMake build of Boost
+#
+# Requires the following env vars:
+# - BOOST_ROOT & SELF (setup step)
+# - BCM_GENERATOR
+# - BCM_BUILD_TYPE
+# - BCM_SHARED_LIBS
+# - BCM_ARGS
+# - BCM_TARGET
+
+set -e
+
+. "$(dirname "${BASH_SOURCE[0]}")"/set_num_jobs.sh
+
+cd "$BOOST_ROOT"
+buildDir=__build
+while [ -d "$buildDir" ]; do
+ buildDir="${buildDir}_2"
+done
+mkdir "$buildDir" && cd "$buildDir"
+
+echo "Configuring..."
+set -x
+cmake -G "$BCM_GENERATOR" -DCMAKE_BUILD_TYPE=$BCM_BUILD_TYPE -DBUILD_SHARED_LIBS=$BCM_SHARED_LIBS -DBOOST_INCLUDE_LIBRARIES=$SELF -DBoost_VERBOSE=ON "${BCM_ARGS[@]}" ..
+set +x
+
+echo "Building..."
+cmake --build . --target $BCM_TARGET --config $BCM_BUILD_TYPE -j$B2_JOBS
diff --git a/ci/cmake_install_test.sh b/ci/cmake_install_test.sh
new file mode 100755
index 00000000..c8fa95ef
--- /dev/null
+++ b/ci/cmake_install_test.sh
@@ -0,0 +1,48 @@
+#! /bin/bash
+#
+# Copyright 2022 Alexander Grund
+# Distributed under 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)
+#
+# Bash script to test consuming a Boost library via CMakes add_subdirectory command
+#
+# Requires the following env vars:
+# - BOOST_ROOT & SELF (setup step)
+# - BCM_GENERATOR
+# - BCM_BUILD_TYPE
+# - BCM_SHARED_LIBS
+
+set -eu
+
+echo "Installing Boost via CMake"
+BCM_INSTALL_PATH=/tmp/boost_install
+
+BCM_ARGS=(
+ -DCMAKE_INSTALL_PREFIX=$BCM_INSTALL_PATH
+)
+BCM_TARGET=install
+
+. "$(dirname "${BASH_SOURCE[0]}")"/cmake_build.sh
+
+cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test"
+# New unified folder used for the subdir and install test with BOOST_CI_INSTALL_TEST to distinguish in CMake
+if [ -d "$cmake_test_folder" ]; then
+ echo "Using the unified test folder $cmake_test_folder"
+
+else
+ cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_install_test"
+ echo "Using the dedicated install test folder $cmake_test_folder"
+fi
+
+cd "$cmake_test_folder"
+mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
+
+echo "Configuring..."
+cmake -G "$BCM_GENERATOR" -DCMAKE_BUILD_TYPE=$BCM_BUILD_TYPE -DBUILD_SHARED_LIBS=$BCM_SHARED_LIBS -DBOOST_CI_INSTALL_TEST=ON -DCMAKE_PREFIX_PATH=$BCM_INSTALL_PATH ..
+
+echo "Building..."
+cmake --build . --config $BCM_BUILD_TYPE -j$B2_JOBS
+
+echo "Testing..."
+ctest --output-on-failure --build-config $BCM_BUILD_TYPE
diff --git a/ci/cmake_subdir_test.sh b/ci/cmake_subdir_test.sh
new file mode 100755
index 00000000..9f13fa48
--- /dev/null
+++ b/ci/cmake_subdir_test.sh
@@ -0,0 +1,40 @@
+#! /bin/bash
+#
+# Copyright 2022 Alexander Grund
+# Distributed under 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)
+#
+# Bash script to test consuming a Boost library via CMakes add_subdirectory command
+#
+# Requires the following env vars:
+# - BOOST_ROOT & SELF (setup step)
+# - BCM_GENERATOR
+# - BCM_BUILD_TYPE
+# - BCM_SHARED_LIBS
+
+set -eu
+
+. "$(dirname "${BASH_SOURCE[0]}")"/set_num_jobs.sh
+
+cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test"
+# New unified folder used for the subdir and install test with BOOST_CI_INSTALL_TEST to distinguish in CMake
+if [ -d "$cmake_test_folder" ]; then
+ echo "Using the unified test folder $cmake_test_folder"
+
+else
+ cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_subdir_test"
+ echo "Using the dedicated subdir test folder $cmake_test_folder"
+fi
+
+cd "$cmake_test_folder"
+mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__
+
+echo "Configuring..."
+cmake -G "$BCM_GENERATOR" -DCMAKE_BUILD_TYPE=$BCM_BUILD_TYPE -DBUILD_SHARED_LIBS=$BCM_SHARED_LIBS -DBOOST_CI_INSTALL_TEST=OFF ..
+
+echo "Building..."
+cmake --build . --config $BCM_BUILD_TYPE -j$B2_JOBS
+
+echo "Testing..."
+ctest --output-on-failure --build-config $BCM_BUILD_TYPE
diff --git a/ci/cmake_test.sh b/ci/cmake_test.sh
new file mode 100755
index 00000000..b8890d90
--- /dev/null
+++ b/ci/cmake_test.sh
@@ -0,0 +1,26 @@
+#! /bin/bash
+#
+# Copyright 2022 Alexander Grund
+# Distributed under 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)
+#
+# Bash script to perform a CMake build of Boost
+#
+# Requires the following env vars:
+# - BOOST_ROOT & SELF (setup step)
+# - BCM_GENERATOR
+# - BCM_BUILD_TYPE
+# - BCM_SHARED_LIBS
+
+set -e
+
+BCM_ARGS=(
+ -DBUILD_TESTING=ON
+)
+BCM_TARGET=tests
+
+. "$(dirname "${BASH_SOURCE[0]}")"/cmake_build.sh
+
+echo "Testing..."
+ctest --output-on-failure --build-config $BCM_BUILD_TYPE
diff --git a/ci/enforce.sh b/ci/enforce.sh
index f040f415..08856998 100755
--- a/ci/enforce.sh
+++ b/ci/enforce.sh
@@ -46,11 +46,7 @@ if [ -z "$B2_CXXSTD" ]; then
export B2_CXXSTD=11
fi
-# default parallel build jobs: number of CPUs available + 1
-if [ -z "${B2_JOBS}" ]; then
- cpus=$(grep -c 'processor' /proc/cpuinfo || python -c 'import multiprocessing as mp; print(mp.cpu_count())' || echo "2")
- export B2_JOBS=$((cpus + 1))
-fi
+. "$(dirname "${BASH_SOURCE[0]}")"/set_num_jobs.sh
# Build cmdline arguments for B2 as an array to preserve quotes
if [ -z "$B2_CI_VERSION" ]; then
diff --git a/ci/github/install.sh b/ci/github/install.sh
index e652c207..c5bf3614 100644
--- a/ci/github/install.sh
+++ b/ci/github/install.sh
@@ -57,3 +57,6 @@ echo "B2_COMPILER=$B2_COMPILER" >> $GITHUB_ENV
[ -z "$B2_TSAN" ] || echo "B2_TSAN=$B2_TSAN" >> $GITHUB_ENV
[ -z "$B2_UBSAN" ] || echo "B2_UBSAN=$B2_UBSAN" >> $GITHUB_ENV
[ -z "$B2_FLAGS" ] || echo "B2_FLAGS=$B2_FLAGS" >> $GITHUB_ENV
+[ -z "$BCM_GENERATOR" ] || echo "BCM_GENERATOR=$BCM_GENERATOR" >> $GITHUB_ENV
+[ -z "$BCM_BUILD_TYPE" ] || echo "BCM_BUILD_TYPE=$BCM_BUILD_TYPE" >> $GITHUB_ENV
+[ -z "$BCM_SHARED_LIBS" ] || echo "BCM_SHARED_LIBS=$BCM_SHARED_LIBS" >> $GITHUB_ENV
diff --git a/ci/set_num_jobs.sh b/ci/set_num_jobs.sh
new file mode 100644
index 00000000..a5a7e8d3
--- /dev/null
+++ b/ci/set_num_jobs.sh
@@ -0,0 +1,17 @@
+#
+# Copyright 2017 - 2019 James E. King III
+# Copyright 2022 Alexander Grund
+#
+# Distributed under 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)
+#
+# Determine a good number of (build) jobs to use and stores it in B2_JOBS
+#
+
+if [ -z "${B2_JOBS:-}" ]; then
+ # default parallel build jobs: number of CPUs available + 1.
+ # In case of failure 2 CPUs are assumed
+ cpus=$(grep -c 'processor' /proc/cpuinfo || python -c 'import multiprocessing as mp; print(mp.cpu_count())' || echo "2")
+ export B2_JOBS=$((cpus + 1))
+fi
diff --git a/include/boost/boost-ci/boost_ci.hpp b/include/boost/boost-ci/boost_ci.hpp
index b2d5f407..b5817fbb 100644
--- a/include/boost/boost-ci/boost_ci.hpp
+++ b/include/boost/boost-ci/boost_ci.hpp
@@ -11,6 +11,17 @@
#include
#endif
+// This define is usually set in boost//config.hpp
+#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_BOOST_CI_DYN_LINK)
+#ifdef BOOST_BOOST_CI_SOURCE
+#define BOOST_BOOST_CI_DECL BOOST_SYMBOL_EXPORT
+#else
+#define BOOST_BOOST_CI_DECL BOOST_SYMBOL_IMPORT
+#endif
+#else
+#define BOOST_BOOST_CI_DECL
+#endif
+
namespace boost
{
namespace boost_ci
@@ -21,25 +32,7 @@ namespace boost
#define MSVC_VALUE false
#endif
- // Some function to test
- BOOST_NOINLINE int get_answer(const bool isMsvc = MSVC_VALUE)
- {
- int answer;
- // Specifically crafted condition to check for coverage from MSVC and non MSVC builds
- if(isMsvc)
- {
- answer = 21;
- } else
- {
- answer = 42;
- }
-#ifdef BOOST_NO_CXX11_SMART_PTR
- return answer;
-#else
- // Just use some stdlib feature combined with a Boost.Config feature as demonstration
- auto ptr = std::unique_ptr(new int(answer));
- return *ptr;
-#endif
- }
+ // Some function to test. Returns 41 for true, 42 otherwise
+ BOOST_BOOST_CI_DECL int get_answer(bool isMsvc = MSVC_VALUE);
}
}
diff --git a/src/boost_ci.cpp b/src/boost_ci.cpp
new file mode 100644
index 00000000..1c3a43cf
--- /dev/null
+++ b/src/boost_ci.cpp
@@ -0,0 +1,47 @@
+//
+// Copyright (c) 2022 Alexander Grund
+//
+// 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)
+
+#define BOOST_BOOST_CI_SOURCE
+
+#include
+// Just some dependency on another Boost library
+#include
+
+// Some simple struct big enough so that the atomic is forced to use a lock
+// forcing it to call into the library
+struct X
+{
+ double x, y, z;
+ explicit X(int value = 0): x(value), y(value), z(value) {}
+};
+
+namespace boost
+{
+ namespace boost_ci
+ {
+ // Some function to test
+ int get_answer(const bool isMsvc)
+ {
+ boost::atomic answer;
+ // Specifically crafted condition to check for coverage from MSVC and non MSVC builds
+ if(isMsvc)
+ {
+ answer = X(21);
+ } else
+ {
+ answer = X(42);
+ }
+#ifdef BOOST_NO_CXX11_SMART_PTR
+ return answer.load().x;
+#else
+ // Just use some stdlib feature combined with a Boost.Config feature as demonstration
+ auto ptr = std::unique_ptr(new int(answer.load().x));
+ return *ptr;
+#endif
+ }
+ }
+}
diff --git a/test/Jamfile b/test/Jamfile
index fdbbeaba..db979644 100644
--- a/test/Jamfile
+++ b/test/Jamfile
@@ -8,9 +8,8 @@
import os ;
import testing ;
-project boost/ci/test
- : requirements
- .
+project : requirements
+ /boost/ci//boost_ci
;
local B2_ADDRESS_MODEL = [ os.environ B2_ADDRESS_MODEL ] ;
diff --git a/test/cmake_test/CMakeLists.txt b/test/cmake_test/CMakeLists.txt
index 01efe823..429ada16 100644
--- a/test/cmake_test/CMakeLists.txt
+++ b/test/cmake_test/CMakeLists.txt
@@ -11,8 +11,27 @@ project(cmake_subdir_test LANGUAGES CXX)
if(BOOST_CI_INSTALL_TEST)
find_package(boost_boost_ci REQUIRED)
else()
- add_subdirectory(../.. boostorg/ci)
- add_subdirectory(../../../config boostorg/config)
+ add_subdirectory(../.. boostorg/boost-ci)
+
+ set(deps
+ # Primary dependencies
+ atomic
+ config
+ core
+ # Secondary dependencies
+ align
+ assert
+ predef
+ preprocessor
+ static_assert
+ throw_exception
+ type_traits
+ winapi
+ )
+
+ foreach(dep IN LISTS deps)
+ add_subdirectory(../../../${dep} boostorg/${dep})
+ endforeach()
endif()
add_executable(main main.cpp)