Ask Your Question

Revision history [back]

Have you tried using a toolchain.cmake file?

Here is an example (for cross-compiling to the raspberry pi), I set the arm cross compiler:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++-4.4)
set(CMAKE_FIND_ROOT_PATH $ENV{HOME}/rpi/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/sysroot $ENV{HOME}/rpi/rootfs $ENV{HOME}/rpi/rootfs/e2fsprogs-1.42.9 $ENV{HOME}/rpi/rootfs/usr $ENV{HOME}/rpi/rootfs/usr/lib $ENV{HOME}/rpi/rootfs/usr/include $ENV{HOME}/rpi/ros_catkin_ws/install_isolated)
#SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -mfpu=vfp -mfloat-abi=softfp -mcpu=arm1176jzf-s" )
#SET( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -static" )
# Have to set this one to BOTH, to allow CMake to find python
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Then, I invoke it with:

catkin_make_isolated --cmake-args -DCMAKE_TOOLCHAIN_FILE=/home/myuser/rpi/toolchain.raspi.cmake