CMake does not work with MASM (VS 2019)
Just test a simple program:
// foo.c
#include <stdio.h>
int add1(int);
int main(void) {
int a, b;
a = 1;
b = add1(a);
printf("%d+1=%d", a, b);
return 0;
}
; bar.asm
.code
public add1
add1 proc input:dword
mov eax, input
add eax, 1
ret
add1 endp
end
If I do not use cmake, I can just compile it with (invoke vcvars64.bat in advance)
cl /c foo.c /Fofoo.obj
ml64 /c bar.asm /Fobar.obj
link foo.obj bar.obj /OUT:foobar.exe
foobar.exe
add CMakeLists.txt as follows:
cmake_minimum_required(VERSION 3.15)
enable_language(C ASM_MASM)
project(program)
set(SOURCES
foo.c
bar.asm)
add_executable(program ${SOURCES})
running mkdir build; cmake ..; cmake --build .
yields an error
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\BuildCustomizations\masm.targets(70,5): error MSB3721: command“ml64.exe /c /nologo /Zi /Fo"program.dir\Debug\bar.obj" /D"WIN32" /D"_WINDOWS" /D"CMAKE_INTDIR="Debug"" /W3 /errorReport:prompt /Ta"C:\Users\xq114\asm-cmake-test\bar.asm"”has existed with return code 1.
[C:\Users\xq114\asm-cmake-test\build\program.vcxproj]
It seems that cmake is not using the complete path of ml64.exe (as what is used in compiling C and C++)
Additional info: OS: Windows 10 2009 Compiler: Visual Studio 2019 (16.8.1) CMake: 3.18.4