[CMake] Best way to sniff for Fortran compiler?

Michael Wild themiwi at gmail.com
Tue Dec 7 11:39:21 EST 2010


On 12/07/2010 05:15 PM, Convey, Christian J CIV NUWC NWPT, B-171 wrote:
> Any suggest for the most-proper way, in a CMakeLists.txt file, to determine whether the Intel vs. GNU fortran compiler will be used?
> 
> I need to use different sets of source files, and different compiler flags, depending on that detail.
> 
> Christian Convey

I think the CMAKE_Fortran_COMPILER_ID variable should do the job...

if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
  message(STATUS "Using GNU Fortran compiler")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
  message(STATUS "Using Intel Fortran compiler")
else()
  message(STATUS "Using unknown Fortran compiler")
endif()

Michael


More information about the CMake mailing list