Merge pull request #330 from rolk/330_underscore

Simplify creation of Fortran function wrappers
This commit is contained in:
Bård Skaflestad 2013-08-23 11:43:48 -07:00
commit 089e755735
2 changed files with 24 additions and 1 deletions

View File

@ -39,6 +39,16 @@ function (define_fc_func verb file)
# the interaction -- don't load the Fortran compiler just to write
# this macro (which apparently nobody uses then)
if (needed)
# if this option is enabled, we skip detecting the Fortran externals
# using a real compiler (which may not be the same that compiled the
# library) and just write a macro that uses a single underscore (which
# is the assumption that FindLAPACK operates on anyway)
option (USE_UNDERSCORING "Assume that Fortran routines have underscore suffix" OFF)
if (USE_UNDERSCORING)
message (STATUS "Assuming Fortran externals have underscore suffix")
set (_str "#define FC_FUNC(name,NAME) name##_\n")
else (USE_UNDERSCORING)
# enable languages needed
if (NOT CMAKE_C_COMPILER_LOADED)
enable_language (C)
@ -65,6 +75,8 @@ function (define_fc_func verb file)
# massage it to look like the one AC_FC_WRAPPERS provide
string (REPLACE "FortranCInterface_GLOBAL" "FC_FUNC" _str ${_str})
endif (USE_UNDERSCORING)
# write this definition to the end of our own configuration file
file (${verb} ${file}
"\n/* Define to a macro mangling the given C identifier (in lower and upper

View File

@ -30,7 +30,9 @@ Optional Features:
--enable-parallel process in parallel using MPI [default=no]
--enable-openmp activate experimental support for OpenMP
--disable-option-checking ignore unrecognized --enable/--with options
--enable-underscoring assume Fortran routines have _ suffix [default=no]
--enable-ninja use Ninja build generator [default=no]
(automatically implies --enable-underscoring)
Optional Packages:
--with-alugrid=PATH use the ALUGrid library from a specified location
@ -116,6 +118,8 @@ use_tests=
use_samples=
#use_ninja="-G\"Unix Makefiles\" "
use_ninja=
#use_underscoring=" -DUSE_UNDERSCORING=OFF"
use_underscoring=
# default is to warn for unknown options, but this can be disabled
option_check=yes
@ -348,7 +352,14 @@ for OPT in "$@"; do
use_samples=" -DBUILD_EXAMPLES=ON"
pkgname=""
;;
underscoring)
use_underscoring=" -DUSE_UNDERSCORING=ON"
pkgname=""
;;
ninja)
# Ninja doesn't support using the Fortran compiler, so
# we'll have to resort to making this assumption
use_underscoring=" -DUSE_UNDERSCORING=ON"
use_ninja="-GNinja "
pkgname=""
;;
@ -400,7 +411,7 @@ for a in "${VARS[@]}"; do
done
# pass everything on to CMake
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" ${use_ninja}\"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${use_runpath}${use_tests}${use_samples} ${FEATURES}"
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" ${use_ninja}\"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${use_runpath}${use_tests}${use_samples}${use_underscoring} ${FEATURES}"
echo --- calling CMake ---
echo ${CMDLINE}
eval exec ${CMDLINE}