[CMake] is it worth using cmake to cross-compile for embedded arm device?

Gunter, Walter E Walter.Gunter at dematic.com
Fri Sep 16 18:11:13 EDT 2016


Okay…that made a huge difference.

Just moving those set commands to a separate toolchain.cmake file worked.  Even though the commands were the same, and I had the CMAKE_FIND_ROOT_PATH at the top of the toplevel CMakeLists.txt before project:

# where is the target environment
set(CMAKE_FIND_ROOT_PATH /opt/toolchains/arm-2008q3/)

and then had all the settings that I moved into the toolchain.cmake file.
The difference came from moving the cross compile settings I had in the top level CMakeLists.txt to the myhardware_toolchain.cmake.
Now, I added the CMAKE_TOOLCHAIN_FILE to the toplevel CMakeLists.txt at the top (right under cmake_minimum_required 3.2) and the output of cmake is now looking right:

#set toolchain to use
set(CMAKE_TOOLCHAIN_FILE cmake/myHardware_toolchain.cmake)

>cmake ../projectFolder
-- The C compiler identification is GNU 4.3.2
-- The CXX compiler identification is GNU 4.3.2
-- Check for working C compiler: /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-gcc
-- Check for working C compiler: /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-gcc -- works



Now to see why it doesn’t make…. It is getting hung up on some of the includes that should be fine.
Any suggestions on why when including
#include <linux/can.h>
The compiler has an issue with using its own linux headers from the toolchain?



From: dflogeras at gmail.com [mailto:dflogeras at gmail.com] On Behalf Of Dave Flogeras
Sent: Friday, September 16, 2016 3:43 PM
To: Gunter, Walter E
Subject: Re: [CMake] is it worth using cmake to cross-compile for embedded arm device?

I personally use cmake with multiple cross toolchains successfully.  I guess it depends on what you are trying to achieve.  I prefer it because I can use the same CMakeLists.txt to build natively on linux/mac/windows, as well as cross-compile against an embedded arm linux.  I'd also agree with the previous discussion about using a toolchain file for your platform, it does simplify things.

On Fri, Sep 16, 2016 at 5:26 PM, Gunter, Walter E <Walter.Gunter at dematic.com<mailto:Walter.Gunter at dematic.com>> wrote:
I am having some troubles getting cmake setup and wonder if cmake is the right tool.
Thoughts? Suggestions?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160916/99ceaed2/attachment-0001.html>


More information about the CMake mailing list