On 7. Jan, 2010, at 10:51 , Nico Schlömer wrote:

> Hi,
> 
> I'm writing a FintMymodule.cmake file for a set of libraries (read:
> components), and with the given examples in the official CMake/Modules
> folder it comes along nicely.
> 
> One thing I couldn't figure out now is how to set link dependencies
> between the different components; that is, if I link against component
> A not only libA is required for linking but also libB and libC. With
> regular libraries I understand I can pull this is in by
> TARGET_LINK_LIBRARIES..
> 
> Cheers,
> Nico
> 

One quick question: Are these libraries created by you? In that case you 
shouldn't write a FindMymodule.cmake, but a MymoduleConfig.cmake (see the 
documentation of find_package).

Anyhow, to define the transitive link dependencies you can either use 
target_link_libraries(A LINK_INTERFACE_LIBRARIES B C) if your CMake is new 
enough, or you can use set_target_properties(A PROPERTIES 
LINK_INTERFACE_LIBRARIES "B;C"). Both solutions require that you use 
add_library(X IMPORTED) (where X = A, B and C) and set their IMPORTED_LOCATION 
property to the location on the file system. All of this is full automatic if 
you write a MymoduleConfig.cmake, because then you can use

install_targets(A B C EXPORT MymoduleExports
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
  PUBLIC_HEADER DESTINATION include
  )

install(EXPORT MymoduleExports
  NAMESPACE Mymodule_
  DESTINATION share/mymodule/cmake
  )

which will install a file 
${CMAKE_INSTALL_PREFIX}/share/mymodule/cmake/MymoduleExports.cmake containing 
all the IMPORT stuff and which you can INCLUDE in your MymoduleConfig.cmake.


I hope I could help a bit, otherwise tell us which case it is and I'll be able 
to help more.

Michael

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to