[CMake] add_library and target_link_libraries indifferentdirectories?

Alexandre Feblot Alexandre.Feblot at thomsonreuters.com
Mon Jan 12 10:42:55 EST 2009


My question is related to my post "Working with repositories":

I want to compile just a part of the project (a few libs and a few
binaries), but when linking binaries, I still need all dependency
informations. I want to get missing libs from a reference build shared
somewhere else.

 

________________________________

From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf
Of David Cole
Sent: Monday, 12 January 2009 16:05
To: Alexandre Feblot
Cc: cmake at cmake.org
Subject: Re: [CMake] add_library and target_link_libraries
indifferentdirectories?

 

Really, the target_link_libraries command for a given lib or exe belongs
in the same CMakeLists.txt file that you call add_library or
add_executable from. What is your reason for wanting to put the list of
dependencies somewhere else?

 

On Mon, Jan 12, 2009 at 9:29 AM, Alexandre Feblot
<Alexandre.Feblot at thomsonreuters.com> wrote:

Hi Andreas,

 

In fact, this is already what I did:

 

Here is a synopsis of my CMakeLists files:

 

ROOT CMakeLists.txt:

-        define some general stuff, options, macros.

-        call add_subdirectory() for all subdirectories

-        *trying* to set link dependencies with target_link_libraries()

 

subdir CMakeLists.txt:

      - defining libs with add_library()

 

Or don't I understand what you mean by " before linking the libs "?

 

 

Alexandre

 

-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf
Of Andreas Pakulat
Sent: Monday, 12 January 2009 14:32
To: cmake at cmake.org
Subject: Re: [CMake] add_library and target_link_libraries in
differentdirectories?

 

On 12.01.09 11:27:28, Alexandre Feblot wrote:

> Hi,

> 

>  

> 

> I have not been able to define a library dependency in a directory

> different from the one in which the library target is created.

> 

> Is this done by design, or is there any way to do it?

> 

>  

> 

> My goal would be to have

> 

> -          each library in it's own directory (and a CMakeLists.txt
file

> with a add_library command)

> 

> -          all dependencies stored in a single file at the root level

> 

 

Then you need to call add_subdirectory() for the library subdirs before

linking the libs. You can't link a target that you havent' defined yet.

 

Andreas

 

-- 

Chicken Little was right.

_______________________________________________

CMake mailing list

CMake at cmake.org

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. 


_______________________________________________
CMake mailing list
CMake at cmake.org
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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090112/e26d09b7/attachment-0001.htm>


More information about the CMake mailing list