# cmake in msvc terminal with yasm not building asm files - works in linux

**URL:** https://discourse.cmake.org/t/cmake-in-msvc-terminal-with-yasm-not-building-asm-files-works-in-linux/6968
**Category:** Usage
**Tags:** os:windows
**Created:** [November 28, 2022, 3:06pm UTC](https://discourse.cmake.org/t/cmake-in-msvc-terminal-with-yasm-not-building-asm-files-works-in-linux/6968 "2022-11-28T15:06:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jbagg](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/f6c823/32.png) [@jbagg](https://discourse.cmake.org/u/jbagg)
#### Post date: [November 28, 2022, 3:06pm UTC](https://discourse.cmake.org/t/cmake-in-msvc-terminal-with-yasm-not-building-asm-files-works-in-linux/6968/1 "2022-11-28T15:06:10Z")

</div>

I am having trouble getting cmake to build asm files on windows in a MSVC 2022 terminal. I am building a shared library that has both asm and c source code. The CMakeList.txt builds both the c and asm objects just fine on linux, but only attempts to build the c sources on windows. I am using yasm for the assembler. yasm is in the path. Is this a bug in cmake or incorrect usage?

```auto
cmake_minimum_required( VERSION 3.18 )
project(libav)
enable_language( C ASM )

set(CMAKE_ASM_COMPILER yasm)
SET(CMAKE_ASM_SOURCE_FILE_EXTENSIONS asm)
SET(CMAKE_ASM_OUTPUT_EXTENSION ".obj" )
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -f win64 -m amd64 -DPIC -D ARCH_X86_64=1 -DARCH_X86_32=0 -DHAVE_CPUNOP=1 -dHAVE_ALIGNED_STACK=1 -DHAVE_AVX_EXTERNAL=1 -DEXTERN_ASM -i ${CMAKE_SOURCE_DIR} -o <OBJECT> <SOURCE>")

set(VERSION 1.0.0)
set(DESCRIPTION "libav fft only")

add_library(libav SHARED libavcodec/avfft.c libavcodec/x86/fft.asm libavutil/x86/cpuid.asm)

set_target_properties(libav PROPERTIES VERSION 1.0.0)
target_include_directories(libav PRIVATE . compat/atomics/win32 ${CMAKE_BINARY_DIR})

file(COPY config.h DESTINATION .)

```

Output of cmake

```auto
c:\Windows\Temp\build>cmake ..\cmake_yasm_win
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.32.31332.0
-- The CXX compiler identification is MSVC 19.32.31332.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Windows/Temp/build

c:\Windows\Temp\build>cmake --build .
Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule C:/Windows/Temp/cmake_yasm_win/CMakeLists.txt
  avfft.c
  libav.vcxproj -> C:\Windows\Temp\build\Debug\libav.dll
  Building Custom Rule C:/Windows/Temp/cmake_yasm_win/CMakeLists.txt

c:\Windows\Temp\build>yasm --version
yasm 1.3.0
Compiled on Aug 17 2014.
Copyright (c) 2001-2014 Peter Johnson and other Yasm developers.
Run yasm --license for licensing overview and summary.

```

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [November 28, 2022, 6:07pm UTC](https://discourse.cmake.org/t/cmake-in-msvc-terminal-with-yasm-not-building-asm-files-works-in-linux/6968/2 "2022-11-28T18:07:48Z")

</div>

Use a different generator, e.g. Ninja. Visual Studio is not usable for your case.

---

<div class="post-metadata">

### Author: ![jbagg](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/f6c823/32.png) [@jbagg](https://discourse.cmake.org/u/jbagg)
#### Post date: [November 28, 2022, 8:20pm UTC](https://discourse.cmake.org/t/cmake-in-msvc-terminal-with-yasm-not-building-asm-files-works-in-linux/6968/3 "2022-11-28T20:20:30Z")

</div>

Thank you. cmake -G Ninja path\_to\_CMakeList.txt does appears to enable the asm file compilation.
