Mercurial > octave
changeset 32367:aeed7db02016
build: Move check for C++ compiler capabilities closer to the start.
* configure.ac: Check for the supported C++ standard versions at the beginning
of the configuration. Check for C++17 support unless configured to build without
GUI or with Qt5. Don't try to build with Qt6 if compiler doesn't support C++17.
* m4/acinclude.m4 (OCTAVE_CHECK_QT_VERSION): Don't check for Qt6 if compiler
doesn't support C++17.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 02 Oct 2023 15:00:35 +0200 |
parents | e3c66ad99652 |
children | e0a6dd4f6fef |
files | configure.ac m4/acinclude.m4 |
diffstat | 2 files changed, 81 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Sun Oct 01 17:56:33 2023 +0200 +++ b/configure.ac Mon Oct 02 15:00:35 2023 +0200 @@ -300,7 +300,7 @@ AC_DEFINE_UNQUOTED([SHELL_PATH], ["$SHELL_PATH"], [Define this to be the path to the shell command interpreter.]) -### Determine which C++ compiler to use (we expect to find g++). +### Determine which C++ compiler to use (we expect to find g++ or clang++). AC_PROG_CXX AC_PROG_CXXCPP @@ -315,15 +315,45 @@ *) AC_MSG_ERROR([bad value $enableval for --enable-std-pmr-polymorphic-allocator]) ;; esac]) -### Determine compiler capabilities. - -if test $ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR = yes; then - ## Test for flags to fully support C++17. - ## Preferably with GNU extensions if flags are required. +AC_ARG_WITH([qt], + [AS_HELP_STRING([--with-qt=VER], [use the Qt major version VER]) +dnl Second help string must not be indented for correct alignment +AS_HELP_STRING([--without-qt], [don't use Qt libraries, disable Qt GUI])], + [case $withval in + yes | "") + ;; + no) + QT_VERSIONS= + ;; + *) + QT_VERSIONS="$withval" + ;; + esac]) + +### Determine C++ compiler capabilities. + +if test "$QT_VERSIONS" = 6; then + ## If QT_VERSIONS is set to 6, require that the C++ compiler fully + ## supports C++17. Preferably with GNU extensions if flags are required. + ## We could use "AX_CXX_COMPILE_STDCXX(17, [], mandatory)" in this case. + ## But prefer to emit a more helpful error message. + AX_CXX_COMPILE_STDCXX(17, [], []) + if test "$HAVE_CXX17" = 0; then + ## The user explicitly requested Qt6. But the C++ compiler lacks + ## support for C++17. + AC_MSG_ERROR([Qt6 requires a compiler that supports C++17. Configure with "--with-qt=5" or "--without-qt", or use a compiler that supports C++17.]) + fi +elif test -z "${QT_VERSIONS+x}" || test $ENABLE_STD_PMR_POLYMORPHIC_ALLOCATOR = yes; then + ## If QT_VERSIONS is not explicitly set, check if the C++ compiler fully + ## supports C++17 (but don't require it). + ## The defaults for the Qt version will depend on the result of this check. AX_CXX_COMPILE_STDCXX(17, [], []) else + ## Set HAVE_CXX17 to 0 because we don't require it (even if the used + ## C++ compiler might technically support C++17). HAVE_CXX17=0 fi + if test "$HAVE_CXX17" = 0; then ## Ensure that the C++ compiler fully supports C++11. ## Preferably with GNU extensions if flags are required. @@ -334,7 +364,7 @@ OCTAVE_CHECK_STD_PMR_POLYMORPHIC_ALLOCATOR fi -### Determine which C compiler to use (we expect to find gcc). +### Determine which C compiler to use (we expect to find gcc or clang). AC_PROG_CC AC_PROG_CPP @@ -1871,22 +1901,15 @@ ### GUI/Qt related tests. -QT_VERSIONS="6 5" - -AC_ARG_WITH([qt], - [AS_HELP_STRING([--with-qt=VER], [use the Qt major version VER]) -dnl Second help string must not be indented for correct alignment -AS_HELP_STRING([--without-qt], [don't use Qt libraries, disable Qt GUI])], - [case $withval in - yes | "") - ;; - no) - QT_VERSIONS= - ;; - *) - QT_VERSIONS="$withval" - ;; - esac]) +if test -z ${QT_VERSIONS+x}; then + ## If QT_VERSIONS is unset, choose default depending on compiler support. + if test $HAVE_CXX17 = 0; then + dnl Qt6 requires support for C++17. + QT_VERSIONS="5" + else + QT_VERSIONS="6 5" + fi +fi check_qscintilla=yes AC_ARG_WITH([qscintilla],
--- a/m4/acinclude.m4 Sun Oct 01 17:56:33 2023 +0200 +++ b/m4/acinclude.m4 Mon Oct 02 15:00:35 2023 +0200 @@ -2002,30 +2002,41 @@ warn_qt_abstract_item_model="" warn_qt_opengl="" - ## Check for Qt libraries - case "$qt_version" in - 5) - QT_MODULES="Qt5Core Qt5Gui Qt5Help Qt5Network Qt5OpenGL Qt5PrintSupport Qt5Xml" - ;; - 6) - QT_MODULES="Qt6Core Qt6Gui Qt6Help Qt6Network Qt6OpenGL Qt6OpenGLWidgets Qt6PrintSupport Qt6Xml" - case $host_os in - mingw* | msdosmsvc*) - ;; - *) - # FIXME: Remove Qt6Core5Compat when we no longer rely on classes that - # have been removed in Qt6: - # https://www.qt.io/blog/porting-from-qt-5-to-qt-6-using-qt5compat-library - # It is still needed for the terminal implementation in - # libgui/qterminal/libqterminal/unix - QT_MODULES="$QT_MODULES Qt6Core5Compat" - ;; - esac - ;; - *) - AC_MSG_ERROR([Unrecognized Qt version $qt_version]) - ;; - esac + if test $build_qt_gui = yes && test "$qt_version" -eq 6; then + ## Ensure that the C++ compiler fully supports C++17. + ## Preferably with GNU extensions if flags are required. + if test $HAVE_CXX17 -eq 0; then + build_qt_gui=no + warn_qt_cxx17="compiler doesn't support C++17; disabling Qt GUI" + fi + fi + + if test $build_qt_gui = yes; then + ## Check for Qt libraries + case "$qt_version" in + 5) + QT_MODULES="Qt5Core Qt5Gui Qt5Help Qt5Network Qt5OpenGL Qt5PrintSupport Qt5Xml" + ;; + 6) + QT_MODULES="Qt6Core Qt6Gui Qt6Help Qt6Network Qt6OpenGL Qt6OpenGLWidgets Qt6PrintSupport Qt6Xml" + case $host_os in + mingw* | msdosmsvc*) + ;; + *) + # FIXME: Remove Qt6Core5Compat when we no longer rely on classes that + # have been removed in Qt6: + # https://www.qt.io/blog/porting-from-qt-5-to-qt-6-using-qt5compat-library + # It is still needed for the terminal implementation in + # libgui/qterminal/libqterminal/unix + QT_MODULES="$QT_MODULES Qt6Core5Compat" + ;; + esac + ;; + *) + AC_MSG_ERROR([Unrecognized Qt version $qt_version]) + ;; + esac + fi if test $build_qt_gui = yes; then ## Use this check to get info in the log file. @@ -2192,16 +2203,6 @@ esac fi - if test $build_qt_gui = yes && test "$qt_version" -eq 6; then - ## Ensure that the C++ compiler fully supports C++17. - ## Preferably with GNU extensions if flags are required. - AX_CXX_COMPILE_STDCXX(17, [], optional) - if test $HAVE_CXX17 -eq 0; then - build_qt_gui=no - warn_qt_cxx17="compiler doesn't support C++17; disabling Qt GUI" - fi - fi - if test $build_qt_gui = yes; then ## We have what we need to build the Qt GUI. The remaining ## checks below are for optional features related to the Qt GUI.