I am trying to use CMake to build a fortran test app. My CMakeLists.txt is as follows:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET (TARGET_NAME test)
PROJECT (${TARGET_NAME} Fortran)

MESSAGE("FC = " $ENV{FC})
GET_FILENAME_COMPONENT(Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
MESSAGE("Fortran_COMPILER_NAME: " ${Fortran_COMPILER_NAME})

IF (Fortran_COMPILER_NAME MATCHES "gfortran.*")
  MESSAGE("COMPILER IS : gfortran")
SET (CMAKE_Fortran_FLAGS_RELEASE "-fbounds-check -fstatic -ftrace=full -fzero") SET (CMAKE_Fortran_FLAGS_DEBUG "-fbounds-check -fstatic -ftrace=full -fzero -g")
ELSE (Fortran_COMPILER_NAME MATCHES "gfortran.*")
MESSAGE ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
  MESSAGE ("Fortran compiler: " ${Fortran_COMPILER_NAME})
MESSAGE ("No optimized Fortran compiler flags are known, we just try -O2...")
  SET (CMAKE_Fortran_FLAGS_RELEASE "-O2")
  SET (CMAKE_Fortran_FLAGS_DEBUG   "-O0 -g")
ENDIF (Fortran_COMPILER_NAME MATCHES "gfortran.*")

SET (CMAKE_BUILD_TYPE Debug)

SET (Fortran_SRCS test.for)

ADD_EXECUTABLE (${TARGET_NAME}  ${Fortran_SRCS})

SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ./)


I have my env var FC set to /usr/bin/gfortran. This is verified by the line MESSAGE("FC = " $ENV{FC}). However GET_FILENAME_COMPONENT(Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME) sets Fortran_COMPILER_NAME to f95. I thought by setting the FC env var I could for the use of gfortran.

What do I need to do to insure that CMake uses gfortran?

Conan
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to