-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
Describe the bug
When using qmake, QT_DEBUG or QT_NO_DEBUG is defined depending on whether the build is a release or debug build. Meson does not do so, so QT_DEBUG is always defined by a qt header.
To Reproduce
meson.build
project('repro', 'cpp')
qt6 = dependency('qt6', modules: ['Core'])
executable('helloworld', 'main.cpp', dependencies: [qt6])
repro.pro
SOURCES += main.cpp
TARGET = helloworld
main.cpp
#include <QtGlobal>
int main() {
#ifdef QT_DEBUG
qWarning("QT_DEBUG is defined");
#else
qWarning("QT_DEBUG is not defined");
#endif
return 0;
}
with qmake in debug mode, QT_DEBUG is defined:
rm -f .qmake.stash Makefile helloworld main.o && qmake6 -o Makefile repro.pro CONFIG+=debug && make && ./helloworld
Info: creating stash file /home/gglrc/third_parties/repro_qt_meson/.qmake.stash
g++ -c -pipe -g -Wall -Wextra -fPIC -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -I. -I/usr/include/x86_64-linux-gnu/qt6 -I/usr/include/x86_64-linux-gnu/qt6/QtGui -I/usr/include/x86_64-linux-gnu/qt6/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt6/mkspecs/linux-g++ -o main.o main.cpp
g++ -Wl,-rpath-link,/usr/lib/x86_64-linux-gnu -o helloworld main.o /usr/lib/x86_64-linux-gnu/libQt6Gui.so /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /usr/lib/x86_64-linux-gnu/libQt6Core.so -lpthread -lGLX -lOpenGL
QT_DEBUG is defined
however in release mode, it is not, QT_NO_DEBUG is defined instead:
rm -f .qmake.stash Makefile helloworld main.o && qmake6 -o Makefile repro.pro CONFIG+=release && make && ./helloworld
Info: creating stash file /home/gglrc/third_parties/repro_qt_meson/.qmake.stash
g++ -c -pipe -O2 -Wall -Wextra -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I/usr/include/x86_64-linux-gnu/qt6 -I/usr/include/x86_64-linux-gnu/qt6/QtGui -I/usr/include/x86_64-linux-gnu/qt6/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt6/mkspecs/linux-g++ -o main.o main.cpp
g++ -Wl,-O1 -Wl,-rpath-link,/usr/lib/x86_64-linux-gnu -o helloworld main.o /usr/lib/x86_64-linux-gnu/libQt6Gui.so /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /usr/lib/x86_64-linux-gnu/libQt6Core.so -lpthread -lGLX -lOpenGL
QT_DEBUG is not defined
with meson, neither is defined, so because of this Qt header, QT_DEBUG is defined:
// /usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h
#if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG)
# define QT_DEBUG
rm -r builddir && ../meson/meson.py setup builddir --buildtype debug && ninja -C builddir && builddir/helloworld
The Meson build system
Version: 1.9.99
Source dir: /home/gglrc/third_parties/repro_qt_meson
Build dir: /home/gglrc/third_parties/repro_qt_meson/builddir
Build type: native build
Project name: repro
Project version: undefined
C++ compiler for the host machine: c++ (gcc 13.3.0 "c++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0")
C++ linker for the host machine: c++ ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1
Run-time dependency qt6 (modules: Core) found: YES 6.4.2 (pkg-config)
Build targets in project: 1
repro undefined
User defined options
buildtype: debug
Found ninja-1.11.1 at /usr/bin/ninja
ninja: Entering directory `builddir'
[2/2] Linking target helloworld
QT_DEBUG is defined
and in release mode it's the same
rm -r builddir && ../meson/meson.py setup builddir --buildtype release && ninja -C builddir && builddir/helloworld
The Meson build system
Version: 1.9.99
Source dir: /home/gglrc/third_parties/repro_qt_meson
Build dir: /home/gglrc/third_parties/repro_qt_meson/builddir
Build type: native build
Project name: repro
Project version: undefined
C++ compiler for the host machine: c++ (gcc 13.3.0 "c++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0")
C++ linker for the host machine: c++ ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1
Run-time dependency qt6 (modules: Core) found: YES 6.4.2 (pkg-config)
Build targets in project: 1
repro undefined
User defined options
buildtype: release
Found ninja-1.11.1 at /usr/bin/ninja
ninja: Entering directory `builddir'
[2/2] Linking target helloworld
QT_DEBUG is defined
Expected behavior
meson should define QT_NO_DEBUG when in release mode
system parameters
- Is this a cross build or just a plain native build (for the same computer)? native
- what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.) ubuntu 24.04
- what Python version are you using e.g. 3.8.0: 3.12.3
- what
meson --versionreproduced with 1.3.2 and current master - what
ninja --versionif it's a Ninja build 1.11.1
Metadata
Metadata
Assignees
Labels
No labels