Skip to content

Commit

Permalink
Linux: build using C++17?
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Jan 8, 2024
1 parent c6b3d13 commit ddbf64d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions platform/unix/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ includes=
AC_DEFUN([LOVE_MSG_ERROR],
[AC_MSG_ERROR([LÖVE needs "$1"[,] please install "$1" with development files and try again])])

# C++14 support in cpp14.m4
ACLOVE_CPP14_TEST
# C++17 support in cpp14.m4
ACLOVE_CPP17_TEST

# Add -fvisibility=hidden and -fvisibility-inlines-hidden
CFLAGS="-fvisibility=hidden $CFLAGS"
Expand Down
52 changes: 26 additions & 26 deletions platform/unix/cpp14.m4
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,47 @@ AC_DEFUN([ACLOVE_GET_CLANG_VERSION], [
AC_COMPUTE_INT(aclove_clang_version_patch, __clang_patchlevel__,, aclove_clang_version_found="no")
])

AC_DEFUN([ACLOVE_CPP14_TEST_FLAG], [
aclove_cpp14_test_cxx14name="no"
ACLOVE_CXX_FLAG_TEST([-std=c++14], aclove_cpp14_test_cxx14name="c++14", [])
AS_VAR_IF([aclove_cpp14_test_cxx14name], [no],
[AC_MSG_ERROR([LÖVE needs a C++ compiler with C++14 support])],
[CXXFLAGS="$CXXFLAGS -std=$aclove_cpp14_test_cxx14name"])
AC_DEFUN([ACLOVE_CPP17_TEST_FLAG], [
aclove_cpp17_test_cxx17name="no"
ACLOVE_CXX_FLAG_TEST([-std=c++17], aclove_cpp17_test_cxx14name="c++17", [])
AS_VAR_IF([aclove_cpp17_test_cxx17name], [no],
[AC_MSG_ERROR([LÖVE needs a C++ compiler with C++17 support])],
[CXXFLAGS="$CXXFLAGS -std=$aclove_cpp17_test_cxx17name"])
])

AC_DEFUN([ACLOVE_CPP14_CHECK_VERSION], [ dnl compiler, targetmajor, targetminor, on-failure
aclove_cpp14_check_version_status="no"
AC_DEFUN([ACLOVE_CPP17_CHECK_VERSION], [ dnl compiler, targetmajor, targetminor, on-failure
aclove_cpp17_check_version_status="no"
AC_MSG_CHECKING([whether $1 version is at least $2.$3])
AS_IF([test "$aclove_[]$1[]_version_major" -gt $2], aclove_cpp14_check_version_status="yes")
AS_IF([test "$aclove_[]$1[]_version_major" -eq $2 && test "$aclove_[]$1[]_version_minor" -ge $3], aclove_cpp14_check_version_status="yes")
AC_MSG_RESULT([$aclove_cpp14_check_version_status])
AS_VAR_IF([aclove_cpp14_check_version_status], [no],
AS_IF([test "$aclove_[]$1[]_version_major" -gt $2], aclove_cpp17_check_version_status="yes")
AS_IF([test "$aclove_[]$1[]_version_major" -eq $2 && test "$aclove_[]$1[]_version_minor" -ge $3], aclove_cpp17_check_version_status="yes")
AC_MSG_RESULT([$aclove_cpp17_check_version_status])
AS_VAR_IF([aclove_cpp17_check_version_status], [no],
[$4])
])

AC_DEFUN([ACLOVE_CPP14_TEST_VERSION_GCC], [
ACLOVE_CPP14_CHECK_VERSION([gcc], 4, 9,
[AC_MSG_ERROR([LÖVE needs a GCC version of at least 4.9])])
AC_DEFUN([ACLOVE_CPP17_TEST_VERSION_GCC], [
ACLOVE_CPP17_CHECK_VERSION([gcc], 9, 0,
[AC_MSG_ERROR([LÖVE needs a GCC version of at least 9.0])])
])

AC_DEFUN([ACLOVE_CPP14_TEST_VERSION_CLANG], [
ACLOVE_CPP14_CHECK_VERSION([clang], 3, 4,
[AC_MSG_ERROR([LÖVE needs a clang version of at least 3.4])])
AC_DEFUN([ACLOVE_CPP17_TEST_VERSION_CLANG], [
ACLOVE_CPP17_CHECK_VERSION([clang], 5, 0,
[AC_MSG_ERROR([LÖVE needs a clang version of at least 5.0])])
])

AC_DEFUN([ACLOVE_CPP14_TEST], [
ACLOVE_CPP14_TEST_FLAG
AC_DEFUN([ACLOVE_CPP17_TEST], [
ACLOVE_CPP17_TEST_FLAG
ACLOVE_GET_GCC_VERSION
ACLOVE_GET_CLANG_VERSION
# Since clang also sets gcc headers, check clang after
aclove_cpp14_test_compiler="unknown"
AS_VAR_IF([aclove_gcc_version_found], [yes], aclove_cpp14_test_compiler="gcc")
AS_VAR_IF([aclove_clang_version_found], [yes], aclove_cpp14_test_compiler="clang")
aclove_cpp17_test_compiler="unknown"
AS_VAR_IF([aclove_gcc_version_found], [yes], aclove_cpp17_test_compiler="gcc")
AS_VAR_IF([aclove_clang_version_found], [yes], aclove_cpp17_test_compiler="clang")
AS_CASE([$aclove_cpp14_test_compiler],
[gcc], [ACLOVE_CPP14_TEST_VERSION_GCC],
[clang], [ACLOVE_CPP14_TEST_VERSION_CLANG],
AS_CASE([$aclove_cpp17_test_compiler],
[gcc], [ACLOVE_CPP17_TEST_VERSION_GCC],
[clang], [ACLOVE_CPP17_TEST_VERSION_CLANG],
[AC_MSG_WARN([Could not determine compiler version])])
])

0 comments on commit ddbf64d

Please sign in to comment.