[CMake] cross-compiling for arm
Gunter, Walter E
Walter.Gunter at dematic.com
Fri Sep 16 15:12:03 EDT 2016
I setup the Main CMakeLists.txt to cross_compile using an arm toolchain:
cmake_minimum_required(VERSION 3.2)
project(enterprise CXX)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CXX_COMPILER /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-g++)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_AR /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-ar)
set(CMAKE_FIND_ROOT_PATH /mnt/root)
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")
find_package(Threads)
add_subdirectory(src)
if(CMAKE_CROSSCOMPILING)
message("I should be cross compiling: ")
endif()
#find_package(GTest REQUIRED)
--------------------------------------------------------
I made some changes to my cmakelists.txt in my src file :
set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}
*list of files*.cpp
Mainfile.cpp
Mycan.cpp #this one references the linux/can.h
)
include_directories("../includes")
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CXX)
add_executable(enterprise ${SOURCES})
target_link_libraries(enterprise ${CMAKE_THREAD_LIBS_INIT} pthread)
I am now getting an error that it can't find a linux can header that is included in the toolchain:
error: 'PF_CAN' was not declared in this scope
This is referenced in the linux/can.h (a socket can define that is preset)
#include <
-----Original Message-----
From: Rolf Eike Beer [mailto:eike at sf-mail.de]
Sent: Thursday, September 15, 2016 12:06 PM
To: cmake at cmake.org
Cc: Gunter, Walter E
Subject: Re: [CMake] cross-compiling for arm
Am Donnerstag, 15. September 2016, 15:48:02 schrieb Gunter, Walter E:
> I am using the arm-2008q3 toolchain and having some issues with compiling.
> Doing a c++ compile for RT Linux,
> I have setup the following in my main CMakeLists.txt
Use a toolchain file. project() will scan for the compiler and do all sorts of setup code, you can never be sure to override enough afterwards. In fact, you probably can't.
https://cmake.org/cmake/help/v3.6/manual/cmake-toolchains.7.html
Eike
--
More information about the CMake
mailing list