[CMake] What do I need to do to insure that CMake uses gfortran?
Conan
dev at celticblues.com
Thu Apr 3 17:07:27 EDT 2014
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
More information about the CMake
mailing list