[cmake-developers] Convention driven CMAKE_USE_PACKAGE macro

Alexander Neundorf neundorf at kde.org
Fri Feb 24 12:19:36 EST 2012


On Friday 24 February 2012, Brad King wrote:
> On 2/24/2012 5:31 AM, Stephen Kelly wrote:
> > When building with Qt5, we want to change the convention away from USE
> > files, and towards a concept of using packages whose variables have
> > conventional names, mostly those conventions in the Modules/readme.txt,
> > so that after find_package(Foo), Foo_INCLUDE_DIRS contains the include
> > directories that targets using Foo need to use, and
> > Foo_COMPILE_DEFINITIONS contains the compile definitions that they need
> > etc. This would also be an incentive for other packages to follow the
> > convention.
> 
> Sounds good.
> 
> > macro(cmake_use_package _target _package)
> 
> Rather than upstreaming a macro like that I'd rather see effort made
> toward first-class "usage requirements" support in CMake.  The new
> per-target include directories was a big step necessary to achieve it.
> 
> Basically targets (and imported targets) should have new properties
> on them that propagate information to application targets that link
> to them.  Currently CMake handles transitive linking requirements
> automatically but not other requirements such as COMPILE_DEFINITIONS
> and INCLUDE_DIRECTORIES.  This will require C++ implementation but
> will be much more powerful than the proposed macro.  Just the simple
> 
>    target_link_libraries(A B)
> 
> command would be enough to propagate B's requirements while compiling
> A's source files.  I can go into more detail upon request.


I agree.
Except one thing (we discussed this already several times I think), I would 
prefer a dedicated command for this, so it is obvious to the reader that the 
command does more than just linking, e.g.:
target_use_package(A B)

Alex



More information about the cmake-developers mailing list