Error creating static library from asm on Windows with Ninja generator
When building a project that creates a static library from asm on Windows with the Ninja generator I get this error:
cmd.exe /C "cd . && "" cr third_party\boost_context\boost_context.lib /machine:x64 third_party\boost_context\CMakeFiles\boost_context.dir\asm\jump_x86_64_ms_pe_masm.asm.obj third_party\boost_context\CMakeFiles\boost_context.dir\asm\make_x86_64_ms_pe_masm.asm.obj && cd ."
'""' is not recognized as an internal or external command,
operable program or batch file.
This happens from VS 2017 and VS 2019 (from the IDE itself and the developer command prompt) when using the Ninja generator. It works fine with the VS generators.
The issue seems to be the archiver is not set properly. I was able to work around the issue by manually specifying CMAKE_AR
(to lib.exe
) and CMAKE_MASM_CREATE_STATIC_LIBRARY
(since CMake seems to assume ar
syntax and passes "cr" as a flag, which lib.exe
doesn't understand). Is this the correct way to fix this?
The original issue is on Developer Community. The project used to repro can be found at https://github.com/RichieSams/FiberTaskingLib (the particular add_library call is located under third_party/boost_context/CMakeLists.txt).