[CMake] CMAKE_EXE_LINKER_FLAGS for shared libraries?

Michael Wild themiwi at gmail.com
Mon Dec 12 15:20:59 EST 2011


On 12/12/2011 09:13 PM, Robert Dailey wrote:
> On Mon, Dec 12, 2011 at 2:10 PM, David Cole <david.cole at kitware.com
> <mailto:david.cole at kitware.com>> wrote:
> 
>     Apparently, they are undocumented, but there are also:
> 
>     CMAKE_SHARED_LINKER_FLAGS and CMAKE_MODULE_LINKER_FLAGS (and their
>     per-config variants) for SHARED and MODULE library targets as well.
> 
>     Use CMAKE_SHARED_LINKER_FLAGS instead.
> 
> 
> Thanks for the information guys. I'm having a minor problem with these
> variables though.
> 
> Here is how I use it:
> 
> set( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
> /NODEFAULTLIB:\"${lib}\" )
> 
> Prior to calling the set above, the shared linker flags look like this:
> 
>  /STACK:10000000 /machine:X86
>  
> After calling the set above, it looks like this:
> 
>   /STACK:10000000 /machine:X86 ;/NODEFAULTLIB:"LIBC"
> 
> For some reason a semi-colon is being inserted prior to the
> /NODEFAULTLIB part. I don't know why this is happening but visual studio
> is complaining about it. Any reason why this is happening? Thanks.
> 

That's how CMake works.

set(VAR val1 val2 val3)

defines a *list* where the elements are separated by a semi-colon (;).
To prevent that, quote the assignment:

set(VAR "val1 val2 val3")


Michael



More information about the CMake mailing list