> > > Assembly files explicitly given as source files for a target are > > > completely ignored. From google searches, it seems to be a known > issue > > > and the solution lies with adding custom commands. > > > > > > I am not familiar with adding custom commands. And thus have > assembly > > > files assembled before building a target. Is there a wiki or a > > tutorial > > > on this? > > > > Currently I am trying the macro; > > > > #Add assembly source files that are not natively supported in cmake > > #Syntax: ADD_ASM_SOURCES(SRC_LST asm1 asm2 asm3 ...) > > MACRO(ADD_ASM_SOURCES SRC_LST) > > FOREACH (SOURCE ${ARGN}) > > GET_FILENAME_COMPONENT(infile ${SOURCE} ABSOLUTE) > > GET_FILENAME_COMPONENT(outfile ${infile} NAME_WE) > > SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.o) > > MESSAGE("SOURCE = ${infile}") > > ADD_CUSTOM_COMMAND (OUTPUT ${outfile} > > COMMAND echo "Assembling ${infile} to > > ${outfile}" > > COMMAND ${CMAKE_C_COMPILER} -c -o ${outfile} > > ${infile} > > MAIN_DEPENDENCY ${infile} > > ) > > IF(NOT EXISTS ${outfile}) > > # MESSAGE(FATAL_ERROR "object file ${outfile} is > > not present") > > ENDIF(NOT EXISTS ${outfile}) > > SET(${SRC_LST} ${outfile} ${${SRC_LST}}) > > MESSAGE("SRC_LST = ${${SRC_LST}}") > > ENDFOREACH(SOURCE) > > ENDMACRO(ADD_ASM_SOURCES SRC_LIST) > > > > I get the MESSAGE prints but not the echo output. Seems like custom > > command is not executed?! What is wrong here? > > Anyone who have tried this before? I have read a couple of entries in > the archives from which I derived the above but they are either too old > or do not work. > > Can anyone help?
Finally, I am successful at assembling files; SET(OBJS ) FOREACH(SOURCE ${ASM_SRCS}) GET_FILENAME_COMPONENT(SOURCE ${SOURCE} ABSOLUTE) GET_FILENAME_COMPONENT(DEST ${SOURCE} NAME_WE) SET(DEST ${CMAKE_CURRENT_BINARY_DIR}/${DEST}.o) ADD_CUSTOM_COMMAND (OUTPUT ${DEST} COMMAND echo "Assembling ${infile} to ${outfile}" COMMAND ${CMAKE_C_COMPILER} -c -o ${DEST} ${SOURCE} MAIN_DEPENDENCY ${SOURCE} ) SET(OBJS ${OBJS} ${DEST}) ENDFOREACH(SOURCE ${ASM_SRCS}) SET_SOURCE_FILES_PROPERTIES(${OBJS} PROPERTIES GENERATED 1) ADD_LIBRARY(asm ${OBJS}) SET_TARGET_PROPERTIES(asm PROPERTIES LINKER_LANGUAGE C) The problem now is that if I do not want to add target here but in a parent CMakeLists.txt (by caching OBJS) source file properties are not propogated and cmake complains that it cannot find the .o files but has searched with various extension like .c .C .cxx ... Is there a solution for this? Besides, is there a cleaner solution for assembling? For example can I declare a custom command for processing any files that have a .S extension and then simple pass the assembly source files to a target and let cmake automatically call the custom command on these files? Warm regards, Kishore _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake