make it possible to toggle fortran support
This commit is contained in:
parent
c75a3bb439
commit
cb3a0a5249
@ -8,6 +8,7 @@
|
||||
# Variables used::
|
||||
#
|
||||
# EXTRA_FCFLAGS
|
||||
# ENABLE_FC_SUPPORT
|
||||
#
|
||||
# Variables defined::
|
||||
#
|
||||
@ -17,6 +18,10 @@
|
||||
#
|
||||
# CMAKE_Fortran_FLAGS
|
||||
#
|
||||
# Variables set::
|
||||
#
|
||||
# ENABLE_FC_SUPPORT
|
||||
#
|
||||
# Environment variables used::
|
||||
#
|
||||
# FCFLAGS
|
||||
@ -27,26 +32,32 @@
|
||||
# source: https://github.com/scisoft/autocmake/raw/master/modules/fc.cmake
|
||||
# docopt: --fc=<FC> Fortran compiler [default: gfortran].
|
||||
# --extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: ''].
|
||||
# --fc-support=<FC_SUPPORT> Toggle Fortran language support (ON/OFF) [default: ON].
|
||||
# export: 'FC=%s' % arguments['--fc']
|
||||
# define: '-DEXTRA_FCFLAGS="%s"' % arguments['--extra-fc-flags']
|
||||
# '-DENABLE_FC_SUPPORT="%s"' % arguments['--fc-support']
|
||||
|
||||
enable_language(Fortran)
|
||||
option(ENABLE_FC_SUPPORT "Enable Fortran language support" ON)
|
||||
|
||||
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/include/fortran)
|
||||
if(ENABLE_FC_SUPPORT)
|
||||
enable_language(Fortran)
|
||||
|
||||
if(NOT DEFINED CMAKE_Fortran_COMPILER_ID)
|
||||
message(FATAL_ERROR "CMAKE_Fortran_COMPILER_ID variable is not defined!")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_Fortran_COMPILER_WORKS)
|
||||
message(FATAL_ERROR "CMAKE_Fortran_COMPILER_WORKS is false!")
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTRA_FCFLAGS)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${EXTRA_FCFLAGS}")
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{FCFLAGS})
|
||||
message(STATUS "FCFLAGS is set to '$ENV{FCFLAGS}'.")
|
||||
set(CMAKE_Fortran_FLAGS "$ENV{FCFLAGS}")
|
||||
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/include/fortran)
|
||||
|
||||
if(NOT DEFINED CMAKE_Fortran_COMPILER_ID)
|
||||
message(FATAL_ERROR "CMAKE_Fortran_COMPILER_ID variable is not defined!")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_Fortran_COMPILER_WORKS)
|
||||
message(FATAL_ERROR "CMAKE_Fortran_COMPILER_WORKS is false!")
|
||||
endif()
|
||||
|
||||
if(DEFINED EXTRA_FCFLAGS)
|
||||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${EXTRA_FCFLAGS}")
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{FCFLAGS})
|
||||
message(STATUS "FCFLAGS is set to '$ENV{FCFLAGS}'.")
|
||||
set(CMAKE_Fortran_FLAGS "$ENV{FCFLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user