Thanks for the info. It's a bit disappointing that it doesn't work like I expect. The CMAKE_MFC_FLAG should work as you say the link flags should, but it does not. As long as CMAKE_MFC_FLAG is set before I create my target, it works. Since CMAKE_SHARED_LINK_FLAGS does not work the same, I consider this a bug. There is no reason for it to exist up to the end of the file... it should only exist up to the call to create the target. For example, if I want to have 2 calls to add_library() in the same file, but specify link flags differently for each, how am I expected to do this without using the target specific property?<br clear="all">
<div><br></div><div>---------</div>Robert Dailey<br>
<br><br><div class="gmail_quote">On Mon, Dec 12, 2011 at 11:26 PM, Michael Wild <span dir="ltr"><<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It needs to exist **at the end** of the CMakeLists.txt file containing<br>
the target. If you don't want to do that (or can't, as in your case),<br>
you can use the LINK_FLAGS target property instead.<br>
<br>
HTH<br>
<br>
Michael<br>
<div class="im"><br>
On 12/12/2011 11:39 PM, Robert Dailey wrote:<br>
> I have attached a small CMake project that reproduces the issue I'm<br>
> referring to. Please take a look :)<br>
><br>
> ---------<br>
> Robert Dailey<br>
><br>
><br>
> On Mon, Dec 12, 2011 at 4:11 PM, Robert Dailey <<a href="mailto:rcdailey@gmail.com">rcdailey@gmail.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:rcdailey@gmail.com">rcdailey@gmail.com</a>>> wrote:<br>
><br>
> I forgot to say that the main issue is that my /NODEFAULTLIB link<br>
> flag isn't showing up in visual studio.<br>
><br>
> ---------<br>
> Robert Dailey<br>
><br>
><br>
><br>
> On Mon, Dec 12, 2011 at 4:10 PM, Robert Dailey <<a href="mailto:rcdailey@gmail.com">rcdailey@gmail.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:rcdailey@gmail.com">rcdailey@gmail.com</a>>> wrote:<br>
><br>
> Another issue...<br>
><br>
> At what point is it most important for the values of<br>
> CMAKE_SHARED_LINK_FLAGS to exist? I set the value of this<br>
> variable before my call to add_library(), however after that at<br>
> some point the flags will get reverted because I'm stepping out<br>
> of function scope. Does it need to exist up to the end of the<br>
> current cmake script? My flow is basically this (pseudo call stack):<br>
><br>
> Enter CMakeLists.txt<br>
> - Call define_project() function (in a separate cmake module)<br>
> - - Call ignore_libs() function<br>
> - - - Set CMAKE_SHARED_LINK_FLAGS with PARENT_SCOPE<br>
> - - Call create_target() function<br>
> - - - Call add_library() command<br>
> Leave CMakeLists.txt<br>
><br>
> I've done some testing and I find that before the call to<br>
> add_library(), my flags are setup properly in the<br>
> CMAKE_SHARED_LINK_FLAGS variable.<br>
><br>
> ---------<br>
> Robert Dailey<br>
><br>
><br>
><br>
> On Mon, Dec 12, 2011 at 2:20 PM, Michael Wild <<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>>> wrote:<br>
><br>
> On 12/12/2011 09:13 PM, Robert Dailey wrote:<br>
> > On Mon, Dec 12, 2011 at 2:10 PM, David Cole<br>
> <<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a> <mailto:<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>><br>
</div>> > <mailto:<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a><br>
<div><div class="h5">> <mailto:<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>>>> wrote:<br>
> ><br>
> > Apparently, they are undocumented, but there are also:<br>
> ><br>
> > CMAKE_SHARED_LINKER_FLAGS and<br>
> CMAKE_MODULE_LINKER_FLAGS (and their<br>
> > per-config variants) for SHARED and MODULE library<br>
> targets as well.<br>
> ><br>
> > Use CMAKE_SHARED_LINKER_FLAGS instead.<br>
> ><br>
> ><br>
> > Thanks for the information guys. I'm having a minor<br>
> problem with these<br>
> > variables though.<br>
> ><br>
> > Here is how I use it:<br>
> ><br>
> > set( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}<br>
> > /NODEFAULTLIB:\"${lib}\" )<br>
> ><br>
> > Prior to calling the set above, the shared linker flags<br>
> look like this:<br>
> ><br>
> > /STACK:10000000 /machine:X86<br>
> ><br>
> > After calling the set above, it looks like this:<br>
> ><br>
> > /STACK:10000000 /machine:X86 ;/NODEFAULTLIB:"LIBC"<br>
> ><br>
> > For some reason a semi-colon is being inserted prior to the<br>
> > /NODEFAULTLIB part. I don't know why this is happening but<br>
> visual studio<br>
> > is complaining about it. Any reason why this is happening?<br>
> Thanks.<br>
> ><br>
><br>
> That's how CMake works.<br>
><br>
> set(VAR val1 val2 val3)<br>
><br>
> defines a *list* where the elements are separated by a<br>
> semi-colon (;).<br>
> To prevent that, quote the assignment:<br>
><br>
> set(VAR "val1 val2 val3")<br>
><br>
><br>
> Michael<br>
><br>
> --<br>
><br>
</div></div>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> <<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<div class="HOEnZb"><div class="h5">><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the CMake FAQ at:<br>
> <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br>