Skip to content

Commit 1f19ade

Browse files
authored
PCBC-972: fix C++ detection on MacOS X (#145)
1 parent 2673a49 commit 1f19ade

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

config.m4

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,30 @@ AC_SUBST(PHP_COUCHBASE)
77

88
if test "$PHP_COUCHBASE" != "no"; then
99
PHP_REQUIRE_CXX
10+
11+
# PHP_REQUIRE_CXX macro might incorrectly format CXX variable,
12+
# concatenating standard selection flags directly to the path,
13+
# instead of using CXXFLAGS. Let's try to fix this issue.
14+
AC_CHECK_FILE([$CXX], [CXX_PATH=$CXX], [CXX_PATH=no])
15+
if test "$CXX_PATH" = "no"; then
16+
AC_MSG_NOTICE([PHP suggested C++ compiler, which includes flags "$CXX", trying to strip them])
17+
# Remove extra flags (considering flags are separated by spaces)
18+
CXX_PATH=$(echo "$CXX" | cut -d' ' -f1)
19+
AC_CHECK_FILE([$CXX_PATH], [], [CXX_PATH=no])
20+
# If a valid path is found, update CXX
21+
if test "$CXX_PATH" == "no"; then
22+
AC_MSG_NOTICE([Unable to locate path to C++ compiler, falling back to "c++"])
23+
AC_SUBST([CXX_PATH], [c++])
24+
fi
25+
fi
26+
AC_MSG_NOTICE([Detected C++ compiler: $CXX_PATH])
27+
1028
AC_PATH_PROG(CMAKE, cmake, no)
1129
if ! test -x "${CMAKE}"; then
1230
AC_MSG_ERROR(Please install cmake to build couchbase extension)
1331
fi
1432

33+
CXX="${CXX_PATH}"
1534
CXXFLAGS="${CXXFLAGS} -std=c++17"
1635
COUCHBASE_CMAKE_SOURCE_DIRECTORY="$srcdir/src"
1736
COUCHBASE_CMAKE_BUILD_DIRECTORY="$ac_pwd/cmake-build"

0 commit comments

Comments
 (0)