[CMake] multi-tiered config file inclusion

Michael Hertling mhertling at online.de
Sat May 29 09:53:14 EDT 2010


On 05/28/2010 06:35 AM, Hugh Sorby wrote:
> 
> Hi All,
> 
> The question I have is about our old friend the static library and 
> config files.
> 
> In my project I use two other libraries that I depend on (both built via 
> CMake)
>   1. OpenCASCADE
>   2. wxWidgets
> 
> plus some others.  So, when I build my project in its application form I 
> locate the LIB-config.cmake files for the dependent libraries and then 
> just insert the include dir and libraries in the appropriate place and 
> all is well in my world.  When I build my project as a static library I 
> still depend on these two libraries and everything compiles fine.  Now, 
> when I try to build and link an application (like a test app) into my 
> library the problem occurs.  I was hoping that with the config files I 
> would get the desired chaining effect for dependent static libraries.  
> But I don't.  What I get is a target name instead of the target location 
> that the linker needs.  Because I am no longer including files like 
> OpenCASCADE-config.cmake I don't get the imported target information 
> because they are another level down (on the include tree).  This only 
> happens with CMake targets,  non-CMake targets get set in full and 
> propagate well.
> 
> Has anyone else come across this, and is there a solution to my 
> problem.  I was hoping to have an easy solution where my library would 
> drag in all required dependencies without the test application (in this 
> case) needing to find them, hence the config files.  Which by the way 
> have worked very well for the single tiered situation.

As far as I understand, your project provides a library which depends
on two libraries built with CMake and several others. Now, you'd like
to link an application against your library and have difficulties to
gather the correct settings necessary to enable your library and its
prerequisites, in particular w.r.t. imported targets, right?

Does your library provide a config file for itself, and does this
config file access the prerequisites' config files in some way? How do
you forward the prerequisites' settings through your library's config
file to the application's CMakeLists.txt? Perhaps, you could post an
example to point out your concern in more detail.

Best regards,

Michael


More information about the CMake mailing list