1# 2# CMake Toolchain file for crosscompiling on ARM. 3# 4# This can be used when running cmake in the following way: 5# cd build/ 6# cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-arm-linux-gnueabihf.cmake 7# 8 9set(CROSS_PATH /opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.02-01-20130221_linux) 10 11# Target operating system name. 12set(CMAKE_SYSTEM_NAME Linux) 13 14# Name of C compiler. 15set(CMAKE_C_COMPILER "${CROSS_PATH}/bin/arm-linux-gnueabihf-gcc") 16set(CMAKE_CXX_COMPILER "${CROSS_PATH}/bin/arm-linux-gnueabihf-g++") 17 18# 19# Different build system distros set release optimization level to different 20# things according to their local policy, eg, Fedora is -O2 and Ubuntu is -O3 21# here. Actually the build system's local policy is completely unrelated to 22# our desire for cross-build release optimization policy for code built to run 23# on a completely different target than the build system itself. 24# 25# Since this goes last on the compiler commandline we have to override it to a 26# sane value for cross-build here. Notice some gcc versions enable broken 27# optimizations with -O3. 28# 29if (CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES release) 30 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") 31 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") 32endif() 33 34# Where to look for the target environment. (More paths can be added here) 35set(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}") 36 37# Adjust the default behavior of the FIND_XXX() commands: 38# search programs in the host environment only. 39set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 40 41# Search headers and libraries in the target environment only. 42set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 43set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 44 45