[CMake] Add linker command file to object files

Michael Hertling mhertling at online.de
Sun Jul 24 21:42:24 EDT 2011


On 07/20/2011 02:19 PM, Florian Reinhard wrote:
> Hi Michael,
> 
> Thank you for that long and well explained resonse!
> 
> I just gave your EXTERNAL_OBJECT approach with a patched cmake version a try.
> 
> Unfortunately this is just almost a solution. That way the linker.cmd
> appears in the list of files that are fed to the linker, but it
> doesn't keep the same order as specified in ADD_EXECUTABLE. External
> objects are being appended to the list of object files which doesn't
> help in that place. I manually edited the resulting makefile and added
> the .cmd file to the object file list in the right place and ran make.
> That way the build was completed successfully.
> 
> So i guess the only way to have the .cmd file appear in the list of
> objects in the same place where it is in the list of source files is
> to fiddle with the CMAKE_<LANG>_IGNORE_EXTENSIONS.

Alternatively, if you get along with Makefiles, you might use one of
the RULE_LAUNCH_LINK properties in connection with a shell script or
the like. In this way, you will have last-minute access to the whole
linker command line and can place the linker command file wherever
you want. To establish a dependency of the affected targets on the
linker command file, you might use the LINK_DEPENDS target property.
IMO, that's a quite elegant solution for your concern; see [1] for
an example how to intercept the linker command by a launch script.

However, I'm still of the opinion that the EXTERNAL_OBJECT property is
*not* handled correctly: It should definitely take precedence over the
examination of the respective file's extension in order that the file
gets included in the linker command regardless whether its extension
is designated to be ignored. This is also what one would expect due
to the documentation. CMake developers, what do you say?

Regards,

Michael

[1] http://www.mail-archive.com/cmake@cmake.org/msg37131.html


More information about the CMake mailing list