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:e...@sf-mail.de] 
Sent: Thursday, September 15, 2016 12:06 PM
To: cmake@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
-- 
-- 

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

Reply via email to