[CMake] assembly files with masm in vs2005 64bit

Alexander Neundorf a.neundorf-work at gmx.net
Fri Oct 24 16:33:32 EDT 2008


On Friday 24 October 2008, Alexander Neundorf wrote:
> On Friday 24 October 2008, Bram de Greve wrote:
> > Hi,
> >
> > I'm trying to build some library with vs2005 64bit using CMake.  This
> > library uses some assembly and as the 64 bit mode of vs2005 doesn't
> > support inline assembly, and external call to MASM is necessary. 
> > However, I'm having troubles getting this working.
> >
> > I've googled on cmake + masm, but that wasn't of much help.
>
> Yes, I think you're the first one who tries that.
>
> > This is the custom build step I need to perform (copy pasted from a
> > handcrafted solution file):
> >
> > ml64 -c -Zi "-Flfoobar.lst" "-FRfoobar.sbr" "-Fofoobar.obj" "foobar.asm"
>
> Are -Fl and -FR necessary or does it also work without them ?
>
> > In my CMakeLists.txt i have something like:
> >
> > enable_language(ASM)
> > set_source_files_property(foobar.asm LANGUAGE ASM)
> >     list(APPEND lass_SRCS ${sourcepath})
> > add_library(mylib foobar.asm ...)
> >
> > The problems I'm facing are:
> > 1. ml64 can't be found as assembler.  Though I can explicitly set its
> > path using the advanced view
> > 2. foobar.asm does not get any custom build step, nor any cmake rule
> >
> > Does you have some advance how to solve this issue, as it is a real
> > showstopper ...
>
> I'll have a look in the next days.

Ok, it was a bit faster (waiting for Qt to build...)

So, please put the three attached files into the cmake Modules/ directory and 
use
ENABLE_LANGUAGE(ASM-MASM)
This should find ml64.exe .
If it doesn't, try hardcoding it for now in 
CMakeDetermineASM-MASMCompiler.cmake. 
Let me know which problems you hit.

Alex
-------------- next part --------------
# determine the compiler to use for ASM using AT&T syntax

SET(ASM_DIALECT "-MASM")
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml64 )
INCLUDE(CMakeDetermineASMCompiler)
SET(ASM_DIALECT)
-------------- next part --------------

# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that that selected ASM-ATT compiler can actually compile
# and link the most basic of programs.   If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
SET(ASM_DIALECT "-MASM")
INCLUDE(CMakeTestASMCompiler)
SET(ASM_DIALECT)
-------------- next part --------------
SET(ASM_DIALECT "-MASM")

SET(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm)

SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> /c  <SOURCE> /Fo <OBJECT>")

INCLUDE(CMakeASMInformation)
SET(ASM_DIALECT)


More information about the CMake mailing list