Compiling ASM source does not work with Visual Studio compiler, VS project or NMake
This code:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(TestAsm C ASM)
file(WRITE ${CMAKE_BINARY_DIR}/test.s "; Test ASM file\n")
file(WRITE ${CMAKE_BINARY_DIR}/main.c "// Main\nint main(int argc, char* argv[])\n{}\n")
add_executable(myprog test.s main.c)
results in this with the VS10 generator (VS12):
<ItemGroup>
<None Include="C:\TEMP\test\cmake_multi\VS12\test.s" />
<ClCompile Include="C:\TEMP\test\cmake_multi\VS12\main.c" />
</ItemGroup>
The VS project lists test.s as "no action" for compiling, rather than assembling with MASM.
When using NMake (using a VS15 command shell), the build prints out:
[ 33%] Building ASM object CMakeFiles/myprog.dir/test.s.obj
Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26730 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9024 : unrecognized source file type 'C:\TEMP\test\cmake_multi\NMake15\test.s', object file assumed
cl : Command line warning D9027 : source file 'C:\TEMP\test\cmake_multi\NMake15\test.s' ignored
cl : Command line warning D9021 : no action performed
[ 66%] Building C object CMakeFiles/myprog.dir/main.c.obj
main.c
It appears to be trying to compile test.s with cl.exe and failing. VS will use ml.exe as the assember, or for WindowsCE (WEC2013) targeting ARM, it will use armasm.exe. So... CMake is not detecting and using these assemblers?
This was using cmake 3.13.0-rc1 on Win10/x64.
Edited by Wil Stark