1 # Cross-compiling requires CMake 2.6 or newer. Example:
2 # cmake .. -DCMAKE_TOOLCHAIN_FILE=../XCompile-Android.txt -DHOST=arm-linux-androideabi
3 # Where 'arm-linux-androideabi' is the host prefix for the cross-compiler. If
4 # you already have a toolchain file setup, you may use that instead of this
5 # file. Make sure to set CMAKE_FIND_ROOT_PATH to where the NDK toolchain was
6 # installed (e.g. "$ENV{HOME}/toolchains/arm-linux-androideabi-r10c-21").
8 # the name of the target operating system
9 SET(CMAKE_SYSTEM_NAME Linux)
11 # which compilers to use for C and C++
12 SET(CMAKE_C_COMPILER "${HOST}-gcc")
13 SET(CMAKE_CXX_COMPILER "${HOST}-g++")
14 SET(CMAKE_RC_COMPILER "${HOST}-windres")
16 # here is the target environment located
17 SET(CMAKE_FIND_ROOT_PATH "SET THIS TO THE NDK TOOLCHAIN'S INSTALL PATH")
19 # here is where stuff gets installed to
20 SET(CMAKE_INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}" CACHE STRING "Install path prefix, prepended onto install directories." FORCE)
22 # adjust the default behaviour of the FIND_XXX() commands:
23 # search headers and libraries in the target environment, search
24 # programs in the host environment
25 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
26 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
27 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
29 # set env vars so that pkg-config will look in the appropriate directory for
30 # .pc files (as there seems to be no way to force using ${HOST}-pkg-config)
31 set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
32 set(ENV{PKG_CONFIG_PATH} "")
35 SET(QT_QMAKE_EXECUTABLE ${HOST}-qmake)
36 SET(QT_MOC_EXECUTABLE ${HOST}-moc)
37 SET(QT_RCC_EXECUTABLE ${HOST}-rcc)
38 SET(QT_UIC_EXECUTABLE ${HOST}-uic)
39 SET(QT_LRELEASE_EXECUTABLE ${HOST}-lrelease)