Cmake Set Compiler
On 4 30 2015 12 52 pm nikolaus rath wrote.
Cmake set compiler. Add these lines to your cmakelists txt. Once opened set your paths and click on configure. For c and c set the cc and cxx environment variables. Hello is there a way to set the fortran compiler from cmakelists txt instead of setting the fc environment when calling cmake.
What i found worked reliably for me is to set cc and cxx and as needed cudacxx environment variables before running cmake. 2013 12 24 02 14 34 00 00 sometimes you might need to use a different version of a default compiler like gcc or a different compiler like intel compiler to build your code. However in my case i wanted to use gcc for normal compilation and intel compiler for my cmake project so method 1 was not suitable. Specifying this is easy in cmake.
That is not the way cmake works. This method is not guaranteed to work for all generators. Thanks for sharing that. Cmake evaluates the environment variables cc for the c compiler cxx for the c compiler and fc for the fortran compiler.
How to set c or c compiler for cmake first posted on. To use a different compiler e g. You want to avoid users of your project to ever have to edit a cmakelists txt file. 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.
As an alternative especially when you re new to cmake use the gui version under windows run cmake gui without parameters instead of cmake. Indeed method 1 and 2 listed in the faq are more elegant. To select a specific compiler you have several solutions as exaplained in cmake wiki.