Reputation: 1151
I'm writing a configure.ac
script for a library which has a few dependencies. One of the dependencies is a library which requires MPI.
I'm using a macro to detect the availability of MPI and use it's variable definitions to change the C++ compiler to the associated MPI wrapper. Unfortunately, this is not reflected completely when I perform an AC_CHECK_HEADER
; the compiler test works fine, but the preprocessor test fails.
failure in config.log
(notice the preprocessor test uses g++
instead of mpic++
):
configure:17591: checking for mpic++
configure:17607: found /opt/apps/gcc4_7/mvapich2-x/2.0.0/bin/mpic++
configure:17618: result: mpic++
configure:17636: checking for MPI_Init
configure:17636: mpic++ -o conftest -g -O2 -std=c++11 conftest.cpp >&5
configure:17636: $? = 0
configure:17636: result: yes
configure:17729: checking for mpi.h
configure:17742: mpic++ -c -g -O2 conftest.cpp >&5
configure:17742: $? = 0
configure:17743: result: yes
configure:17781: checking mylibrary.h usability
configure:17781: mpic++ -c -g -O2 -I./mylibrary/include -std=c++11 conftest.cpp >&5
configure:17781: $? = 0
configure:17781: result: yes
configure:17781: checking mylibrary.h presence
configure:17781: g++ -E -I./mylibrary/include -std=c++11 conftest.cpp
In file included from ./mylibrary/include/mylibrary.h:4,
from conftest.cpp:26:
./mylibrary/include/mylibrary.h:4:17: fatal error: mpi.h: No such file or directory
configure.ac
associated section:
...
ACX_MPI([], [AC_MSG_ERROR([Cannot find an MPI C++ compiler wrapper.])])
CXX="$MPICXX"
LIBS="$MPILIBS $LIBS"
CPPFLAGS="-I$with_mylibrary_path/include $CPPFLAGS"
AC_CHECK_HEADER([mylibrary.h], [], [works=no]
...
Now the configure only throws a warning, and proceeds with the compiler's results, but I'm pedantic and want to solve this issue so that my users don't think it's an issue with their system, build setup, etc.
I've looked around, and haven't found a way to reset the preprocessor command for this to work. Am I missing something?
Upvotes: 0
Views: 191
Reputation: 16315
You could try taking the advice of the authors of ACX_MPI
and use AC_TRY_COMPILE
instead...
dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
dnl latter uses $CPP, not $CC (which may be mpicc).
BTW The AX_MPI
macro seems to be a more updated (but not that different) version of ACX_MPI
.
Upvotes: 2
Reputation: 1151
Apparently CXXCPP
is used as the command to run the C++ preprocessor compiler (source), so I modified my configure script:
...
ACX_MPI([], [AC_MSG_ERROR([Cannot find an MPI C++ compiler wrapper.])])
CXX="$MPICXX"
CXXCPP="$CXX -E"
LIBS="$MPILIBS $LIBS"
CPPFLAGS="-I$with_mylibrary_path/include $CPPFLAGS"
AC_CHECK_HEADER([mylibrary.h], [], [works=no]
...
and the warning is gone.
Upvotes: 0