[CMake] Inter-project dependencies

Brad King brad.king at kitware.com
Wed May 21 10:51:52 EDT 2008


Emmanuel Blot wrote:
> Hi,
> 
> I'm using CMake to build two C-based projects
> 
> The first CMake project builds several static libraries (ARM elf / eCos)
> The second CMake project builds several application which do link
> against the static libraries produced within the first project.
> However, both CMake projects are unrelated from CMake perspective.
> 
> I've not been able to find a CMake rule to tell CMake to force relinking
> an application of the second project when a library generated in the
> first project has been updated. I always need to "touch" a source file
> of the second project so that Make rebuilds the file and is forced to
> relink the application with the static libraries of the first project.
> 
> Which CMake rule should/could I use to add a dependency from the 2nd
> project onto an external static library (of the 1st project) ?

In the second project make sure you specify the libraries to link from
the first project by full path.  Then the dependencies will be hooked
up.  Without a full path CMake does not know how to add a build-time
dependency on a library.  You can get a full path in the second project
by using find_library.  Even better, use export/import capabilities:

http://www.cmake.org/Wiki/CMake_2.6_Notes#Exporting_and_Importing_Targets

-Brad


More information about the CMake mailing list