Skip to content

Commit 2abbecd

Browse files
committed
Use compiler's companion preprocessor w/ FORD
Fixes #205
1 parent 48c096a commit 2abbecd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ if ( NOT SKIP_DOC_GEN )
163163
else ()
164164
set ( MACRO_FLAG "" )
165165
endif ()
166+
# Pick the preprocessor to use based on the Fortran compiler
167+
if ( "${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel" )
168+
set ( FPP "fpp\n" )
169+
else ()
170+
set ( FPP "gfortran -E\n" ) # default to gfortran -E for gfortran and unsupported compilers
171+
endif ()
172+
file ( WRITE "${CMAKE_BINARY_DIR}/preprocessor-def.md" "${FPP}" )
166173
# Dynamically generate the FORD outputs list
167174
message ( STATUS "Dynamically computing FORD output information..." )
168175
if ( NOT (DEFINED FORD_OUTPUTS_CACHED) )

build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ BINDIR='./bin/' # build directory for unit tests
7878
LIBDIR='./lib/' # build directory for library
7979
MODCODE='json_module.F90' # json module file name
8080
LIBOUT='libjsonfortran.a' # name of json library
81-
81+
FPP="gfortran -E" # default to gfortran -E pre-processing
8282

8383
# The following warning might be triggered by ifort unless explicitly silenced:
8484
# warning #7601: F2008 standard does not allow an internal procedure to be an actual argument procedure name. (R1214.4).
@@ -122,18 +122,21 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
122122
intel|Intel|INTEL|ifort)
123123
FCOMPILER='Intel'
124124
FCOMPILERFLAGS="$INTELCOMPILERFLAGS"
125+
FPP="fpp"
125126
shift
126127
;;
127128
gnu|Gnu|GNU|gfortran|Gfortran|GFortran|GFORTRAN)
128129
FCOMPILER='gnu'
129130
FCOMPILERFLAGS="$GNUCOMPILERFLAGS"
131+
FPP="gfortran -E"
130132
shift
131133
;;
132134
*)
133135
FCOMPILER="custom"
134136
echo "Warning: Trying to build with unsupported compiler, $2." 1>&2
135137
echo "Please ensure you set appropriate --cflags and (single) quote them" 1>&2
136138
FC="$2"
139+
FPP="gfortran -E" # try gfortran to preprocess as a default
137140
shift
138141
;;
139142
esac
@@ -344,6 +347,7 @@ if [[ $JF_SKIP_DOCS != [yY]* ]]; then
344347
if hash ford 2>/dev/null; then
345348
echo "Building documentation..."
346349
[[ $TRY_UNICODE = [yY]* ]] && MACRO_FLAG=("-m" "USE_UCS4")
350+
echo "$FPP" > preprocessor-def.md # Override via include in project file, until FORD gets CLI for this
347351
ford --debug "${MACRO_FLAG[@]}" -p "$PAGESDIR" "$FORDMD"
348352
else
349353
echo "FORD not found! Install using: sudo pip install ford"

0 commit comments

Comments
 (0)