[CMake] CMake and Absoft Fortran compilers

Yngve Inntjore Levinsen yngve.levinsen at gmail.com
Wed Sep 22 14:53:40 EDT 2010


Do you know how to compile for Fortran in general? I don't know the Absoft compiler, but I've used some others.

First off you need to enable Fortran language. This you can do by e.g.
PROJECT(<projectname> Fortran CXX C) where you after the project name gives a list of the languages you use in your project.

Next you can enable the compiler of choice with (replace g95 with the binary of your compiler)
SET(CMAKE_Fortran_COMPILER g95)
You can set this when you call cmake instead, like this
cmake -DCMAKE_Fortran_COMPILER=g95 <path>

Then you can continue setting Fortran specific flags based on compiler:
  if (CMAKE_Fortran_COMPILER MATCHES "gfortran")
   set (CMAKE_Fortran_FLAGS_RELEASE " -g -funroll-loops -fno-range-check -fno-f2c -O2 ")
   set (CMAKE_Fortran_FLAGS_DEBUG   " -fno-f2c -O0 -g ")
   set (CMAKE_Fortran_LINK_FLAGS   "${CMAKE_Fortran_LINK_FLAGS} -static ")
 elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
...
 endif (CMAKE_Fortran_COMPILER MATCHES "gfortran")

I hope this helps, not quite sure this was what you asked for? By the way, you need CMake 2.6.x or newer I believe, fortran support is quite limited (or non-existent?) in earlier versions.

Best Regards
Yngve

On Wednesday 22 September 2010 19:03:49 Michael Jackson wrote:
> Does anyone use CMake in combination with the Absoft fortran  
> compilers? What environment variables would need to be set to have  
> cmake detect the Absoft compilers? Like you can set CC or CXX vars.
> 
> Thanks for any information.
> ___________________________________________________________
> Mike Jackson                      www.bluequartz.net
> Principal Software Engineer       mike.jackson at bluequartz.net
> BlueQuartz Software               Dayton, Ohio
> 
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
> 


More information about the CMake mailing list