[CMake] Target properties, dependencies and subdirs order?

Brad King brad.king at kitware.com
Mon Sep 25 10:07:37 EDT 2006


Jeroen Janssen wrote:
> Hi,
> 
> I have a question on the evaluation/creation of target properties in
> relation with dependencies.
> 
> Example:
> <topdir>
>   TestDll     directory with interface/ and src/
>   TestExe   directory with src/
> 
> TestExe has a dependency to TestDll (with add_dependency)
> 
> Now I would like to add the interface directory of TestDll to the
> include paths of TestExe (based on the target properties of TestDll).
> Note that for this 'small' example I could probably 'short-circuit'
> things, but this way is the easiest to explain one of the conceptual
> problems we have.
> 
> I found a 'subdirectory-order-dependency' problem that I need to
> understand/find a solution to:
> 
> When performing GET_TARGET_PROPERTY( TestSO_INTERFACEDIR TestDll
> LOCATION), this only works when <topdir> has TestDll before TestExe in
> the SUBDIRS section. If TestDll is after TestExe (e.g. "SUBDIRS(
> TestExe TestDll)" ), the GET_TARGET_PROPERTY fails on TestDll
> (resulting in NOTFOUND).
> 
> Now I would rather not have any dependency/order information in the
> topdir CMakeLists.txt. I was hoping that "add_dependencies" would make
> sure information got evaluated in the "right order".
> 
> Is there anyone doing something similar?
> Any thoughts on how to solve this problem?

Use ADD_SUBDIRECTORY instead of SUBDIRS.  Then the subdirectories will
be processed in-order with the top-level CMakeLists.txt file.

-Brad


More information about the CMake mailing list