[CMake] Internal propagation of usage requirements
Lukas Böger
dev at lboeger.de
Fri Jun 8 09:58:19 EDT 2018
Dear cmake-Gurus,
When unit tests and an exported library shall be compiled with identical _private_ settings (include directories, compiler flags etc.), I see these options:
(1) define variables to be passed to target_* functions for both library and test target
+ simple solution
- violates avoid-variables-idiom
- possibly uses "non-local" variables defined in another CMakeLists.txt (reduces readability)
(2) link both library and test targets against an internal, usage-requirement-only interface library
+ modern approach, no variables, only target_* functions invoked
- when compiling a static library, the internal target must be exported, too (though "filtered" by LINK_ONLY later on)
(3) retrieve lib properties via get_property, then propagate them via target_* functions
+ variables in use have a "local" scope of the CMakeLists.txt
- verbose and clumsy
Am I missing a solution? Which one is preferable and why? Any pro/cons that I haven't seen?
Thanks for any advice!
Best,
Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180608/07ede92d/attachment.html>
More information about the CMake
mailing list