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.

For more complete information about compiler optimizations, see our Optimization Notice.
File cmake-files.tar.gz769 bytes

1 comment

Jeongnim K.'s picture


The link for the toolchain files is not working. I'm also trying to use cmake to build simple examples with offload. Is there any customized command? Thanks

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.