Skip to content

Gate the unit tests on the Boost components they link - #200

Merged
mr-smidge merged 1 commit into
xsco:mainfrom
sebasje:fix-boost-test-gate
Sep 14, 2026
Merged

mr-smidge merged 1 commit into
xsco:mainfrom
sebasje:fix-boost-test-gate

Conversation

@sebasje

@sebasje sebasje commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Hi,

I'm using libdjinterop for my (new) application. It's very nice and high quality, thanks a lot!

I've run into a buildsystem/dependency issue, which was easy to work around on my side, but also easy to fix in your buildsystem. I thought I'd share it. Would be nice if you could consider merging it so other users don't run into it.

The unit tests are gated on Boost_FOUND, but with CMP0167 set to NEW
(CMakeLists.txt:17), the BoostConfig package is satisfied by a headers-only
Boost install. On such a system:

Boost_FOUND=1  Boost_filesystem_FOUND=0  Boost_LIBRARIES=

The twelve test targets are configured anyway, ${Boost_LIBRARIES} expands to
nothing, and the two tests that use Boost.Filesystem fail to link with
undefined references to boost::filesystem::detail::*. The QUIET on
find_package hides the diagnostic that would have explained it, and the
else() branch ("Unit tests not available, as Boost cannot be found") is never
reached -- which is exactly the case it is there for.

This is common on Debian and Ubuntu, where libboost-dev provides the headers
and libboost-filesystem-dev is a separate package.

This PR gates the tests on Boost_filesystem_FOUND and Boost_system_FOUND as
well, and makes the message name what is missing.

Tested on Ubuntu 24.04 (CMake 3.30.5, GCC 13.3.0):

  • With Boost.Filesystem installed: all 12 test targets configure and build, and
    ctest passes 12/12.
  • With the Boost headers only: no test targets are configured, the build
    succeeds, and the configure output says that Boost.Filesystem/System are
    missing.

@mr-smidge mr-smidge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great spot, thank you!

I left some minor comments.

Comment thread CMakeLists.txt Outdated
Comment on lines +415 to +420
# Boost_FOUND alone is not enough: with CMP0167 NEW the BoostConfig package
# is satisfied by a headers-only install, so Boost_FOUND is true while
# Boost_LIBRARIES is empty. The tests below then configure and fail to link
# with undefined references to boost::filesystem::detail::*, and the QUIET
# above hides the one message that would have explained why. Gate on the
# components that are actually linked.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems to focus on the code as it was, when it contained the bug that your PR fixes. But that's not the purpose of code comments - in fact, I don't think anything in this comment adds value, so would suggest removing it entirely.

Q: Was this comment written by AI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Claude code.

Note that I did review the PR and added a personal note, and of course take full responsibility for it.

Thanks for the quick review, I'll adjust and will resubmit according to your preferences.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude often does this for me too!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's awfully verbose, but I have it rather tell me too much than too little.
Especially if this avoids it reverting a change some other time, because it forgot (which it also sometimes does).

Thanks btw for getting this through this quickly!

I might have some more useful (to me at least) things, nothing urgent though. Support for transactions came up, but that's obviously a larger change.

Also I'm interested in OneLibrary support. Guess we'll keep in touch! Cheers!

Comment thread CMakeLists.txt Outdated
The tests are gated on `Boost_FOUND`, but with CMP0167 set to NEW the
BoostConfig package is satisfied by a headers-only install: `Boost_FOUND`
is true while `Boost_filesystem_FOUND` is false and `Boost_LIBRARIES` is
empty.  The twelve test targets are then configured anyway, and the two
that use Boost.Filesystem fail to link with undefined references to
`boost::filesystem::detail::*`.  The `QUIET` hides the one message that
would have explained it, and the `else()` branch -- which exists for
exactly this case -- is never reached.

This is common on Debian and Ubuntu, where `libboost-dev` provides the
headers and `libboost-filesystem-dev` is a separate package.

The tests are now gated on the filesystem and system components as well,
and the message says what is missing.

Co-authored-by: Adam Szmigin <smidge@xsco.net>
@sebasje
sebasje force-pushed the fix-boost-test-gate branch from 464ebc1 to 1b5e1b8 Compare September 14, 2026 20:16
@sebasje

sebasje commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Great spot, thank you!

I left some minor comments.

Thanks, updated the patch (squashed).

@mr-smidge
mr-smidge merged commit 810c105 into xsco:main Sep 14, 2026
14 checks passed
sebasje added a commit to sebasje/seabass that referenced this pull request Sep 15, 2026
The comment is gone and the message no longer names a distribution, as
in the squashed commit on xsco/libdjinterop#200.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants