[CMake] how to really change CMake linker

Mark Abraham mark.j.abraham at gmail.com
Tue Aug 12 12:04:14 EDT 2014

Hi David,

Thanks very much for your reply! That was extremely helpful, and will let
several packages document a functional workflow for the future.

On Tue, Aug 12, 2014 at 5:38 AM, David Cole <dlrdave at aol.com> wrote:

> Unless it is overridden somewhere else along the way, the following is
> used to create the link command line for a C++ executable:
>     (found in Modules/CMakeCXXInformation.cmake)
>     endif()
> As you can see, by default, the C++ compiler is used as a front end to
> link C++ executables...
> Similarly for other types of targets, there are
> for other languages, there are CMAKE_${LANG}_CREATE_... variables too.

Ah, that explains one source of confusion. I read CMAKE_CXX_LINK_EXECUTABLE
with LINK as an adjective - specify the executable that does linking -
whereas the above use of CREATE makes clear that the sense of LINK is
intended to be as a verb - specify how to create an executable. The docs
did say that this variable specifies a rule, now that I know what to look
for. :-(

In order to use the linker you want, you would have to define a custom
> CMAKE_CXX_LINK_EXECUTABLE that uses "<CMAKE_LINKER>" in its definition
> of the linker command line.

Right. It's easy to assume that this would be the default behaviour for
constructing linking command lines. It's probably too late to consider a
change, but I hope the original reasoning works well somewhere! :-)


> HTH,
> David C.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140812/0ae323ac/attachment.html>

More information about the CMake mailing list