[CMake] CMake removes /DEF: option in CMAKE_SHARED_LINKER_FLAGS

Alexander alexander.samoylov at gmail.com
Fri Oct 4 10:59:34 EDT 2019


Dear Cristian,

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).
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?

--
Best Regards,
Alexander

On Fri, 4 Oct 2019 at 16:54, Cristian Adam <cristian.adam at gmail.com> wrote:

> Hi,
>
> You should simply add the my_defs.def file as a source files to
> add_library/add_executable.
> CMake will automagically pass /DEF: to the linker with my_defs.def
>
> Cheers,
> Cristian.
>
> On Fri, Oct 4, 2019 at 4:45 PM Alexander <alexander.samoylov at gmail.com>
> wrote:
>
>> 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
>> --
>>
>> 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
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20191004/c619ffbf/attachment.html>


More information about the CMake mailing list