Gate the unit tests on the Boost components they link - #200
Conversation
mr-smidge
left a comment
There was a problem hiding this comment.
Great spot, thank you!
I left some minor comments.
| # 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Claude often does this for me too!
There was a problem hiding this comment.
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!
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>
464ebc1 to
1b5e1b8
Compare
Thanks, updated the patch (squashed). |
The comment is gone and the message no longer names a distribution, as in the squashed commit on xsco/libdjinterop#200.
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 withCMP0167set toNEW(
CMakeLists.txt:17), theBoostConfigpackage is satisfied by a headers-onlyBoost install. On such a system:
The twelve test targets are configured anyway,
${Boost_LIBRARIES}expands tonothing, and the two tests that use Boost.Filesystem fail to link with
undefined references to
boost::filesystem::detail::*. TheQUIETonfind_packagehides the diagnostic that would have explained it, and theelse()branch ("Unit tests not available, as Boost cannot be found") is neverreached -- which is exactly the case it is there for.
This is common on Debian and Ubuntu, where
libboost-devprovides the headersand
libboost-filesystem-devis a separate package.This PR gates the tests on
Boost_filesystem_FOUNDandBoost_system_FOUNDaswell, and makes the message name what is missing.
Tested on Ubuntu 24.04 (CMake 3.30.5, GCC 13.3.0):
ctestpasses 12/12.succeeds, and the configure output says that Boost.Filesystem/System are
missing.