[cmake-developers] Setting includes, defines and other usage requirements with one command
Stephen Kelly
steveire at gmail.com
Thu Jan 24 15:00:02 EST 2013
Hi there,
I've pushed the tll-includes-defines topic to my clone again, rebased to
master.
It allows the removal a lot of redundant use of target_include_directories
and target_compile_definitions. I think the real value of the whole feature
will only come when all usage requirements can be set by connecting targets
together one time with one command, be that with tll() or with
target_use_interfaces().
One reason I think tll() should be used for that is that it has the
implication that can be documented and easily understood - namely that cmake
requirements usage is based on linking targets together.
Linking correctly requires having compiled correctly, and compiling
correctly depends on having used the correct include directories and compile
definitions as specified by upstream, as well as a few other things such as
use of -fPIC. Currently in cmake master, the -fPIC compile flag may be added
depending on what targets are used in tll() calls, but the compile
definitions and the include directories are not. As linking correctly
depends on compiling correctly as specified by upstream, it seems natural to
ensure that compiling correctly is possible as a result of
target_link_libraries calls.
As far as I understand, the only objection is to the idea that
target_link_libraries would be doing something other than linking, and it
might not be obvious. It is currently used for -fPIC, so I'm not so sure.
Also, the objection is not that people would have to learn or discover, in
documentation or otherwise, that target_link_libraries could have an effect
other than linking. The objection instead is that, even long term and for
experienced people, reading a line of code that contains a
target_link_libraries call alone would not inform them of whether it is
'only' linking or whether it has other affects. This also seems funny to me.
Given a line containing target_use_interfaces(foo PRIVATE bar), it is
impossible to know from reading alone whether foo INCLUDE_DIRECTORIES,
COMPILE_DEFINITIONS, LINK_LIBRARIES, or all three, are affected by the line.
In both cases, the way to know is to use
-DCMAKE_DEBUG_TARGET_PROPERTIES=INCLUDE_DIRECTORIES or similar.
Also feel free to respond to any parts of
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/5526/focus=5710
which are not obviously already addressed.
Thanks,
Steve.
More information about the cmake-developers
mailing list