[CMake] Advice on how to remove duplicated code for object and interface library setup
Stephen McDowell
sjm324 at cornell.edu
Wed Mar 21 16:03:39 EDT 2018
Hi Deniz,
Thanks for the response! I tested it out and it seems to work exactly as you describe :)
I don’t want to depend on an un-released version of CMake though. The original desire is because I kept making mistakes / adding definitions for one and not the other (code duplication at its finest…).
I discovered that I can populate one, e.g. only modify mylib_obj and then later grab these properties to add to the interface:
get_target_property(MYLIB_OBJ_INTERFACE_COMPILE_DEFINITIONS mylib_obj INTERFACE_COMPILE_DEFINITIONS)
and also the same for INTERFACE_COMPILE_OPTIONS etc. (Note: for anybody reading this, understand that INTERFACE_COMPILE_DEFINITIONS is desired here, COMPILE_DEFINITIONS includes private items which I do not want in this case).
Is getting the properties and then later setting them a reasonable solution here, or is this a bad idea?
-Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180321/8e074529/attachment-0001.html>
More information about the CMake
mailing list