[CMake] masm & msvc

Micha Renner Micha.Renner at t-online.de
Mon Aug 15 08:19:32 EDT 2011


This script...

# Copy & paste from CMake Wiki
# Works only if CMake runs in the Visual Studio DOS Window 
SET(MASMFound FALSE)
# test whether it is a x86 machine and masm is available
IF("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86")
	ENABLE_LANGUAGE(ASM_MASM)
	IF(CMAKE_ASM_MASM_COMPILER_WORKS)
		SET(MASMFound TRUE)
	ENDIF(CMAKE_ASM_MASM_COMPILER_WORKS)
ENDIF("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86")
# no assembler found
IF(NOT MASMFound)
	MESSAGE(STATUS NOT)
ENDIF(NOT MASMFound)

...generates still the message:
The ASM_MASM compiler identification is unknown <----------------------!
Found assembler: C:/Program Files/Microsoft Visual Studio
10.0/VC/bin/ml.exe

---------------------------------------------
# cAsm.asm is the main program
ADD_EXECUTABLE(tt cAsm.asm)

In Visual Studio the masm starts, but generates these nice messages:
3>MASM : warning A4018: invalid command-line option : /STACK:10000000
3>MASM : warning A4018: invalid command-line option : /SACK:10000000
3>MASM : warning A4018: invalid command-line option : /SCK:10000000
3>MASM : warning A4018: invalid command-line option : /SK:10000000
3>MASM : warning A4018: invalid command-line option : /S:10000000
3>MASM : warning A4018: invalid command-line option : /S10000000
3>MASM : warning A4018: invalid command-line option : /S0000000
3>MASM : warning A4018: invalid command-line option : /S000000
3>MASM : warning A4018: invalid command-line option : /S00000
3>MASM : warning A4018: invalid command-line option : /S0000
3>MASM : warning A4018: invalid command-line option : /S000
3>MASM : warning A4018: invalid command-line option : /S00
3>MASM : warning A4018: invalid command-line option : /S0
3>  Microsoft (R) Macro Assembler Version 10.00.30319.01
3>  Copyright (C) Microsoft Corporation.  All rights reserved.
3>  
3>MASM : warning A4018: invalid command-line option : /machine:X86
3>MASM : warning A4018: invalid command-line option : /debug
3>MASM : warning A4018: invalid command-line option : /subsystem:console
3>MASM : warning A4018: invalid command-line option : -o
3>   Assembling: tt.exe
3>MASM : fatal error A1000: cannot open file : tt.exe

# ----------------------------------------------
ADD_EXECUTABLE(tt cTest.c cAsm2.asm)
main in cTest.c. cAsm2.asm has a function only.
Visual Studio does not start the masm. A right click on cAsm2.asm in the
project explorer => properties
says: element type: Not part of the build.

# ----------------------------------------------
The only way to use the masm seems to be:
ADD_CUSTOM_COMMAND(OUTPUT cAsm2.obj
	COMMAND ${CMAKE_ASM_MASM_COMPILER} -c
${CMAKE_CURRENT_SOURCE_DIR}/cAsm2.asm
	DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cAsm2.asm
	COMMENT "generate cAsm2.obj") 

ADD_EXECUTABLE(cTest CTest.c cAsm2.obj)

Greetings

Micha





More information about the CMake mailing list