[CMake] Build/Link with static libs

Christian Lang christian.lang at uni-bielefeld.de
Mon Apr 24 12:19:17 EDT 2006


Alexander Neundorf schrieb:

>>--- Ursprüngliche Nachricht --- 
>>Von: Christian Lang <christian.lang at uni-bielefeld.de> 
>>An: cmake at cmake.org 
>>Betreff: [CMake] Build/Link with static libs 
>>Datum: Tue, 18 Apr 2006 20:54:32 +0200 
>> 
>>Hi, 
>> 
>>I want to link a target (executable) against some static (not 
>>    
>>
>installed)  
>  
>
>>libs (e.g. "./foo.a"). How can I do this? "TARGET_LINK_LIBRARIES" does  
>>not work. I cannot use "CMAKE_EXE_LINKER_FLAGS" either, because the  
>>flags appear before the object files, leading to link failure for  
>>dependency reasons. (The static libs have to appear after the last  
>>object file.) 
>> 
>>Furthermore I want to build some static "noinst" libs in some  
>>subdirectories (each with its own CMakeLists.txt) and link them into an  
>>executable in the toplevel-directory. This executable does not require  
>>any additional source files, it shall be build from this libs only. 
>>    
>>
>What  
>  
>
>>is an appropriate way to achieve this? 
>>    
>>
> 
>AFAIK this should work. How does it fail ? 
> 
>Bye 
>Alex 
> 
>
>  
>
Hi,

my first problem is solved: To link against "foo/libbar.a", the link 
line options "-Lfoo -lbar" are produced. This works. But what if for 
some reason I do not want to use it this way, but want to directly 
specify "foo/libbar.a" at the link line (as I tried in the first place)? 
Is this possible?

Regarding my second problem, I simply do not know how to tell cmake to 
first build the static libs by recursing into the subdirs and then build 
the main target by linking them together (at the top-level-dir)...

Thanks a lot,
Christian



More information about the CMake mailing list