[CMake] using IMPORTED targets in multiple projects within one CMake tree

Alexandre.Feblot at thomsonreuters.com Alexandre.Feblot at thomsonreuters.com
Tue May 5 12:38:23 EDT 2009


I saw this too.
IMHO, it's a bug. If it's a feature, I don't see the point.

I ended defining all my imported targets in the top directory, to be
able to use them wherever I need them.

Alexandre

-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf
Of Pentasopor
Sent: Tuesday, 05 May 2009 18:06
To: cmake at cmake.org
Subject: [CMake] using IMPORTED targets in multiple projects within one
CMake tree

Hi all,

here is what I'm trying to do:

I have a CMake build tree with several projects and targets with some
depending on others (impressive eh? ;)).  Furthermore I have a library
that I need to build outside of CMake and therefor I just added it
using

> add_library(xxx SHARED IMPORTED)

(But anyway - this is MY library, so I need to install it and
everything.)

I also set some target properties (like IMPORTED_LOCATION) for it.
All this happens in CMakeLists file 'A'.  So my build tree looks like
this:

(I will call the CMakeLists.txt files A, B, ... for distinction)

M
|--- A
|--- B
|  |--- BA
|  |--- BB
|--- C

where M is something like:
====
PROJECT(TheWholeThingy)
#.. some defines a.s.o.
ADD_SUBDIRECTORY(A)
ADD_SUBDIRECTORY(B)
ADD_SUBDIRECTORY(C)
====

Now if I try to use target 'xxx' in B, it will not get resolved.  But
if I add a 'real' target (without IMPORTED) to 'A', I can use it (e.g.
in TARGET_LINK_LIBRARIES) without problems in B.

I just want to have a single point in my CMake-lists where I define
this externally built library and use it at several positions within
the rest of my CMake tree.

(Only at one point, because names and positions change for different
build types and I do not want to copy&paste the IF/THEN code needed
here to all locations where I want to link against 'xxx'.)

What am I doing wrong here?  Is this supposed to work, or did I just
use the wrong mechanism?

Any help is reaaallllyy appreciated! :)
bye

   Pentasopor

_______________________________________________
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


This email was sent to you by Thomson Reuters, the global news and information company.
Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.




More information about the CMake mailing list