<!DOCTYPE html>
<html><head>
    <meta charset="UTF-8">
</head><body><p class="default-style">Dear cmake-Gurus,</p><p class="default-style">When unit tests and an exported library shall be compiled with identical _private_ settings (include directories, compiler flags etc.), I see these options:</p><p class="default-style">(1) define variables to be passed to target_* functions for both library and test target<br>    + simple solution<br>    - violates avoid-variables-idiom<br>    - possibly uses "non-local" variables defined in another CMakeLists.txt (reduces readability)</p><p class="default-style">(2) link both library and test targets against an internal, usage-requirement-only interface library<br>    + modern approach, no variables, only target_* functions invoked<br>    - when compiling a static library, the internal target must be exported, too (though "filtered" by LINK_ONLY later on)<br></p><p class="default-style">(3) retrieve lib properties via get_property, then propagate them via target_* functions<br>    + variables in use have a "local" scope of the CMakeLists.txt<br>    - verbose and clumsy</p><p class="default-style">Am I missing a solution? Which one is preferable and why? Any pro/cons that I haven't seen?</p><p class="default-style">Thanks for any advice!</p><p class="default-style">Best,<br>Lukas<br></p></body></html>