[CMake] How to change CMake's expected output filename
Trevor Kellaway
tkellaway at asl-vision.co.uk
Sun Oct 17 13:34:10 EDT 2010
Nick,
> I'm using CMake with SDCC. Currently, support for SDCC in CMake does
not also
> include dialects for its various assemblers. So I've created one, for
the
> asx8051 assembler. The problem is that the asx8051 assembler shows
nonstandard
> behavior, and does not let you arbitrarily name the output. Instead,
if you
> compile myfile.a51, it produces myfile.rel. No option to change that.
>
> CMake tells the linker to then look for an output file named
> <source_filename><CMAKE_ASM${ASM_DIALECT}_OUTPUT_EXTENSION>, which
ends up
> looking for myfile.a51.rel. I can add whatever arbitrary extension I
want, but
> I need to strip the .a51 from CMake's expected output filename so it
knows to
> look for myfile.rel. Should I create a custom command which moves
myfile.rel to
> myfile.a51.rel? It seems unnecessarily Byzantine. Is there an easier
way?
I'm sure you've solved this but thought I'd post the elegant answer to
this which I found by looking at the CMake source code as I had the same
issue for a compiler which doesn't have a "-o" option, so has no way of
changing the generated object filename (you can change the output
directory).
CMake >V2.4 changed to the new "file.c.obj" naming format, but you can
override this on a per language basis by setting this style variable:
CMAKE_<lang>_OUTPUT_EXTENSION_REPLACE
E.g. for C,
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
This will restore the original "file.obj" behaviour.
This also works for assembler modules, just replace "<lang>" with
"ASM_MINE" where "_MINE" is the ASM dialect.
-TrevK
More information about the CMake
mailing list