[CMake] Linking object files into executable target

James Bigler jamesbigler at gmail.com
Wed Dec 10 15:45:58 EST 2008


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 <colin at gibibit.com> wrote:

> On Tue, 9 Dec 2008 22:26:11 -0800
> Colin D Bennett <colin at gibibit.com> 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 at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081210/059e6dc3/attachment.htm>


More information about the CMake mailing list