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/ec93082b6b54cd734b236638e7c4ba76... 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.