[CMake] Trying to get build info for a target

Gary Kramlich grim at reaperworld.com
Sun Jan 1 01:47:18 EST 2012


On 12/31/2011 05:03 PM, Robert Dailey wrote:
> Storing the source directory will require the exact idea you had
> mentioned. Use an internal cache variable or, even better, a target
> property. This is how I have done it. Each target that I create
>  specifies a list of its include directories (where other targets that
> depend on it can find its header files, and will append this directory
> to its list of searchable include directories).

I learned the  hard way, that the target property can't be named
SOURCE_LOCATION, since it just spit out the value for the LOCATION
property, which seems like a bug, unless SOURCE_LOCATION was left around
for compatibility, but I couldn't find it documented anywhere.

> 
> For defines, and I think cflags, you can use get_target_property().

Coming up empty for the target and the directory.  Tried DEFINITIONS,
COMPILE_DEFINITIONS, and COMPILE_FLAGS.  When used on the target, i get
a -NOTFOUND, and I get an empty string when used on the source directory.

> For libraries, I've also maintained a list in a target property. This is
> how you build recursive dependencies. CMake will automatically set up
> build order based on your dependencies, however you cannot query these
> libraries without maintaining them yourself. Also, another benefit to
> maintaining dependencies in target properties is that you can throw an
> error message if a target depends on another target that does not yet
> exist (used to ensure that targets are defined in the proper order in
> the cmake scripts).

It looks like I'll have to be setting these up manually too, since even
though cmake has knowledge about it, it won't give the information out
to scripts.

Maybe I'll be better off requiring that this module be included in the
CMakeLists.txt for the target it's going to work on...  But that's
really annoying that cmake is dictating how a module can work, even
though all I'm trying to do is query a target...

> Hope that helps.

It helps in the sense that I'm not chasing something that can't be done
anymore ;)

> ---------
> Robert Dailey

-- 
Gary Kramlich <grim at reaperworld.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120101/ea310e55/attachment.pgp>


More information about the CMake mailing list