<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 5, 2019 at 12:59 AM Alexander <<a href="mailto:alexander.samoylov@gmail.com">alexander.samoylov@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear Cristian,</div><div><br></div><div>It would better for me not modifying CMakeFiles.txt, because as I wrote it is 3rd party stuff (we just download it and build, but some different way).</div><div></div><div>My concern is why the command line option -DCMAKE_SHARED_LINKER_FLAGS deliberately ignores /DEF: option. It this behavior expected? What is the logic behind this behavior? Why not simply allow /DEF in CMAKE_SHARED_LINKER_FLAGS and not cut it?</div></div></blockquote><div><br></div><div><br></div><div>You don't have to modify the third party <font face="monospace">CMakeLists.txt</font> file to achieve what Cristian suggested. You can call <font face="monospace">target_sources()</font> on the third party target from your own <font face="monospace">CMakeLists.txt</font> file to add <font face="monospace">.def</font> files to their target. You don't have to be in the same directory scope as the target to use <font face="monospace">target_sources()</font> on it.</div><div><br></div><div>I'm not familiar with why CMake is stripping out the /DEF: option in your case, but I suspect it would be related to the way CMake expects to add such options based on .def files given as sources.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>On Fri, 4 Oct 2019 at 16:54, Cristian Adam <<a href="mailto:cristian.adam@gmail.com" target="_blank">cristian.adam@gmail.com</a>> wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>You should simply add the <span style="white-space:pre-wrap"><font face="monospace">my_defs.def</font> file as a source files to <font face="monospace">add_library/add_executable</font>. </span></div><div><span style="white-space:pre-wrap">CMake will automagically pass<font face="monospace"> /DEF</font>: to the linker with </span><font face="monospace">my_defs.def</font></div><div><br></div><div>Cheers,</div><div>Cristian. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 4, 2019 at 4:45 PM Alexander <<a href="mailto:alexander.samoylov@gmail.com" target="_blank">alexander.samoylov@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<br><br>I would like to add an extra .defs file for linking of a DLL on 
Windows. I want to use the CMake command line option 
-DCMAKE_SHARED_LINKER_FLAGS="/DEF:my_defs.defs". I expect that besides 
the automatically generated <project_path>/bin/<project>.dir/Release/exports.def i see additionally
/DEF:my_defs.defs
in the resulting linking command, but it does not happen.<br>

<br>

What is especially irritating that CMake deliberately removes namely 
/DEF: from CMAKE_SHARED_LINKER_FLAGS. Any other word combinations (if I 
write  /DEF111:my_defs.def for example) are accepted and I see them the 
linking command.<br>

<br><div>I tried to reach the same goal using a CMakeLists.txt like this:</div><div><pre><code>set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEF:my_defs.def")</code></pre></div>but it did not help - the same way CMake removes my /DEF: option.<br><br>

Could you please open a ticket to fix this behavior to not cut /DEF: option from CMAKE_***_LINKER_FLAGS?<br><div><br>

</div><div>On my opinion CMake should not interpret or modify the content of 
CMAKE_SHARED_LINKER_FLAGS value, but should put it entirely as the user 
specified it. If you have another opinion, please provide any other possibility to pass an arbitrary arguments to the linking command "as is" so that they are not modified.</div><div><br></div>

Any workaround  is highly appreciated (better command-line, because we build 3rd party software and it would not really fine to change CMakeLists.txt)<br><br><div>--</div><div>Best Regards,</div><div>Alexander Samoilov<br></div><div>Build & Integration Engineer<br></div><div>Compart AG, 71034 Böblingen Germany<br></div></div></blockquote></div></blockquote></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div><div><br></div><div>Get the hand-book for every CMake user: <a href="https://crascit.com/professional-cmake/" target="_blank">Professional CMake: A Practical Guide</a><br></div><div>Consulting services (CMake, C++, build/release processes): <a href="https://crascit.com/services" target="_blank">https://crascit.com/services</a></div></div></div></div></div></div></div></div></div></div></div></div>