[CMake] Target-specific include directories?

Robert Dailey rcdailey at gmail.com
Thu Oct 6 16:49:56 EDT 2011


I'm using cmake (through the GUI) on Windows (version 2.8.5).

Currently I have a define_project() function that all 100 or so
sub-directories use to define its project. This function calls
add_executable(), sets target properties, and everything necessary to set it
up properly to build in Visual Studio. Each project is also able to pass in
a list of include directories that other targets shall use if they specify
that target as a dependency. So for example:

if I have two targets, A and B, and A depends on B, if B specified "C:\foo"
as its source include directory, then target A will have an additional
include directory of "C:\foo" to get to B's source code.

Right now I'm implementing this functionality using an internal cache
variable. Each target defines a ${target}_SOURCEDIR cache variable. So I
would have a B_SOURCEDIR variable with "C:\foo" in it, and target "A" would
use this variable to add include directories to itself.

The problem with this approach is that it requires projects to be processed
by CMake in the order of their dependency. I would like to make the project
definition order (the order I call define_project()) to not matter, so I was
wondering if there was a built-in functionality for this kind of behavior or
if there is a different implementation I could use. Can anyone help me out?

Thanks in advance.

---------
Robert Dailey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111006/dc931723/attachment.htm>


More information about the CMake mailing list