[CMake] nasm and cmake
Brad King
brad.king at kitware.com
Wed Nov 16 11:31:44 EST 2005
Prakash Punnoor wrote:
> could someone be so nice and give an example of how to get nasm files
> compiled and linked to c objects? I searched the list and found two
> short threads not actually solving this. Some sort of instructions were
> given, but no concrete example - and till now I failed to get it running
> using latest cmake in linux.
This should work in CMake 2.0:
---------------------------------------------------------
PROJECT(FOO C)
FIND_PROGRAM(NASM_EXECUTABLE nasm)
SET(ASM_OBJECTS)
FOREACH(src myasm1 myasm2)
SET(ASM_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/${src}.asm)
SET(ASM_OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${src}.o)
SET(ASM_OBJECTS ${ASM_OBJECTS} ${ASM_OBJECT})
ADD_CUSTOM_COMMAND(
OUTPUT ${ASM_OBJECT}
COMMAND ${NASM_EXECUTABLE}
ARGS -o ${ASM_OBJECT} ${ASM_SOURCE}
DEPENDS ${ASM_SOURCE}
)
ENDFOREACH(src)
ADD_EXECUTABLE(bar bar.c ${ASM_OBJECTS})
---------------------------------------------------------
...but it looks like there is a bug in CMake 2.2 that prevents it from
working. I'll get this fixed for the next patch release.
> Why can't cmake just have the possibility
> to define a rule for a certain extension? As far as I understood for the
> custom command you have to add every source file, which isn't very
> convenient.
CMake 2.2 supports custom language definitions, so you might be able to
define an "ASM" language. Unfortunately this support is new and not yet
documented. Look in the CMake/Modules directory for
CMakeCXXInformation.cmake and similar files. If you create your own
CMakeASMInformation.cmake and related files and put them somewhere in
CMAKE_MODULE_PATH then you can define your own language. Then just do
PROJECT(my_c_and_asm_project C ASM)
and the support for the ASM language will be loaded. Then you could
just include .asm sources as any other. I have not tried doing this though.
-Brad
More information about the CMake
mailing list