[CMake] specifying linker for cross-compilation

Guraaf guraaf at gmail.com
Tue May 19 10:55:43 EDT 2015


Hello all,

I am a newbie though I have used CMake a bit for a few projects. Now, I am
trying to use CMake for cross-compiling on my Linux desktop for an embedded
system (ARM DS-5 based).

Right now, the needs are simple - I need to specify the compiler and linker
with flags for both. However, I can't figure out why the linking step
doesn't work. The "armlink" does get specified but Make is invoking it
without any parameters, i.e., without any object files to link and produce
the output .elf file. I am looking to keep it simple and hopefully this is
not too involved. Any advice appreciated.

My system has cmake version 2.8.7 and I invoke as:
$ cd build
$ cmake ..
$ make VERBOSE=1

I can't seem to figure out where and how do I tell that the output will be
blinky.elf. e.g., If I try on command-line by myself it is:
$ armlink --cpu=Cortex-M3  --map --ro-base=0x0 --rw-base=0x0008000
--first='boot.o(RESET)' --datacompressor=off
CMakeFiles/blinky.dir/blinky.c.o  -o blinky.elf

but the makefile is invoking as only:
$ armlink

My current CMakeLists and output is given below. Look forward to your
pointers.
cmake_minimum_required(VERSION 2.8)

SET(CMAKE_SYSTEM_NAME Generic)
project(test_arm)
enable_language(C ASM)


# cross-compilation for ARM
SET(CMAKE_C_COMPILER armcc)
SET(CMAKE_AR armar)
SET(CMAKE_LINKER armlink)

SET(CMAKE_C_FLAGS "--cpu=Cortex-M3")
SET(CMAKE_AR_FLAGS "-armcc,-Ospace")
SET(CMAKE_EXE_LINKER_FLAGS "--map --ro-base=0x0 --rw-base=0x0008000
--first='boot.o(RESET)' --datacompressor=off")

include_directories(../include)

add_executable( blinky blinky.c )
set_target_properties( blinky PROPERTIES LINKER_LANGUAGE C)

$ make VERBOSE=1[100%] Building C object
CMakeFiles/blinky.dir/blinky.c.o/usr/bin/cmake -E cmake_link_script
CMakeFiles/blinky.dir/link.txt --verbose=1
armlinkLinking C executable blinkyProduct: DS-5 Professional 5.21.0
[5210017]Component: ARM Compiler 5.05 update 1 (build 106)Tool:
armlink [4d0efa]For support see http://www.arm.com/support/Software
supplied by: ARM LimitedUsage: armlink option-list input-file-list

----
Guraaf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150519/323dd5af/attachment.html>


More information about the CMake mailing list