[CMake] CMake removes /DEF: option in CMAKE_SHARED_LINKER_FLAGS

Alexander alexander.samoylov at gmail.com
Fri Oct 4 10:45:22 EDT 2019


Hello,

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.

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.

I tried to reach the same goal using a CMakeLists.txt like this:

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEF:my_defs.def")

but it did not help - the same way CMake removes my /DEF: option.

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

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.

Any workaround is highly appreciated (better command-line, because we build
3rd party software and it would not really fine to change CMakeLists.txt)

--
Best Regards,
Alexander Samoilov
Build & Integration Engineer
Compart AG, 71034 Böblingen Germany
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191004/fb613b0b/attachment.html>


More information about the CMake mailing list