[CMake] TARGET_LINK_LIBRARIES debug optimized visual studio 2010

Michael Hertling mhertling at online.de
Fri Jul 29 18:10:42 EDT 2011


On 07/30/2011 12:06 AM, Michael Hertling wrote:
> On 07/29/2011 06:22 PM, Louis Hoefler wrote:
>> I tried that and now I get
>> for the debug libraries:
>> ...;wtdwthttpd.lib;...
>> for the release libraries:
>> ...;wtwthttp.lib;...
>>
>> I want it to look like
>> ...;wt.lib;wthttp.lib;... or ...;wtd.lib;wthttpd.lib;...
>> my version somehow adds one release
>> library to the debug configuration and
>> vice versa (...;wthttpd.lib;wt.lib;wthttp.lib;...).
>>
>> Sorry for not mentioning this.
>> Thank you, Louis
>>
>> Am 29.07.2011 18:12, schrieb David Cole:
>>> Don't put a space in between the "wt" and the "${BACKENDLIB}" ... ?
>>>
>>> Use this instead:
>>>
>>> IF(WIN32)
>>>   TARGET_LINK_LIBRARIES(construction.wt
>>>    debug wtd${BACKENDLIB}d
>>>    optimized wt${BACKENDLIB})
>>> ELSE(WIN32)
>>>   TARGET_LINK_LIBRARIES(construction.wt wt${BACKENDLIB})
>>> ENDIF(WIN32)
>>>
>>> Just a guess since I don't really know what you're expecting...
>>>
>>>
>>> On Fri, Jul 29, 2011 at 12:02 PM, Louis Hoefler<louis.hoefler at gmx.de>  wrote:
>>>> Hello everyone.
>>>> I try to set a specific library for the debug and release configuration.
>>>>
>>>> I try to do it this way:
>>>> IF(DEFINED USEFCGI)
>>>>   SET(BACKENDLIB wtfcgi)
>>>> ELSE(DEFINED USEFCGI)
>>>>   SET(BACKENDLIB wthttp)
>>>> ENDIF(DEFINED USEFCGI)
>>>>
>>>> IF(WIN32)
>>>>   TARGET_LINK_LIBRARIES(construction.wt
>>>>   debug wtd ${BACKENDLIB}d
>>>>   optimized wt ${BACKENDLIB})
>>>> ELSE(WIN32)
>>>>   TARGET_LINK_LIBRARIES(construction.wt wt ${BACKENDLIB})
>>>> ENDIF(WIN32)
> 
> TARGET_LINK_LIBRARIES()'s debug/optimized/general keywords apply to
> their following argument only: 'A "debug", "optimized", or "general"
> keyword indicates that the library immediately following it is to be
> used only for the corresponding build configuration.' [Documentation
> of TARGET_LINK_LIBRARIES()]. So, your use of TARGET_LINK_LIBRARIES()
> yields exactly what's expected/documented. Instead, it should read:
> 
> TARGET_LINK_LIBRARIES(construction.wt
>     debug wtd debug ${BACKENDLIB}d
>     optimized wt optimized ${BACKENDLIB})
> 
> However, you should definitely prefer the more powerful approach of
> imported targets that is mainly intended for such linking concerns:
> 
> ADD_LIBRARY(wt SHARED IMPORTED)
> ADD_LIBRARY(backendlib SHARED IMPORTED)
> SET_TARGET_PROPERTIES(wt PROPERTIES
>     IMPORTED_LOCATION_DEBUG "wtd"
>     IMPORTED_LOCATION "wt")
> SET_TARGET_PROPERTIES(backendlib PROPERTIES
>     IMPORTED_LOCATION_DEBUG "${BACKENDLIB}d"
>     IMPORTED_LOCATION "${BACKEND}")

Oops, IMPORTED_LOCATION "${BACKENDLIB}", of course.
                                  ^^^
> TARGET_LINK_LIBRARIES(construction.wt wt backendlib)
> 
> Regards,
> 
> Michael


More information about the CMake mailing list