Cross-compilation for Intel® Xeon Phi™ Coprocessor with CMake

Cross-compilation for Intel® Xeon Phi™ Coprocessor with CMake

CMake is a cross-platform, open-source build system. A special file named “toolchain” is required for cross-compilation, and this file should define all tools (compiler, linker, libraries, etc.) needed for building an application.  To invoke Cmake with the toolchain file, use the following command-line option:


An example toolchain file that works on Intel® Xeon Phi™ Coprocessor can be found here (attached to this article, see Download link below) .  In order for this to work in your environment, you will need to update the path to the Intel(R) Manycore Platform Software Stack (Intel(R) MPSS) by modifying the CMAKE_FIND_ROOT_PATH variable in the toolchain file to match the path that is used on your system.

If your project requires the MPI CMake module, FindMPI will need to be patched with the patch file attached to this article (also in the Download link below). This patch fixes recognition of MPI libraries for cross compilation and is valid for CMake version 2.8.

The following variables (compilers and compilation options) should be defined before the build:

export CC=icc
export CXX=icpc
export FC=ifort
export CFLAGS="-mmic"
export MPI_C=mpiicc
export MPI_CXX=mpiicpc


That’s it – CMake is ready for cross-building on your Intel(R) Xeon Phi(tm) Coprocessor.

Note:  CMake is an out of source build system – you need to create a new folder and invoke the cmake command from there. CMake will cache everything it is doing. If you are changing build options or definitions you need to remove everything from the build folder.

Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.