John Maddock 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 see how. CMake doesn't know whether someone will include header X or not. With compiled libraries, we use CMake options to control whether the library is built with support for ICU or not, but here we don't build anything. I suppose you could still add a build option that won't do anything except `target_link_libraries(boost_regex INTERFACE ICU::in)`, as suggested in the issue (although for consistency the option should be named BOOST_REGEX_ENABLE_ICU because that's the convention the other libraries use.)