Discussion:
[CMake] is it worth using cmake to cross-compile for embedded arm device?
Gunter, Walter E
2016-09-16 20:26:23 UTC
Permalink
I am having some troubles getting cmake setup and wonder if cmake is the right tool.
Thoughts? Suggestions?

Walter E. Gunter, Jr.
Mechatronics Engineer/Roboticist
AGV R&D
Dematic North America
265 S 5200 W
Salt Lake City, UT 84104
801.715.2602

Customer Service 1.800.530.9153

DEMATIC l We Optimize Your Supply Chain www.dematic.com<http://www.dematic.com/>

MATERIAL HANDLING & LOGISTICS CONFERENCE www.mhlc.com<http://www.mhlc.com/>

CONFIDENTIALITY NOTICE: This email message and any attachments to it, is intended only for the individual or entity to which it is addressed and may contain confidential material. If you are not the intended recipient, or the employee or agent responsible for delivering it to the intended recipient, please do not disclose, copy, forward, or retain. If you have received this in error, please contact the sender by reply email and destroy all copies of the original message. ​
Rolf Eike Beer
2016-09-16 21:44:01 UTC
Permalink
Post by Gunter, Walter E
I am having some troubles getting cmake setup and wonder if cmake is the right tool.
Thoughts? Suggestions?
Yes, it is. I do it basically every day. Read my advise and properly set up a
toolchain file, that is very likely the missing magic.

https://cmake.org/cmake/help/v3.6/manual/cmake-toolchains.7.html

Eike
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Gunter, Walter E
2016-09-16 22:11:13 UTC
Permalink
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: ***@gmail.com [mailto:***@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 <***@dematic.com<mailto:***@dematic.com>> wrote:
I am having some troubles getting cmake setup and wonder if cmake is the right tool.
Thoughts? Suggestions?
Uwe Koloska
2016-09-19 09:16:13 UTC
Permalink
Content preview: On 17.09.2016 00:11, Gunter, Walter E wrote: > Okay…that made
a huge difference. Just a silly question: Where have been the commands that
you now have moved to the toolchain file? Before or after project()? [...]


Content analysis details: (-101.0 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-100 USER_IN_WHITELIST From: address is in the user's white-list
-1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP
Subject: Re: [CMake] is it worth using cmake to cross-compile for embedded
arm device?
X-BeenThere: ***@cmake.org
X-Mailman-Version: 2.1.18rc3
Precedence: list
List-Id: Cross-Platform Make <cmake.cmake.org>
List-Unsubscribe: <http://public.kitware.com/mailman/options/cmake>,
<mailto:cmake-***@cmake.org?subject=unsubscribe>
List-Archive: <http://public.kitware.com/pipermail/cmake/>
List-Post: <mailto:***@cmake.org>
List-Help: <mailto:cmake-***@cmake.org?subject=help>
List-Subscribe: <http://public.kitware.com/mailman/listinfo/cmake>,
<mailto:cmake-***@cmake.org?subject=subscribe>
Content-Type: text/plain; charset="windows-1252"
Content-Transfer-Encoding: quoted-printable
Okay…that made a huge difference.
Just a silly question: Where have been the commands that you now have
moved to the toolchain file? Before or after project()?

For project() triggers the process of finding the compiler etc. and I'm
not sure wether it uses variables defined after it.

Uwe
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Gunter, Walter E
2016-10-19 16:57:49 UTC
Permalink
The toolchain was a great suggestion.

I am still having problems, but at least I know I am using the right toolchain:
Currently, this is what I have for my toolchain:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TOOLCHAIN_PATH /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi)

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

# specify the cross compiler
set(CMAKE_CXX_COMPILER /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-g++)
set(CMAKE_C_COMPILER /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-gcc)

#set(CMAKE_AR /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-ar)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(COMPILE_FLAGS "-lrt -Wall -lpthread")


I run cmake with the reference to that toolchain file, cmake –DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake

I can see it finds the right toolchain and compilers.
Now I am having some issues where it is getting conflicted between using sys or linux headers
.
Is this just a header issue?

CMAKE question: What is the difference between the two variables?
TOOLCHAIN_PATH
CMAKE_FIND_ROOT_PATH
Should they be the same reference location?

This is the folder structure at the /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi
/bin
/include
/lib
/libc

Thoughts?

Thanks!

From: ***@gmail.com [mailto:***@gmail.com] On Behalf Of Dave Flogeras
Sent: Friday, September 16, 2016 5: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 <***@dematic.com<mailto:***@dematic.com>> wrote:
I am having some troubles getting cmake setup and wonder if cmake is the right tool.
Thoughts? Suggestions?
J Decker
2016-10-19 18:09:45 UTC
Permalink
to gcc you can pass --sysroot which will bias it's internal referenced
includes and libraries....
Post by Gunter, Walter E
The toolchain was a great suggestion.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TOOLCHAIN_PATH /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi)
# where is the target environment
set(CMAKE_FIND_ROOT_PATH /opt/toolchains/arm-2008q3/
arm-none-linux-gnueabi)
# specify the cross compiler
set(CMAKE_CXX_COMPILER /opt/toolchains/arm-2008q3/
bin/arm-none-linux-gnueabi-g++)
set(CMAKE_C_COMPILER /opt/toolchains/arm-2008q3/
bin/arm-none-linux-gnueabi-gcc)
#set(CMAKE_AR /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-ar)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(COMPILE_FLAGS "-lrt -Wall -lpthread")
I run cmake with the reference to that toolchain file, cmake
–DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake
I can see it finds the right toolchain and compilers.
Now I am having some issues where it is getting conflicted between using
sys or linux headers
.
Is this just a header issue?
CMAKE question: What is the difference between the two variables?
TOOLCHAIN_PATH
CMAKE_FIND_ROOT_PATH
Should they be the same reference location?
This is the folder structure at the /opt/toolchains/arm-2008q3/
bin/arm-none-linux-gnueabi
/bin
/include
/lib
/libc
Thoughts?
Thanks!
Flogeras
*Sent:* Friday, September 16, 2016 5: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 <
I am having some troubles getting cmake setup and wonder if cmake is the right tool.
Thoughts? Suggestions?
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at http://www.kitware.com/
opensource/opensource.html
http://public.kitware.com/mailman/listinfo/cmake
Gunter, Walter E
2016-10-19 19:32:15 UTC
Permalink
Can I put that in my CMakeLists.txt?
Cmake –DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake –sysroot
From: J Decker [mailto:***@gmail.com]
Sent: Wednesday, October 19, 2016 2:10 PM
To: Gunter, Walter E
Cc: Dave Flogeras; ***@cmake.org
Subject: Re: [CMake] is it worth using cmake to cross-compile for embedded arm device?

to gcc you can pass --sysroot which will bias it's internal referenced includes and libraries....

On Wed, Oct 19, 2016 at 9:57 AM, Gunter, Walter E <***@dematic.com<mailto:***@dematic.com>> wrote:
The toolchain was a great suggestion.

I am still having problems, but at least I know I am using the right toolchain:
Currently, this is what I have for my toolchain:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TOOLCHAIN_PATH /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi)

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

# specify the cross compiler
set(CMAKE_CXX_COMPILER /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-g++)
set(CMAKE_C_COMPILER /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-gcc)

#set(CMAKE_AR /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-ar)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(COMPILE_FLAGS "-lrt -Wall -lpthread")


I run cmake with the reference to that toolchain file, cmake –DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake

I can see it finds the right toolchain and compilers.
Now I am having some issues where it is getting conflicted between using sys or linux headers
.
Is this just a header issue?

CMAKE question: What is the difference between the two variables?
TOOLCHAIN_PATH
CMAKE_FIND_ROOT_PATH
Should they be the same reference location?

This is the folder structure at the /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi
/bin
/include
/lib
/libc

Thoughts?

Thanks!

From: ***@gmail.com<mailto:***@gmail.com> [mailto:***@gmail.com<mailto:***@gmail.com>] On Behalf Of Dave Flogeras
Sent: Friday, September 16, 2016 5: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 <***@dematic.com<mailto:***@dematic.com>> wrote:
I am having some troubles getting cmake setup and wonder if cmake is the right tool.
Thoughts? Suggestions?
--
Powered by www.kitware.com<http://www.kitware.com>

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...