Adding support for VASM
Hi,
I'm part of AmigaPorts group, which maintains development tools for Amiga, including Amiga-specific CMake toolchain files. Over at AmigaCMakeCrossToolchains we've set up the config for using VASM 68k assembler to support this compiler, but it's far from optimal that each user has to do some manual steps to have it recognized by CMake.
Inside the docs there's following bit:
We would be happy about patches which add support for nasm, yasm, tasm, etc.
So I'd like to tackle this to simplify stuff for our users, but... it gets hairy.
VASM is multi-platform compiler, and there are different flavors of it: it can generate 68k, PowerPC and other code depending on executable (similarly to how GCC is compiled for each platform separately, but here each executable has explicitly different name, e.g. vasmm68k_mot for m68k & Motorola syntax, vasmppc_std, etc.), as well as file formats (ELF objects, Amiga hunk objects, etc.) depending on parameters.
Assuming we'd add patch for vasmm68k_mot (motorola 68k variant), it'd have a line similar to this:
SET(CMAKE_ASM_VASM_SOURCE_FILE_EXTENSIONS vasm;asm)
so, from my understanding it would create a conflict with any other assembler using .asm
executable and perhaps also with any other vasm flavor added to CMake on .vasm
extension?
Also, the other thing worth mentioning is that typical extension for asm files are .asm
and .s
, and people tend to use those for their default assembler. This also comes in the way when dual-assembler configuration is to be used. In my project's case, .s files are used for GNU assembler and .asm or .vasm are used for VASM. Perhaps this could/should be configurable in some way.
So where should we go from here?
One option is to use project()
directive to declare which specific asms are to be used - this would require removing ASM option and replace it with NASM/TASM/GAS/VASM_M68K etc, but I guess being backwards-compatible is very important for CMake. Also this makes using different assemblers for multiplatform projects problematic, 'cuz it requires some scripting before project()
command is called.
Another option would be adding means to enable specific assemblers and bind extensions to them on a per-project manner:
- assuming user only specifies
project(myProject LANGUAGES C CXX ASM)
, it falls back to compiler suite's default assembler (etc GAS for GCC), or whatever the current behavior is. - calling brand-new
enable_assembler(VASM_M68K vasm asm s)
command somewhere afterproject(... ASM)
could allow enabling specific assemblers for projects, but that requires some more CMake development. Also, this should allow influencing assembler's command-line args to e.g. accomodate for linkers which expects given .o file format (under Amiga, it's either ELF or Amiga hunk) - being able to properly run
CMakeASM_VASMInformation
,CMakeDetermineASM_VASMCompiler
andCMakeTestASM_VASMCompiler
on a per-project basis from toolchain file would be helpful. Being able to include custom CMake modules without copying it into its own directory would simplify things for our users, but it doesn't solve the desire to bundle such configs with CMake as wiki documentation suggests.
Or perhaps there's some kind of other solution, which eludes me due to my very fragmented CMake knowledge.
Thoughts?