[CMake] intercomponent link dependencies?

Michael Wild themiwi at gmail.com
Wed Jan 13 03:43:42 EST 2010


On 13. Jan, 2010, at 1:55 , Nico Schlömer wrote:

> Pheeew..
> So I've now been trying to include one *single* library from an
> external project (liba.a) into my own project, writing FindA.cmake.
> Somehow I still fail to apply the dependencies correctly. What I do is
> 
> [...]
> ADD_LIBRARY(A STATIC IMPORTED)
> SET_TARGET_PROPERTIES( A PROPERTIES
>                                             IMPORTED_LOCATION
> "${A_LIBRARY}"     %set above
>                                             LINK_INTERFACE_LIBRARIES
> "${A_LINK_INTERFACE_LIBRARIES}"   % set above to something like
> "/usr/lib/liblapack.a;/usr/lib/blas.a;"
>                       )
> [...]
> 
> [Setting TARGET_LINK_LIBRARIES(A LINK_INTERFACE_LIBRARIES
> "${A_LINK_INTERFACE_LIBRARIES}" ) did *not* work for me.]
> 
> Now,  in the main CMakeLists.txt I say Find( A REQUIRED ), and I was
> naivly expecting that upon
> 
> TARGET_LINK_LIBRARIES ( main.out A )
> 
> *all* the dependent libraries would be pulled in too. This is not the case. :/
> 
> What am I missing?
> 
> Cheers,
> Nico

Coming to think of it: Why don't you simply list ${A_LIBRARY}, /usr/lib/liblapack.a and /usr/lib/blas.a (shouldn't that be libblas.a?) in A_LIBRARIES and the use that in TARGET_LINK_LIBRARIES? Simpler for you and less work for CMake...

Michael

PS: I can't tell for sure from what you show, but you REALLY should discover lapack and blas instead of hardcoding their paths, e.g. using FindBLAS and FindLAPACK (which admittedly have their deficiencies)



More information about the CMake mailing list