Re: [CMake] Linking object files into executable target

2009-01-11 Thread Alexander Neundorf
On Wednesday 10 December 2008, Alexander Neundorf wrote:
> On Wednesday 10 December 2008, Colin D Bennett wrote:
> > On Tue, 9 Dec 2008 22:26:11 -0800
> >
> > Colin D Bennett  wrote:
> > > The problem is that CMake is *silently* ignoring the request to link
> > > the object file into the executable target with ADD_EXECUTABLE().
> >
> > I forgot to include the CMake/SDCC toolchain file I'm using, which
> > might be of help:
>
> I think we should try to get the assembler working as assembler. I.e.
> enable_language(ASM...)
> I will have a closer look in the next days.
> You can have a look at the other assembler support files in CMake/Modules/.
> I guess we'll have to create a ASM_SDCC "language".

Finally I took the time to write some documentation about how the assembler 
support in cmake works:
http://www.cmake.org/Wiki/CMake/Assembler

I think you should create an assembler "dialect" for sdcc, which handles 
assembler files appropriately.

Please let me know if that helps, if there are things unclear or missing on 
the wiki page etc.

Bye
Alex
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Linking object files into executable target

2008-12-10 Thread Alexander Neundorf
On Wednesday 10 December 2008, Colin D Bennett wrote:
> On Tue, 9 Dec 2008 22:26:11 -0800
>
> Colin D Bennett <[EMAIL PROTECTED]> wrote:
> > The problem is that CMake is *silently* ignoring the request to link
> > the object file into the executable target with ADD_EXECUTABLE().
>
> I forgot to include the CMake/SDCC toolchain file I'm using, which
> might be of help:

I think we should try to get the assembler working as assembler. I.e. 
enable_language(ASM...)
I will have a closer look in the next days.
You can have a look at the other assembler support files in CMake/Modules/.
I guess we'll have to create a ASM_SDCC "language".

Alex
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Linking object files into executable target

2008-12-10 Thread James Bigler
I asked a similar question about a month ago.  The response can be found in
the archive:

http://www.cmake.org/pipermail/cmake/2008-November/025541.html

I tried it on VS, and it seem to work (though I had to use .obj instead of
.o to make it work).

Perhaps you could take the response as a start and work back to your project
a little at a time.

James

On Tue, Dec 9, 2008 at 11:39 PM, Colin D Bennett <[EMAIL PROTECTED]> wrote:

> On Tue, 9 Dec 2008 22:26:11 -0800
> Colin D Bennett <[EMAIL PROTECTED]> wrote:
>
> > The problem is that CMake is *silently* ignoring the request to link
> > the object file into the executable target with ADD_EXECUTABLE().
>
> I forgot to include the CMake/SDCC toolchain file I'm using, which
> might be of help:
>
>
> 
> # the name of the target operating system
> SET(CMAKE_SYSTEM_NAME Generic)
>
> # which compilers to use for C and C++
> SET(CMAKE_C_COMPILER sdcc)
> SET(SDCC_MCS51_MEMORY_MODEL "large")
> SET(SDCC_STACK_AUTO ON)
> # Flags common to both compiler and linker.
> SET(SDCC_MCS51_COMMON_FLAGS "-mmcs51
>--model-${SDCC_MCS51_MEMORY_MODEL}")
> IF(SDCC_STACK_AUTO)
>SET(SDCC_MCS51_COMMON_FLAGS "${SDCC_MCS51_COMMON_FLAGS}
>--stack-auto")
> ENDIF(SDCC_STACK_AUTO)
>
> SET(CMAKE_C_FLAGS_INIT "${SDCC_MCS51_COMMON_FLAGS} --std-c99")
> SET(CMAKE_EXE_LINKER_FLAGS_INIT "${SDCC_MCS51_COMMON_FLAGS}")
>
> # Safe memory mapping which excludes the vanishing region.
> # There are only 3414 bytes available in XDATA, but it is all retained
> # through PM2 and PM3.
> SET(SDCC_CC2430_MEMORY_MAPPING
>"--xram-loc 0xF000 --xram-size 3414 --iram-size 256 --code-size
> 32768")
>
> SET(CMAKE_EXE_LINKER_FLAGS_INIT ${SDCC_CC2430_MEMORY_MAPPING})
>
> # here is the target environment is located
> SET(CMAKE_FIND_ROOT_PATH /home/cdb/bin/sdcc)
>
> # adjust the default behaviour of the FIND_XXX() commands:
> # search headers and libraries in the target environment, search
> # programs in the host environment
> set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
> set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
> set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
> 
>
>
> Then I use "cmake -DCMAKE_TOOLCHAIN_FILE=TOOLCHAIN.cmake" to build.
>
> Regards,
> Colin
>
> ___
> CMake mailing list
> CMake@cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Linking object files into executable target

2008-12-09 Thread Colin D Bennett
On Tue, 9 Dec 2008 22:26:11 -0800
Colin D Bennett <[EMAIL PROTECTED]> wrote:

> The problem is that CMake is *silently* ignoring the request to link
> the object file into the executable target with ADD_EXECUTABLE().

I forgot to include the CMake/SDCC toolchain file I'm using, which
might be of help:



# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Generic)

# which compilers to use for C and C++
SET(CMAKE_C_COMPILER sdcc)
SET(SDCC_MCS51_MEMORY_MODEL "large")
SET(SDCC_STACK_AUTO ON)
# Flags common to both compiler and linker.
SET(SDCC_MCS51_COMMON_FLAGS "-mmcs51
--model-${SDCC_MCS51_MEMORY_MODEL}") 
IF(SDCC_STACK_AUTO)
SET(SDCC_MCS51_COMMON_FLAGS "${SDCC_MCS51_COMMON_FLAGS}
--stack-auto")
ENDIF(SDCC_STACK_AUTO)

SET(CMAKE_C_FLAGS_INIT "${SDCC_MCS51_COMMON_FLAGS} --std-c99")
SET(CMAKE_EXE_LINKER_FLAGS_INIT "${SDCC_MCS51_COMMON_FLAGS}")

# Safe memory mapping which excludes the vanishing region.
# There are only 3414 bytes available in XDATA, but it is all retained
# through PM2 and PM3.
SET(SDCC_CC2430_MEMORY_MAPPING
"--xram-loc 0xF000 --xram-size 3414 --iram-size 256 --code-size
32768")

SET(CMAKE_EXE_LINKER_FLAGS_INIT ${SDCC_CC2430_MEMORY_MAPPING})

# here is the target environment is located
SET(CMAKE_FIND_ROOT_PATH /home/cdb/bin/sdcc)

# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search 
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)



Then I use "cmake -DCMAKE_TOOLCHAIN_FILE=TOOLCHAIN.cmake" to build.

Regards,
Colin

___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Linking object files into executable target

2008-12-09 Thread Colin D Bennett
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