Rakete1111
Rakete1111

Reputation: 48948

CMake fails with "did not find file compiler/msvc-asm" even though it exists

I'm trying to generate Visual Studio project files with CMake. I'm executing the following command in the Visual Studio 2017 Developer Command Prompt:

cmake -G "Visual Studio 15 2017 Win64" -Thost=x64 ../project

Everything is found correctly except the ASM compiler (which should be cl.exe which comes with Visual Studio). I find this weird because the C++ compiler, which is the exact same file, has been found!

For reference, I'm seeing this line in the log:

Warning: Did not find file Compiler/MSVC-ASM

Any ideas?

Upvotes: 4

Views: 5551

Answers (4)

valiano
valiano

Reputation: 18551

It turns out MSVC-ASM is the name of an actual CMake module.
I'm using CMake 3.8.2, and in my case it was indeed missing!

MSVC-ASM.cmake a placeholder for settings to be used for the Visual Studio assembler. It may be just an empty file:
https://github.com/Kitware/CMake/blob/master/Modules/Compiler/MSVC-ASM.cmake

I was able to track it down using CMake's --trace option. It's being included by another file, CMakeASMInformation.cmake, and if not found, that warning is printed:

# Load compiler-specific information.
set(_INCLUDED_FILE "")
if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
  include(Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL  RESULT_VARIABLE _INCLUDED_FILE)
endif()
if(NOT _INCLUDED_FILE)
  if("ASM${ASM_DIALECT}" STREQUAL "ASM")
    message(STATUS "Warning: Did not find file Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}")
  endif()
  include(Platform/${CMAKE_BASE_NAME} OPTIONAL)
endif()

Solution: created an empty MSVC-ASM.cmake under c:\Program Files\CMake\share\cmake-3.8\Modules\Compiler, and viola, the warning was gone.

Upvotes: 1

Mika Lindqvist
Mika Lindqvist

Reputation: 80

You have too old version of CMake... The required file was missing in older versions...

Upvotes: -1

Marco Martins
Marco Martins

Reputation: 155

I had the same issue on VS2013 and solved it by using enable_language(ASM_MASM) instead of enable_language(ASM) and forcing the inclusion of the assembly code file with set_property(SOURCE <file>.S PROPERTY LANGUAGE ASM_MASM) otherwise the file would not participate in the build.

Upvotes: 5

Rakete1111
Rakete1111

Reputation: 48948

I don't exactly know why this happens, but it looks like the developer command prompt messes up something which CMake uses to find the ASM compiler.

This worked for me:

  1. Make sure that cl.exe is in your PATH (and any other relevant file which your project uses).

  2. Execute the command in the regular command prompt (or the Native Tools one).

Upvotes: 1

Related Questions