# cmake cross compile setup

**URL:** <https://discourse.cmake.org/t/cmake-cross-compile-setup/11424>\
**Category:** Code\
**Created:** [August 11, 2024, 6:15pm UTC](https://discourse.cmake.org/t/cmake-cross-compile-setup/11424 "2024-08-11T18:15:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![duaneellis\_inno](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/f04885/32.png) [@duaneellis\_inno](https://discourse.cmake.org/u/duaneellis_inno)\
**Post date:** [August 11, 2024, 6:15pm UTC](https://discourse.cmake.org/t/cmake-cross-compile-setup/11424/1 "2024-08-11T18:15:55Z")

</div>

Cross compiling using the Linux Kernel Makefile way seems super easy to me.

One sets the CROSS\_COMPLE=/some/path/to/your-tripple-name-  
and it just works.

ie: set(CROSS\_COMPILE “/some/absolute/path/to/special/gcc/foo-bar-thang-”)

As an Example - XILINX Microblaze compiler or the XIILNX ARM, or - for Microsemi/Microchip - their RISCV compiler - each of these come in the tool vendors installation package - they are _NOT_ in my path.

Is there any way to make CMAKE understand CROSS\_COMPILE?

In my case - I am targeting multiple different CPUs - all use GCC,and I would really like to be able to just set the ONE or TWO variables and call some cmake file that takes care of the rest of the process - CMAKE does not need to _FIND_ the damn compiler I’m telling it exactly where it is located by an absolute path.

ie:

# tell the MACRO the prefix for GCC… ie: arm-non-eabi- )

set( CMAKE\_CROSS\_COMPILE\_PREFIX “/some/absolute/path/arm-none-eabi-”)

# This might set like: -fcpu=cortexm4 or hard/soft float options and -std=c11

set( CMAKE\_CROSS\_CFLAGS “… flags specific to this cross compiler …”)

# Same but for C++

set( CMAKE\_CROSS\_CXXFLAGS “.. flags specific to this cross compiler …”)

#then simply include some predefined thing that does the rest of the magic?  
include( cmake-cross-compile-via-gcc )
