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