Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mesonbuild/dependencies/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def get_exe_args(self, compiler: 'Compiler') -> T.List[str]:
def log_details(self) -> str:
return f'modules: {", ".join(sorted(self.requested_modules))}'

def _get_common_defines(self) -> T.List[str]:
is_debug = self.env.coredata.optstore.get_value_for('debug')
return ['-DQT_DEBUG' if is_debug else '-DQT_NO_DEBUG']

class QtPkgConfigDependency(_QtBase, PkgConfigDependency, metaclass=abc.ABCMeta):

Expand Down Expand Up @@ -225,6 +228,8 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):

self.libexecdir = self.get_pkgconfig_host_libexecs(self)

self.compile_args += self._get_common_defines()

@staticmethod
@abc.abstractmethod
def get_pkgconfig_host_bins(core: PkgConfigDependency) -> T.Optional[str]:
Expand Down Expand Up @@ -268,6 +273,8 @@ def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
if not self.found():
return

self.compile_args += self._get_common_defines()

# Query library path, header path, and binary path
stdo = self.get_config_value(['-query'], 'args')
qvars: T.Dict[str, str] = {}
Expand Down
5 changes: 5 additions & 0 deletions test cases/frameworks/4 qt/assert_qt_debug.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef QT_DEBUG
#error QT_DEBUG is not defined
#endif

int main() { return 0; }
5 changes: 5 additions & 0 deletions test cases/frameworks/4 qt/assert_qt_no_debug.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#ifndef QT_NO_DEBUG
#error QT_NO_DEBUG is not defined
#endif

int main() { return 0; }
7 changes: 7 additions & 0 deletions test cases/frameworks/4 qt/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,12 @@ foreach qt : ['qt4', 'qt5', 'qt6']
accept_versions = ['>=@0@'.format(qtdep.version()), '<@0@'.format(qtdep.version()[0].to_int() + 1)]
dependency(qt, modules: qt_modules, version: accept_versions, method : get_option('method'))

# check that QT_DEBUG is correctly defined depending on whether this is a debug build
if get_option('debug')
assert_source = 'assert_qt_debug.cpp'
else
assert_source = 'assert_qt_no_debug.cpp'
endif
executable(qt + 'assert_debug', sources: [ assert_source ], dependencies: [ qtdep ])
endif
endforeach
4 changes: 4 additions & 0 deletions test cases/frameworks/4 qt/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{ "val": "config-tool" },
{ "val": "qmake" },
{ "val": "pkg-config" }
],
"debug": [
{ "val": "true" },
{ "val": "false" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in running the entire Qt tests six times instead of three, which is pretty heavyweight..I suggest instead defining the executable twice with override_options: ['debug=true']

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I passed override_options as arguement to executable, but it looks like it is too late, and the qt dependency was already found, and the define is already computed. So that does not work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should just make a separate test project that just builds this single executable?

]
}
},
Expand Down
Loading