I'm using CMake and SDCC to build a project for the 8051
microcontroller. CMake has been working great for this so far, but now
I need to link in an object file that I've assembled with SDCC's
"asx8051" assembler, and I am not able to get CMake to explicitly add
an object file to the list of objects to be linked into a target.
The problem is that CMake is *silently* ignoring the request to link the
object file into the executable target with ADD_EXECUTABLE().
First, I am using ADD_CUSTOM_COMMAND to assemble the assembly code into
an object file (".rel" extension, as are the object files produced by
SDCC for compiled C code). The custom command is resulting in the
object file being produced properly.
Next, my ADD_EXECUTABLE() call simply names the object file in addition
to the C source files that I already am specifying. However, while the
C source files are compiled and linked with into the target executable,
the '.rel' object file is not being added into the list of objects to
link into the executable.
I think that the GENERATED=TRUE and EXTERNAL_OBJECT=TRUE source
properties on the generated object file should cause CMake to link it.
Is there something I'm doing wrong?
Here's my CMakeLists.txt:
-----------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(timertest C)
SET(CMAKE_ASM_OUTPUT_EXTENSION ${CMAKE_C_OUTPUT_EXTENSION})
SET(MY_SRCS main.c)
SET(MY_ASM_SRCS sleep_timer_get.asm)
FOREACH(ASMFILE ${MY_ASM_SRCS})
GET_FILENAME_COMPONENT(BASENAME ${ASMFILE} NAME_WE)
SET(SRC ${CMAKE_CURRENT_SOURCE_DIR}/${ASMFILE})
SET(OBJ
${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}${CMAKE_ASM_OUTPUT_EXTENSION})
SET_SOURCE_FILES_PROPERTIES(${OBJ} PROPERTIES
GENERATED TRUE
EXTERNAL_OBJECT TRUE)
ADD_CUSTOM_COMMAND(OUTPUT ${OBJ}
MAIN_DEPENDENCY ${SRC}
COMMAND asx8051-wrapper
ARGS -I${CMAKE_CURRENT_SOURCE_DIR}
-o ${OBJ} ${SRC})
LIST(APPEND MY_ASM_OBJS ${OBJ})
ENDFOREACH(ASMFILE ${MY_ASM_SRCS})
MESSAGE(STATUS "MY_ASM_OBJS is ${MY_ASM_OBJS}")
ADD_EXECUTABLE(timertest main.c ${MY_ASM_OBJS})
-----------------------------------------------------------------
I have attached the output I get when I build using this file.
I have spent all day and most of the night trying to get this to work,
and I've already started working on a Makefile to replace CMake for
this, though I really would hate to give up CMake; however, this silent
failure by CMake is creating an impossible-to-track-down problem.
Thanks for any help.
Regards,
Colin
[EMAIL PROTECTED] ~/vdsi/beacon-work/tmp-test/out9 $ cmake-sdcc ..
-- The C compiler identification is SDCC
-- Check for working C compiler: /home/cdb/bin/sdcc/bin/sdcc
-- Check for working C compiler: /home/cdb/bin/sdcc/bin/sdcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- MY_ASM_OBJS is /home/cdb/vdsi/beacon-work/tmp-test/out9/sleep_timer_get.rel
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cdb/vdsi/beacon-work/tmp-test/out9
[EMAIL PROTECTED] ~/vdsi/beacon-work/tmp-test/out9 $ make VERBOSE=1
/usr/bin/cmake -H/home/cdb/vdsi/beacon-work/tmp-test
-B/home/cdb/vdsi/beacon-work/tmp-test/out9 --check-build-system
CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start
/home/cdb/vdsi/beacon-work/tmp-test/out9/CMakeFiles
/home/cdb/vdsi/beacon-work/tmp-test/out9/CMakeFiles/progress.make
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/cdb/vdsi/beacon-work/tmp-test/out9'
make -f CMakeFiles/timertest.dir/build.make CMakeFiles/timertest.dir/depend
make[2]: Entering directory `/home/cdb/vdsi/beacon-work/tmp-test/out9'
/usr/bin/cmake -E cmake_progress_report
/home/cdb/vdsi/beacon-work/tmp-test/out9/CMakeFiles 2
[ 50%] Generating sleep_timer_get.rel
asx8051-wrapper -I/home/cdb/vdsi/beacon-work/tmp-test -o
/home/cdb/vdsi/beacon-work/tmp-test/out9/sleep_timer_get.rel
/home/cdb/vdsi/beacon-work/tmp-test/sleep_timer_get.asm
SRC: '/home/cdb/vdsi/beacon-work/tmp-test/sleep_timer_get.asm'
OBJ: '/home/cdb/vdsi/beacon-work/tmp-test/out9/sleep_timer_get.rel'
Running assembler...
`/home/cdb/vdsi/beacon-work/tmp-test/sleep_timer_get.rel' ->
`/home/cdb/vdsi/beacon-work/tmp-test/out9/sleep_timer_get.rel'
`/home/cdb/vdsi/beacon-work/tmp-test/sleep_timer_get.lst' ->
`/home/cdb/vdsi/beacon-work/tmp-test/out9/sleep_timer_get.lst'
`/home/cdb/vdsi/beacon-work/tmp-test/sleep_timer_get.sym' ->
`/home/cdb/vdsi/beacon-work/tmp-test/out9/sleep_timer_get.sym'
cd /home/cdb/vdsi/beacon-work/tmp-test/out9 && /usr/bin/cmake -E cmake_depends
"Unix Makefiles" /home/cdb/vdsi/beacon-work/tmp-test
/home/cdb/vdsi/beacon-work/tmp-test /home/cdb/vdsi/beacon-work/tmp-test/out9
/home/cdb/vdsi/beacon-work/tmp-test/out9
/home/cdb/vdsi/beacon-work/tmp-test/out9/CMakeFiles/timertest.dir/DependInfo.cmake
--color=
Dependee
"/home/cdb/vdsi/beacon-work/tmp-test/out9/CMakeFiles/timertest.dir/DependInfo.cmake"
is newer than depender
"/home/cdb/vdsi/beacon-work/tmp-test/out9/CMakeFiles/timertest.dir/depend.internal".
Scanning dependencies of target timertest
make[2]: Leaving directory `/home/cdb/vdsi/beacon-work/tmp-test/out9'
make -f CMakeFiles/timertest.dir/build.make CMakeFiles/timertest.dir/build
make[2]: Entering directory `/home/cdb/vdsi/beacon-work/tmp-test/out9'
/usr/bin/cmake -E cmake_progress_report
/home/cdb/vdsi/beacon-work/tmp-test/out9/CMakeFiles 1
[100%] Building C object CMakeFiles/timertest.dir/main.c.rel
/home/cdb/bin/sdcc/bin/sdcc -mmcs51 --model-large --stack-auto --std-c99 -o
CMakeFiles/timertest.dir/main.c.rel -c
/home/cdb/vdsi/beacon-work/tmp-test/main.c
Linking C executable timertest.ihx
/usr/bin/cmake -E cmake_link_script CMakeFiles/timertest.dir/link.txt
--verbose=1
/home/cdb/bin/sdcc/bin/sdcc -mmcs51 --model-large --stack-auto --std-c99
CMakeFiles/timertest.dir/main.c.rel --out-fmt-ihx -o timertest.ihx --xram-loc
0xF000 --xram-size 3414 --iram-size 256 --code-size 32768
?ASlink-Warning-Undefined Global '_sleep_timer_get' referenced by module 'main'
make[2]: *** [timertest.ihx] Error 1
make[2]: Leaving directory `/home/cdb/vdsi/beacon-work/tmp-test/out9'
make[1]: *** [CMakeFiles/timertest.dir/all] Error 2
make[1]: Leaving directory `/home/cdb/vdsi/beacon-work/tmp-test/out9'
make: *** [all] Error 2
[EMAIL PROTECTED] ~/vdsi/beacon-work/tmp-test/out9 $
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake