[CMake] is it worth using cmake finds toolchain, but cannot find PF_CAN - os it confused?

Gunter, Walter E Walter.Gunter at dematic.com
Wed Oct 19 16:58:54 EDT 2016


Changing the subject line, since it is a great idea to use cmake.

Can I put that in my CMakeLists.txt?
Or would it be used on the command line when running cmake:

>Cmake –DCMAKE_TOOLCHAIN_FILE=cmake/toolchain.cmake –sysroot


I just tried it, and am still getting the error from make output.  If I put the linux/socket.h or sys/socket.h at the top of the #includes, I get the issues with variables already being defined, but don’t have get them when I put the #include for socket.h lower in the #include list:
For instance:

#include <cstdlib>
#include <stdio.h>
#include <cstring>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <unistd.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include <iostream>

#include <sys/socket.h>  // i tried linux/socket.h and get some other errors, so I am confused.
#include <pthread.h>
#include <net/if.h>
#include <string.h>
#include <net/if.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <assert.h>
#include <linux/can.h>
#include <linux/can/raw.h>

This is the output?

error: 'PF_CAN' was not declared in this scope
error: 'AF_CAN' was not declared in this scope

That’s it..nothing else.

Walter

From: J Decker [mailto:d3ck0r at gmail.com]
Sent: Wednesday, October 19, 2016 2:10 PM
To: Gunter, Walter E
Cc: Dave Flogeras; cmake at 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 <Walter.Gunter at dematic.com<mailto:Walter.Gunter at 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: dflogeras at gmail.com<mailto:dflogeras at gmail.com> [mailto:dflogeras at gmail.com<mailto:dflogeras at 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 <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?


--

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161019/4889ff69/attachment-0001.html>


More information about the CMake mailing list