Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCBC-972: fix C++ detection on MacOS X #145

Merged
merged 1 commit into from Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions config.m4
Expand Up @@ -7,11 +7,30 @@ AC_SUBST(PHP_COUCHBASE)

if test "$PHP_COUCHBASE" != "no"; then
PHP_REQUIRE_CXX

# PHP_REQUIRE_CXX macro might incorrectly format CXX variable,
# concatenating standard selection flags directly to the path,
# instead of using CXXFLAGS. Let's try to fix this issue.
AC_CHECK_FILE([$CXX], [CXX_PATH=$CXX], [CXX_PATH=no])
if test "$CXX_PATH" = "no"; then
AC_MSG_NOTICE([PHP suggested C++ compiler, which includes flags "$CXX", trying to strip them])
# Remove extra flags (considering flags are separated by spaces)
CXX_PATH=$(echo "$CXX" | cut -d' ' -f1)
AC_CHECK_FILE([$CXX_PATH], [], [CXX_PATH=no])
# If a valid path is found, update CXX
if test "$CXX_PATH" == "no"; then
AC_MSG_NOTICE([Unable to locate path to C++ compiler, falling back to "c++"])
AC_SUBST([CXX_PATH], [c++])
fi
fi
AC_MSG_NOTICE([Detected C++ compiler: $CXX_PATH])

AC_PATH_PROG(CMAKE, cmake, no)
if ! test -x "${CMAKE}"; then
AC_MSG_ERROR(Please install cmake to build couchbase extension)
fi

CXX="${CXX_PATH}"
CXXFLAGS="${CXXFLAGS} -std=c++17"
COUCHBASE_CMAKE_SOURCE_DIRECTORY="$srcdir/src"
COUCHBASE_CMAKE_BUILD_DIRECTORY="$ac_pwd/cmake-build"
Expand Down