[CMake] Projects with C++ and Assembly

Brad King brad.king at kitware.com
Tue Jun 21 10:48:54 EDT 2005


David McKinnon wrote:
> Hi,
>   I have seen some previous posts about integrating assembly files into
> a project. I have implemented something along the lines of the snippet
> below and have successfully created the object files (.obj on Windows).
> 
> FOREACH (SOURCE ${MY_ASM_SRCS})
>     GET_FILENAME_COMPONENT (FILE_BASE ${SOURCE} NAME_WE)
>     ADD_CUSTOM_COMMAND (SOURCE ${SOURCE}
>     SET(OBJ ${CMAKE_CURRENT_BINARY_DIR}/${FILE_BASE}.o)    
>     OUTPUT ${OBJ}
>     ARGS "-f win32" ${SOURCE}
>     COMMAND "nasm"
>     )
> ENDFOREACH(SOURCE)
> 
> When I use the following method,
> 
> ADD_LIBRARY (mylib ${MY_SRCS} ${OBJ})
> 
> CMake says that it cannot find any files finishing with (.c,.cxx,.h) etc... 
> 
> My problem is that I do not understand how to make a library (.lib or .dll)
> in CMake out of .obj files as is suggested in a further post on the topic.
> Assuming I have a set of object files ${OBJ} how do I manufacture a library 
> from the object files and merge this library into the original library  
> mylib?

You cannot use a SET command inside the ADD_CUSTOM_COMMAND arguments. 
I'll just assume that is a typo in your post.  Other than that this 
looks okay at a glance.  We'll need more details about what input file 
names you are using and error messages you are getting.

-Brad


More information about the CMake mailing list