Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake uses NASM for linking, which fails.

Tags:

cmake

nasm

I have an assembler file I want to compile in one run. However, the following code fails:

enable_language(ASM_NASM)
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -f bin")
add_executable(test test.s)

CMake first runs: nasm -f bin -o test.s.o test.s
And then: nasm -f bin -o test test.s.o
The last step fails as test.s.o is already a binary file.

My question is: How do I disable the first compilation step?

like image 249
ababababanababab Avatar asked Jan 30 '15 17:01

ababababanababab


1 Answers

There seems to be a bug in nasm module for cmake. Cmake calls nasm for linking which is obviously wrong (that is why you see two calls to nasm). Hotfix is to set

set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld <FLAGS> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET> <LINK_LIBRARIES>")
like image 157
triacontahedron Avatar answered Sep 20 '22 13:09

triacontahedron