in our project we have the need to run a custom linker tool. This custom linker tool is supposed to be used for only some targets (some shared libs will be linked the normal way), not all. I have successfully registered the custom linker via setting CMAKE_CXX_USING_LINKER_customlinker and I also were able to set the LINKER_TYPE property on the target. How can I tell CMake that only for this custom linker, CMAKE_CXX_USING_LINKER_MODE is supposed to be TOOL instead of FLAGS? There are no CMAKE_<lang>_USING_LINKER_MODE_<custom linker>
properties, right?
For now, you cannot specify MODE per target because using the compiler as driver or directly the linker for the link step is defined using some global variables (like CMAKE__CREATE_SHARED_LIBRARY, etc…).
The idea regarding LINKER_TYPE
is that the compiler is aware of the linker and so, is able to manage softly the selection of the specified linker.
The case of a linker which cannot be used in coordination with the compiler is not supported.
In your case, may be the <LANG>_LINKER_LAUNCHER target property is more adequate to your needs.
ah, thank you Marc. I gave it a try and yes, now I get my tool invoked. What is just now missing is the ability to pass additional tool options before the line that CMake passes into the linker wrapper. Can I do this without writing my own tool wrapper script? I would need a call to myTool -prefixoption /path/to/g++ (etc)
instead of myTool /path/to/g++ (etc)
in fact, best would be if I could stitch the whole command line manually together
<LANG>_LINKER_LAUNCHER
is a semicolon separated list, so I think you can have:
set_property(TARGET mytarget PROPERTY CXX_LINKER_LAUNCHER myTool -prefixoption)
wow, thank you Marc, you are my hero!