Ok, that makes sense to me. What I’m seeing though, is that find modules and 
xyzConfig files for some software packages do not make a variable available 
that contains just target names. Xyz_LIBRARIES contains full path file 
locations.

This is my immediate frustration with leptonica for example. The config file it 
creates does not output a list of targets, and even if it did, it doesn’t 
dynamically build the list of targets depending on what dependencies it finds 
(libpng, libjpeg, etc…)

I think I will fork and rewrite the leptonica cmake file to properly expose 
target names.

Thanks,
Adam

From: Craig Scott [mailto:audiofana...@gmail.com]
Sent: Wednesday, February 03, 2016 4:26 PM
To: Adam Rankin <aran...@robarts.ca>
Cc: cmake@cmake.org
Subject: Re: [CMake] xyz_LIBRARIES



On 4 February 2016 at 04:45, Adam Rankin 
<aran...@robarts.ca<mailto:aran...@robarts.ca>> wrote:
Hello all,

I am trying to sort out a project with multiple layers of dependencies and I am 
trying to figure out the “right” way of configuring things.

First easy question: Should a value xyz_LIBRARIES contain target names, or 
library file locations?

Preferably target names, assuming you mean imported targets (see answer to next 
question).


 Second question: Should a FindXYZ.cmake file add imported targets, or should a 
USE_xyz variable be created for later inclusion? (what if the project does not 
export its targets?)

Imported targets will be better for end users/developers. An imported target 
can provide not just the library file location, it can also provide other 
dependencies such as dependent libraries that also must be linked, header 
search paths, etc. Furthermore, with an imported target you can explicitly 
control what other targets are affected by these dependencies simply by linking 
against your imported target. If you chose the USE_xyz variable + include 
approach, then the include file will typically end up calling  
link_libraries(), link_directories() and/or include_directories() commands and 
making those things apply to all targets defined thereafter, which used to be 
the norm but is no longer necessary with all the target_xxx() commands added in 
more recent versions of CMake (well, 2.8.11 or later).


 Third question: How’s your day going today?

Ask me again after the coffee kicks in. :P


--
Craig Scott
Melbourne, Australia
http://crascit.com
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to