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