[CMake] Support for cross compiling
Mark Jonas
toertel at gmail.com
Wed Apr 16 12:48:55 EDT 2008
Hi,
I am currently testing if CMake would be a usable build system for my
embedded C, C++ and assembly language project.
My first target compiler will be a cross gcc but I need to get CMake
to work with IAR and Green Hills compilers, too.
I found CMAKE_FORCE_C_COMPILER() and CMAKE_FORCE_CXX_COMPILER() to
force a different compiler. But how do I tell CMake about different
archivers, assemblers and linkers?
Is this a reasonable way to teach CMake to handle assembly language files?
FOREACH(src ${ASM_SRCS})
GET_FILENAME_COMPONENT(SRC_NAME ${src} NAME)
SET(ASM_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${src})
SET(ASM_OBJ ${CMAKE_CURRENT_BINARY_DIR}/${SRC_NAME}.o)
STRING(TOUPPER ${CMAKE_BUILD_TYPE} BTYPE)
SET(ASM_FLAGS ${CMAKE_C_FLAGS})
SET(ASM_FLAGS ${ASM_FLAGS} ${CMAKE_C_FLAGS_${BTYPE}})
SEPARATE_ARGUMENTS(ASM_FLAGS)
ADD_CUSTOM_COMMAND(
OUTPUT ${ASM_OBJ}
DEPENDS ${ASM_SRC}
COMMAND ${MY_ASM_COMPILER}
ARGS -c ${ASM_FLAGS} -o ${ASM_OBJ} ${ASM_SRC}
)
SET(ASM_OBJS ${ASM_OBJS} ${ASM_OBJ})
ENDFOREACH(src)
ADD_EXECUTABLE( ${EXENAME} ${SRCS} ${ASM_OBJS} )
Can this be done better?
Is there already assembly language support in CMake and I did not look
closely enough?
TIA,
Mark
More information about the CMake
mailing list