Repository navigation
CMake: standalone build with check and check-valgrind targets - #63
Conversation
Allow the library to be configured on its own, outside the Boost
superproject, using an installed Boost (find_package(Boost 1.85
CONFIG)).
- When this is the top-level project and BUILD_TESTING is on,
include CTest and add two targets:
check run the unit tests (ctest --output-on-failure)
check-valgrind run them under valgrind (ctest -T memcheck),
only when valgrind is found
- Pass -C <config> to ctest only when a configuration is set, so the
targets work with single-config generators and an empty
CMAKE_BUILD_TYPE (a bare "-C" made ctest fail).
- Run valgrind with --error-exitcode=1, --leak-check=full and
--errors-for-leak-kinds=definite, so memory errors and definite
leaks fail the test instead of only being listed in the memcheck
summary.
- test/CMakeLists.txt: list the tests directly (base_test,
constant_erase_test, soft_iterator_invalidation,
space_optimized_test) instead of reading them from Jamfile.v2. The
tests are built with C++11 and -Wall -Wextra -Wpedantic (/W4 on
MSVC), and a "tests" target builds them all.
The library target no longer lists its Boost dependencies.
- Raise the cmake_minimum_required lower bound from 3.8 to 3.10. CMake 3.31 and later warn that compatibility with versions older than 3.10 is deprecated. - Add the test subdirectory with EXCLUDE_FROM_ALL. A plain build no longer compiles the tests, following the Boost convention. They are built through the "tests" target, which check and check-valgrind depend on.
The library target's Boost dependencies had been removed because the
standalone build failed with them. A b2-installed Boost (for example
the distro packages) provides only Boost::headers and none of the
per-library targets, so the link interface named targets that did
not exist ("The link interface of target boost_circular_buffer
contains: Boost::assert but the target was not found").
Without the list, Boost::circular_buffer did not pass on its
dependencies' include paths in the superproject or in
test/cmake_test.
- Put the dependencies back, in a BOOST_CIRCULAR_BUFFER_DEPS list
that is passed to target_link_libraries.
- In the standalone build, after find_package(Boost), make each
dependency target that does not exist an alias of an interface
library that links Boost::headers. Targets that already exist,
from the superproject or a CMake-installed Boost, are left alone.
- The file is now maintained by hand rather than generated by
boostdep, so drop the "Generated by" line.
CLAUDE.md:
- Describe the hand-maintained dependency list and the
Boost::headers fallback, and stop telling people to regenerate
CMakeLists.txt with boostdep.
- test/CMakeLists.txt lists its tests separately from Jamfile.v2
and must be kept in sync with it. cmake_install_test and
cmake_subdir_test are replaced by cmake_test.
- Add instructions for the standalone CMake build (CMake 3.10 or
newer, Boost 1.85 or newer, -DBUILD_TESTING=ON, check and
check-valgrind).
The header was lost when the file was rewritten to list the tests directly. Restore the Boost Software License notice.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #63 +/- ##
==========================================
Coverage ? 99.43%
==========================================
Files ? 10
Lines ? 4578
Branches ? 3358
==========================================
Hits ? 4552
Misses ? 23
Partials ? 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Looks OK. The change from 3.8 to 3.10 is unnecessary (for the stated reason) but harmless. It's possible to avoid the Starting from 1.92, the b2-installed Boost actually provides compatibility targets for the header-only libraries (boostorg/boost_install@cd84189) but that's not going to be an issue because the code checks But everything is fine as it is, these are minor comments. The standalone case probably needs to be added to CI, though. |
|
@pdimov All good, just didn't want to (inadvertently) cause you more headaches. |
Let the library be configured and tested on its own, against an installed Boost, without a Boost superproject checkout. Add
checkandcheck-valgrindtargets.Usage
Requires CMake 3.10 or newer and Boost 1.85 or newer, found with find_package(Boost CONFIG).
Changes
Standalone build (only when circular_buffer is the top-level project)
Dependencies
Tests
Other
Testing
With the system Boost 1.90 (b2-installed, Boost::headers only), CMake 4.2 and Ninja: