From 01b4c03a847daf85fdb6330aa168608acdab4d92 Mon Sep 17 00:00:00 2001 From: Waf Project Date: Fri, 12 Jan 2024 14:08:12 +0100 Subject: [PATCH] Improve Qt6 detection with msvc --- waflib/Tools/qt5.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/waflib/Tools/qt5.py b/waflib/Tools/qt5.py index 0932e943..6cfc4271 100644 --- a/waflib/Tools/qt5.py +++ b/waflib/Tools/qt5.py @@ -530,13 +530,20 @@ def configure(self): Logs.error('No xml.sax support was found, rcc dependencies will be incomplete!') feature = 'qt6' if self.want_qt6 else 'qt5' - # Qt6 requires C++17 (https://www.qt.io/blog/qt-6.0-released) - stdflag = '-std=c++17' if self.want_qt6 else '-std=c++11' # Qt5 may be compiled with '-reduce-relocations' which requires dependent programs to have -fPIE or -fPIC? frag = '#include \nint main(int argc, char **argv) {QMap m;return m.keys().size();}\n' uses = 'QT6CORE' if self.want_qt6 else 'QT5CORE' - for flag in [[], '-fPIE', '-fPIC', stdflag, [stdflag, '-fPIE'], [stdflag, '-fPIC']]: + + # Qt6 requires C++17 (https://www.qt.io/blog/qt-6.0-released) + flag_list = [] + if self.env.CXX_NAME == 'msvc': + stdflag = '/std:c++17' if self.want_qt6 else '/std:c++11' + flag_list = [[], ['/Zc:__cplusplus', '/permissive-', stdflag]] + else: + stdflag = '-std=c++17' if self.want_qt6 else '-std=c++11' + flag_list = [[], '-fPIE', '-fPIC', stdflag, [stdflag, '-fPIE'], [stdflag, '-fPIC']] + for flag in flag_list: msg = 'See if Qt files compile ' if flag: msg += 'with %s' % flag