[CMake] CMAKE_EXE_LINKER_FLAGS for shared libraries?
Robert Dailey
rcdailey at gmail.com
Mon Dec 12 17:39:17 EST 2011
I have attached a small CMake project that reproduces the issue I'm
referring to. Please take a look :)
---------
Robert Dailey
On Mon, Dec 12, 2011 at 4:11 PM, Robert Dailey <rcdailey at gmail.com> wrote:
> I forgot to say that the main issue is that my /NODEFAULTLIB link flag
> isn't showing up in visual studio.
>
> ---------
> Robert Dailey
>
>
>
> On Mon, Dec 12, 2011 at 4:10 PM, Robert Dailey <rcdailey at gmail.com> wrote:
>
>> Another issue...
>>
>> At what point is it most important for the values of
>> CMAKE_SHARED_LINK_FLAGS to exist? I set the value of this variable before
>> my call to add_library(), however after that at some point the flags will
>> get reverted because I'm stepping out of function scope. Does it need to
>> exist up to the end of the current cmake script? My flow is basically this
>> (pseudo call stack):
>>
>> Enter CMakeLists.txt
>> - Call define_project() function (in a separate cmake module)
>> - - Call ignore_libs() function
>> - - - Set CMAKE_SHARED_LINK_FLAGS with PARENT_SCOPE
>> - - Call create_target() function
>> - - - Call add_library() command
>> Leave CMakeLists.txt
>>
>> I've done some testing and I find that before the call to add_library(),
>> my flags are setup properly in the CMAKE_SHARED_LINK_FLAGS variable.
>>
>> ---------
>> Robert Dailey
>>
>>
>>
>> On Mon, Dec 12, 2011 at 2:20 PM, Michael Wild <themiwi at gmail.com> wrote:
>>
>>> 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
>>>
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111212/bfb970fa/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmaketest.zip
Type: application/zip
Size: 1630 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111212/bfb970fa/attachment-0001.zip>
More information about the CMake
mailing list