[CMake] Linking object files into executable target

Colin D Bennett colin at gibibit.com
Wed Dec 10 01:39:40 EST 2008


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



More information about the CMake mailing list