[CMake] strange behaviour of TARGET_LINK_LIBRARIES debug/optimized on MacOS

Clemens Arth clemens.arth at gmx.at
Wed Dec 10 09:03:52 EST 2008


Clemens Arth wrote:
> Hi, 
>
> -------- Original-Nachricht --------
>   
>> Datum: Wed, 10 Dec 2008 13:45:05 +0100
>> Von: Hendrik Sattler <post at hendrik-sattler.de>
>> An: cmake at cmake.org
>> Betreff: Re: [CMake] strange behaviour of TARGET_LINK_LIBRARIES	debug/optimized on MacOS
>>     
>
>   
>> Am Wednesday 10 December 2008 13:23:04 schrieb Clemens Arth:
>>     
>>> Clemens Arth wrote:
>>>       
>>>> before I submit a bug report I wanted to ask you about some strange
>>>> behaviour of TARGET_LINK_LIBRARIES on MacOS 10.5 and CMake 2.6-2;
>>>>
>>>> A library is created for debug and release, named libFooD.dylib and
>>>> libFoo.dylib respectively. This works well. Then I create another
>>>> library in the following way:
>>>>
>>>> link_directories(${FooDir}/build/OSX)
>>>> add_library(Bar ${BarSources})
>>>> set_target_properties(Bar PROPERTIES
>>>>  DEBUG_OUTPUT_NAME BarD
>>>>  RELEASE_OUTPUT_NAME Bar
>>>> )
>>>>         
>> You make your life hard, see property DEBUG_POSTFIX
>>
>>     
>
> well, that DEBUG_POSTFIX will make surely make things more readable....
>
>   
>>>> It is necessary to link foo to bar, which I thought should with either
>>>> of the following ways:
>>>>
>>>> TARGET_LINK_LIBRARIES(Bar Foo)
>>>>
>>>> As expected, this only works for Release and not for Debug due to the
>>>> appended "D" for the debug library. Changing Foo to FooD works only
>>>> for debug, not for release.
>>>> However that's the expected behaviour, but then I've tried the
>>>>         
>> following:
>>     
>>>> TARGET_LINK_LIBRARIES(Bar debug FooD optimized Foo)
>>>>         
>> Is Foo created using add_library()?
>>     
>
> yes it is built as a shared lib but in another project, so I have to include the output location in LINK_DIRECTORIES... 
>
>
>   
Well, maybe previously I did not describe the problem in a good way. I 
played around a bit and now it works but for one library only.
If I use only one library (Foo and FooD respectively) to link to Bar (as 
indicated above) it works; if I use two libraries and do it like that,

TARGET_LINK_LIBRARIES(Toe debug BarD FooD optimized Bar Foo)

it does not work, giving me the errors already described above. BUT! If 
I do it like that

TARGET_LINK_LIBRARIES(Toe debug BarD debug FooD optimized Bar optimized 
Foo)

it works - I'm pretty sure this is not the usual way to do it. Whatever 
I tried, using quotation marks, colons or semicolons to indicate a list 
of libraries does not work...





More information about the CMake mailing list