Flamefire
Flamefire

Reputation: 5807

Add wrapper for a CMake find module

In our project we use boost a lot. So find_package(Boost ...) is called often with different components (for different modules/libraries). This causes a lot of "Imported targets not available" warnings (like REALLY a lot)

I want to avoid all this log clutter without forcing all users to upgrade CMake when upgrading boost. I can assume newer boost versions are fine. But there is nothing to disable this warning or show it only once.

So my idea was to wrap the find_package(Boost ...) and simply return a status. Easiest way seems to create a custom FindBoost.cmake and put it in CMAKE_MODULE_PATH. But how would I then call into the original boost find-module? If I call find_package(Boost ...) again it would probably call the same module again.

Also: Gathering the arguments to pass would probably be quite cumbersome. Is there an automatic way of doing that (like ARGN for regular functions)?

Note: The obvious solution of using a custom macro find_boost which does this should not be considered as it involves changing all callers.

Upvotes: 3

Views: 449

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 66061

You may create FindBoost.cmake script, which is the same as one in CMake of some version, but with corresponded

message(WARNING ...)

lines removed.

Add this script into your project, and adjust CMAKE_MODULE_PATH variable for find it.


Boost warnings "Imported targets not available" cannot be disabled with QUIET option for find_package: Shipped with CMake, script FindBoost.cmake doesn't check this option when emits these warnings.

Upvotes: 1

Related Questions