FindBoost ignores required dependent libraries
When using FindBoost to find e.g. filesystem the module knows that system
is also required. However it chooses to ignore if it wasn't able to find it but still adds it to the library target leading to "missing Boost::system...forget IMPORTED...?" errors
https://gitlab.kitware.com/cmake/cmake/blob/662ab10bc2ec952b89b6a6f5824caf608734051f/Modules/FindBoost.cmake#L1941
The comment states that those are "optional" but they are not. If they are really optional then they should not be added to the targets when not found: https://gitlab.kitware.com/cmake/cmake/blob/662ab10bc2ec952b89b6a6f5824caf608734051f/Modules/FindBoost.cmake#L2067
Furthermore there is a stray set
command which messes up top-level variables (although I think it may not lead to actual problems by chance). Problem is that _ret
is not set/empty hence it sets the first variable in _Boost_${uppercomponent}_DEPENDENCIES
to the value of the 2nd:
https://gitlab.kitware.com/cmake/cmake/blob/662ab10bc2ec952b89b6a6f5824caf608734051f/Modules/FindBoost.cmake#L1003