To use a different compiler (e.g. Intel Compiler, CLANG or PGI) or a different version then CMake uses by default, one can either set environment variables or modify
the CMakeLists.txt file.
CMake evaluates the environment variables CC
for the C compiler, CXX
for the C++ compiler and FC
for the Fortran compiler:
CC=/path/to/icc cmake .. CXX=/path/to/icpc cmake .. FC=/path/to/ifort cmake ..
For a more permanent solution, one can also edit the CMakeLists.txt file:
SET(CMAKE_C_COMPILER /path/to/pgcc) SET(CMAKE_CXX_COMPILER /path/to/pgc++) SET(CMAKE_FC_COMPILER /path/to/pgfortran)
BTW: The environment variables LDFLAGS
, CFLAGS
, CXXFLAGS
or FFLAGS
are also evaluated by CMake.
Leave a Reply