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:
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -DEF:\"foo_1.def\" -DEF111:\"foo_1.def\"") 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 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. I am not sure that it can be informative, but for the illustration I show the full linking command: 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 *"-DEF:foo_2.def"* /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 *-DEF111:foo_1.def* /DLL libtesseract.dir\Release\libtesseract.res 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. For me it looks like a bug or like an undocumented behavior of CMAKE_SHARED_LINKER_FLAGS. -- Best Regards, Alexander On Thu, 10 Oct 2019 at 00:29, Brad King <brad.k...@kitware.com> wrote: > On 10/9/19 6:04 PM, Alexander wrote: > > it deliberately ignores /DEF: which makes impossible to add /DEF: this > easy > > (and for me preferable) way. > > The code > > ``` > string(APPEND CMAKE_SHARED_LINKER_FLAGS " > -DEF:\"${CMAKE_CURRENT_SOURCE_DIR}/foo.def\"") > ``` > > works fine for me. > > So does this: > > > ``` > target_link_options(mySharedLib PRIVATE > "-DEF:${CMAKE_CURRENT_SOURCE_DIR}/foo.def") > ``` > > -Brad >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake-developers