Skip to content

Commit 5fc8ca9

Browse files
committed
Prevent caf script to check for caf_mpi_static when -cpp is specified.
1 parent 53f4d2c commit 5fc8ca9

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

src/script-templates/caf.in

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,13 @@ __caf_err_report() {
161161
trap '__caf_err_report "${FUNCNAME:-.}" ${LINENO}' ERR
162162

163163
# See if we are compiling or compiling and/or linking
164-
__only_compiling () {
165-
for arg in "${@}"; do
166-
if [[ "${arg}" == "-c" ]]; then
167-
return 0
168-
fi
169-
done
170-
return 1
171-
}
164+
with_link="true"
165+
for arg in "${@}"; do
166+
if [[ "${arg}" == "-c" || "${arg}" == "-cpp" ]]; then
167+
with_link="false"
168+
break
169+
fi
170+
done
172171

173172
#--------------------------------------------------------------------------
174173
# End configured variables, now process them and build compile/link command
@@ -223,16 +222,14 @@ if [[ -n "${mpi_compile_flags[*]:-}" ]]; then
223222
caf_pre_flags+=("${compileflag}")
224223
done
225224
fi
226-
if [[ -n "${mpi_link_flags[*]:-}" ]]; then
227-
if ! __only_compiling "${@}"; then
228-
for linkflag in "${mpi_link_flags[@]:-}"; do
229-
caf_pre_flags+=("${linkflag}")
230-
done
231-
fi
225+
if [[ -n "${mpi_link_flags[*]:-}" && "${with_link}" == "true" ]]; then
226+
for linkflag in "${mpi_link_flags[@]:-}"; do
227+
caf_pre_flags+=("${linkflag}")
228+
done
232229
fi
233230

234231
# Now do libraries, IN CORRECT ORDER, to append to command
235-
if [[ -n "${caf_libs[*]:-}" ]]; then
232+
if [[ "${with_link}" == "true" && -n "${caf_libs[*]:-}" ]]; then
236233
for lib in "${caf_libs[@]:-}"; do
237234
caf_added_libs+=("$(substitute_lib "${prefix%/}/${lib}")")
238235
done
@@ -242,7 +239,7 @@ if [[ -n "${threads_lib}" ]]; then
242239
caf_added_libs+=("${threads_lib}")
243240
fi
244241

245-
if [[ -n "${mpi_libs[*]:-}" ]]; then
242+
if [[ "${with_link}" == "true" && -n "${mpi_libs[*]:-}" ]]; then
246243
for lib in "${mpi_libs[@]:-}"; do
247244
caf_added_libs+=("$(substitute_lib "${lib}")")
248245
done
@@ -330,10 +327,8 @@ elif [[ ${1} == '-s' || ${1} == '--show' || ${1} == '-show' ]]; then
330327
if [[ "${args}" ]]; then
331328
compiler_args+=("${args}")
332329
fi
333-
if [[ "${caf_added_libs[*]:-}" ]]; then
334-
if ! __only_compiling "${@}"; then
335-
compiler_args+=("${caf_added_libs[@]}")
336-
fi
330+
if [[ "${caf_added_libs[*]:-}" && "${with_link}" == "true" ]]; then
331+
compiler_args+=("${caf_added_libs[@]}")
337332
fi
338333
echo "${cafc}" "${compiler_args[@]}"
339334
exit 0
@@ -365,10 +360,8 @@ fi
365360
if [[ "${*:-}" ]]; then
366361
compiler_args+=("${@}")
367362
fi
368-
if [[ "${caf_added_libs[*]:-}" ]]; then
369-
if ! __only_compiling "${@}" ; then
370-
compiler_args+=("${caf_added_libs[@]}")
371-
fi
363+
if [[ "${caf_added_libs[*]:-}" && "${with_link}" == "true" ]]; then
364+
compiler_args+=("${caf_added_libs[@]}")
372365
fi
373366
#set -o xtrace # Show what we're doing
374367
set +o errtrace

0 commit comments

Comments
 (0)