Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2021-10-08 14:32:19


On 10/8/21 5:07 PM, John Maddock via Boost wrote:
> I have a regex bug report relating to linking to ICU when using CMake:
> https://github.com/boostorg/regex/issues/143
>
> Is there a correct way to specify in the CMake file that if you use
> header X, then you should also link to library Y, but otherwise not?

I don't think so, unless you create a new library (target, in CMake
terms) that will depend on ICU, and that users will have to "link" with.

Or you could conditionally enable ICU support based on CMake config
option. We do something like this in Boost.Filesystem:

https://github.com/boostorg/filesystem/blob/ec93082b6b54cd734b236638e7c4ba76e3b639e7/CMakeLists.txt#L15-L21

Either way, the user will have to do something explicitly - either add
linking with the new target or specify the option in the CMake command
line. Simply including a C++ header won't work as that is beyond CMake
scope.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk