Skip to content

Commit

Permalink
Extend fortran standard to other compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj committed Sep 24, 2019
1 parent c38c1dd commit c082b7f
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ option(FLIBCPP_USE_SWIG "Regenerate source files using SWIG" ${FLIBCPP_DEV})
# FLAGS
#---------------------------------------------------------------------------#

# Fortran standard
set(FLIBCPP_FORTRAN_STD "03" CACHE STRING
"Fortran standard for compiling generated code (options: 03/08/15/18)")
if (FLIBCPP_FORTRAN_STD AND NOT FLIBCPP_FORTRAN_STD STREQUAL "none")
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
set(_FLIBCPP_STD_FLAGS "-std=f20${FLIBCPP_FORTRAN_STD}")
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
set(_FLIBCPP_STD_FLAGS "-stand ${FLIBCPP_FORTRAN_STD}")
else()
message(WARNING "Fortran standard flags are not known for "
"compilier '${CMAKE_Fortran_COMPILER_ID}': ignoring"
"FLIBCPP_FORTRAN_STD=${FLIBCPP_FORTRAN_STD}. Configure with "
"the FFLAGS environment variable or explicitly specify "
"CMAKE_Fortran_FLAGS")
set(_FLIBCPP_STD_FLAGS "none" CACHE FORCE STRING "")
endif()
endif()

# Build type
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
if (FLIBCPP_DEV)
set(_CMAKE_BUILD_TYPE "Debug")
Expand All @@ -38,9 +57,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "${_CMAKE_BUILD_TYPE}" CACHE STRING "Build type" FORCE)
endif()

set(FLIBCPP_FORTRAN_STD "f2003" CACHE STRING
"Fortran standard for compiling generated code")

#---------------------------------------------------------------------------#
# MODULES TO LOAD
#---------------------------------------------------------------------------#
Expand Down Expand Up @@ -100,7 +116,6 @@ else()
endif()
endif()


set(FLIBCPP_VERSION_CPP "${CMAKE_CURRENT_BINARY_DIR}/flibcpp_version.cpp")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/flibcpp_version.cpp.in"
"${FLIBCPP_VERSION_CPP}" @ONLY)
Expand Down Expand Up @@ -166,11 +181,9 @@ function(flibcpp_add_module name)
PRIVATE
cxx_std_11
)

if (FLIBCPP_FORTRAN_STD AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
# Compile Fortran code with given standard
if (_FLIBCPP_STD_FLAGS)
target_compile_options(${name}
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>:-std=${FLIBCPP_FORTRAN_STD}>
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>:${_FLIBCPP_STD_FLAGS}>
)
endif()

Expand Down

0 comments on commit c082b7f

Please sign in to comment.