James Mansion wrote:
I'd like to create a library from a mix of
assembler and C files.
I'm reading the book to try to determine how
to achieve this. There seems to be perhaps two
possible approaches.
(Initially this is for Win32, and I have files for NASM
and MASM with extensions .nasm and .masm)
1) define new languages for NASM and MASM.
The example in the book (Fortran) suggests that I then need to
enable the language in the PROJECT declaration, though the
section on PROJECT suggests that all languages are enabled
by default. (?) Presumably I'm safe if I use ENABLE_LANGUAGE?
Then I would just use ADD_LIBRARY (foo a.c b.nasm c.masm).
Is that right?
This is mostly right, but currently there is no NASM or MASM language.
You have to look at all the *Fortran*.cmake files in the Modules
directory. Create similar ones for NASM and MASM in some directory in
your project, say myproj/CMake. Then in myproj/CMakeLists.txt do
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
PROJECT(MYPROJ C NASM MASM)
Note the above is from memory so it may need some tweaking.
2) Define a whole set of custom commands that create an object
file:
SET( MASM_SOURCES b1.masm b2.masm )
FOREACH( SRC ${MASM_SOURCES} )
ADD_CUSTOM_COMMAND(TARGET <obj for ${SRC}>
PRE_LINK
COMMAND masm ${SRC}
)
ENDFOREACH( SRC )
ADD_LIBRARY( foo a.c b1.obj b2.obj )
Is that right?
Try something like
SET(MASM_NAMES b1 b2)
FOREACH(src ${MASM_NAMES})
SET(MASM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${src}.masm)
SET(MASM_OBJ ${CMAKE_CURRENT_BINARY_DIR}/${src}.obj)
ADD_CUSTOM_COMMAND(
OUTPUT ${MASM_OBJ}
DEPENDS ${MASM_SRC}
COMMAND masm ${MASM_SRC} -o${MASM_OBJ}
)
SET(MASM_OBJECTS ${MASM_OBJECTS} ${MASM_OBJ})
ENDFOREACH(src)
ADD_LIBRARY(foo a.c ${MASM_OBJECTS})
-Brad
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake