Skip to content

Commit e65bf47

Browse files
committed
Added a configure option --with-pkg-config which enables use of pkg-config to aid in the configuration
The spdlog dependency does not propagate its compile flags through config.h in the usual way, causing build failure of the AD when built with spack. When pkg-config is enabled, the configure script now queries that tool for the flags.
1 parent 0caa958 commit e65bf47

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

configure.ac

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@ AC_PROG_CXX
66
AM_PROG_AR
77
LT_INIT
88

9+
#Enable pkg-config
10+
AC_ARG_WITH([pkg-config], AS_HELP_STRING([--with-pkg-config], [Use pkg-config to determine configuration of some dependencies]),[use_pkgconfig="yes"],[use_pkgconfig="no"])
11+
12+
#Check if pkg-config is installed
13+
no_pkgconfig=1
14+
if test "x$use_pkgconfig" != "xno"; then
15+
no_pkgconfig=$(echo $(pkg-config 2>&1) | grep -c "not found")
16+
if [[ "${no_pkgconfig}" -eq 0 ]]; then
17+
AC_MSG_NOTICE([pkg-config was detected])
18+
fi
19+
fi
20+
21+
#spdlog propagates its compile flags through cmake targets and pkg-config but doesn't for autotools
22+
#thus if pkg-config is available we try to get the flags there
23+
if [[ "${no_pkgconfig}" -eq 0 ]]; then
24+
SPDLOG_CFLAGS=$(pkg-config --cflags spdlog 2>&1)
25+
if [[ $(echo ${SPDLOG_CFLAGS} | grep -c "not found") -eq 1 ]]; then
26+
AC_MSG_FAILURE(["Cannot find spdlog configuration with pkg-config"])
27+
fi
28+
CXXFLAGS+="${SPDLOG_CFLAGS}"
29+
SPDLOG_LDFLAGS=$(pkg-config --libs spdlog 2>&1)
30+
LDFLAGS+="${SPDLOG_LDFLAGS}"
31+
AC_MSG_NOTICE([Retrieved configuration for spdlog from pkg-config])
32+
fi
33+
34+
935
# Check if compiling to generate a coverage report using gcov
1036
# Once built, run the tests in the install/test directory, then from the build directory run
1137
#(pip3 install gcovr)

0 commit comments

Comments
 (0)