Conan: use settings.build_type if not set by Qt options for the build

To make the Qt conan package consumption more seamless for consumers
who use e.g. conan-center packages we should try to make sure that
"the default conan build profiles" people are using should work
with Qt conan packages as well.

This means that we should support the use case that when consumers
are not explicitly defining Qt specific build options, e.g.

  -o debug_and_release=True

And the consumer build profiles/settings may contain e.g.

  [settings]
    ...
    build_type=RelWithDebInfo

In qtbase conan recipe this should translate to correct
'Options' specific to Qt's configure(.bat).

This change introduces a fallback in case Qt specific
options are not being passed. It sets the Qt specific
options based on the settings.build_type.

Task-number: QTBUG-99571
Change-Id: I961570a100fadc03b8c423dcf0064ccc4be7ae6e
Reviewed-by: Toni Saario <toni.saario@qt.io>
(cherry picked from commit b9055da1738bc59cba7692ae34910c90e0859f67)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Iikka Eklund 2022-01-05 08:22:38 +02:00 committed by Qt Cherry-pick Bot
parent dae16a2ca7
commit d90cd761ae

View File

@ -504,9 +504,25 @@ class QtBase(ConanFile):
elif debug == True:
_set_build_type("Debug")
else:
# set default that mirror the configure(.bat) default values
self.options.release = True
_set_build_type("Release")
# As a fallback set the build type for Qt configure based on the 'build_type'
# defined in the conan build settings
build_type = self.settings.get_safe("build_type")
if build_type in [None, "None"]:
# set default that mirror the configure(.bat) default values
self.options.release = True
self.settings.build_type = "Release"
elif build_type == "Release":
self.options.release = True
elif build_type == "Debug":
self.options.debug = True
elif build_type == "RelWithDebInfo":
self.options.release = True
self.options.force_debug_info = True
elif build_type == "MinSizeRel":
self.options.release = True
self.options.optimize_size = True
else:
raise QtConanError("Unknown build_type: {0}".format(self.settings.build_type))
def build(self):
self.python_requires["qt-conan-common"].module.build_env_wrap(self, _build_qtbase)