<div dir="ltr"><div>Well, I have tested this proposal as well and I can confirm that it does not work for me. I have added this code to my CMakeLists.txt:<br></div><div><br></div><div>string(APPEND CMAKE_SHARED_LINKER_FLAGS " -DEF:\"foo_1.def\" -DEF111:\"foo_1.def\"")<br>string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " -DEF:\"foo_2.def\"") # just in order to illustrate that CMAKE_CXX_STANDARD_LIBRARIES works with DEF: option in distinct to CMAKE_SHARED_LINKER_FLAGS<br><br></div><div>As a result I see "-DEF:foo_2.def" (in the middle of the linking command right after the "standard" exports.def) and -DEF111:foo_1.def (at the and of the linking command), however I don't see "-DEF:foo_1.def" and it means it was stripped.<br></div><div>I am not sure that it can be informative, but for the illustration I show the full linking command:</div><div></div><div></div><div><pre id="gmail-out" class="gmail-console-output"><pre>Link:
  C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe /ERRORREPORT:QUEUE /OUT:"E:\workspace\cmake_test_option\tesseract\bin\bin\Release\tesseract41.dll" /INCREMENTAL:NO /NOLOGO Ws2_32.lib "E:\workspace\cmake_test_option\leptonica\bin\src\Release\leptonica-1.78.0.lib" "e:\workspace\cmake_test_option\libjpeg\libjpeg_a.lib" "e:\workspace\cmake_test_option\libpng\lib\libpng16_static.lib" "e:\workspace\cmake_test_option\libtiff\lib\tiff.lib" "e:\workspace\cmake_test_option\zlib\lib\zlibstatic.lib" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib <b>"-DEF:foo_2.def"</b> /DEF:"E:/workspace/cmake_test_option/tesseract/bin/libtesseract.dir/Release/exports.def" /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"E:/workspace/cmake_test_option/tesseract/bin/bin/Release/tesseract41.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"E:/workspace/cmake_test_option/tesseract/bin/Release/tesseract41.lib" /MACHINE:X64  /machine:x64 <b>-DEF111:foo_1.def</b> /DLL libtesseract.dir\Release\libtesseract.res</pre></pre></div><div><br></div><div>It proves what I wanted to say that CMAKE_SHARED_LINKER_FLAGS strips -DEF: option in purpose, in distinct to CMAKE_CXX_STANDARD_LIBRARIES which accepts everything.<br></div><div>For me it looks like a bug or like an undocumented behavior of CMAKE_SHARED_LINKER_FLAGS.</div><div><br></div><div>--</div><div>Best Regards,</div><div>Alexander<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 10 Oct 2019 at 00:29, Brad King <<a href="mailto:brad.king@kitware.com">brad.king@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 10/9/19 6:04 PM, Alexander wrote:<br>
> it deliberately ignores /DEF: which makes impossible to add /DEF: this easy<br>
> (and for me preferable) way.<br>
<br>
The code<br>
<br>
```<br>
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -DEF:\"${CMAKE_CURRENT_SOURCE_DIR}/foo.def\"")<br>
```<br>
<br>
works fine for me.<br>
<br>
So does this:<br>
<br>
<br>
```<br>
target_link_options(mySharedLib PRIVATE "-DEF:${CMAKE_CURRENT_SOURCE_DIR}/foo.def")<br>
```<br>
<br>
-Brad<br>
</blockquote></div>