occ-ai/obs-backgroundremoval

Fails to build when ENABLE_QT is off

Closed this issue · 11 comments

Describe the bug

ENABLE_QT is off by default, but if you try to build it that way, it fails, because it can't find QtWidgets. With ENABLE_QT it build just fine.

To Reproduce

Try to build without setting -DENABLE_QT=ON

Expected behavior

It should still build, but disable the components which require QT.

Or maybe the ENABLE_QT flag can be removed and just be required always, or at least be enabled by default?

Log and Crash Report

In file included from /tmp/portage/media-plugins/obs-backgroundremoval-1.1.0/work/obs-backgroundremoval-1.1.0/src/update-checker/update-checker.cpp:2:
/tmp/portage/media-plugins/obs-backgroundremoval-1.1.0/work/obs-backgroundremoval-1.1.0/src/update-checker/UpdateDialog.hpp:1:10: fatal error: QtWidgets: No such file or directory
    1 | #include <QtWidgets>
      |          ^~~~~~~~~~~
compilation terminated.

In file included from /tmp/portage/media-plugins/obs-backgroundremoval-1.1.0/work/obs-backgroundremoval-1.1.0/src/update-checker/UpdateDialog.cpp:1:
/tmp/portage/media-plugins/obs-backgroundremoval-1.1.0/work/obs-backgroundremoval-1.1.0/src/update-checker/UpdateDialog.hpp:1:10: fatal error: QtWidgets: No such file or directory
    1 | #include <QtWidgets>
      |          ^~~~~~~~~~~
compilation terminated.

Desktop (please complete the following information):

  • OS: Gentoo
  • Plugin Version: 1.1.0
  • OBS Version: 29.1.3

ENABLE_QT is enabled in this project in CMakePresets.json.
I just found this is not true for aarch64.
Do you use an ARM64 machine?

This may be related.
#375

No, I'm on amd64, but it looks like my build system (portage) isn't picking up the CMakePresets.json (it just uses the default set in CMakeLists.txt). I'm not really sure how I need to use the CMakePresets.json, as I'm not super familiar with cmake, but that's probably an issue on my side.

But if it's an option to disable QT, I think it should still compile, even when it's disabled?

What version is your CMake? I suspect your CMake is too old.

But if it's an option to disable QT, I think it should still compile, even when it's disabled?

ENABLE_QT is enabled on all the build systems via CMakePresets.json because our plugin must be built with Qt so considering the condition that ENABLE_QT is disabled is not reasonable.
If ENABLE_QT is disabled under some circumstances, this must be a bug in the build system.

We pulled the ENABLE_QT option from obsproject/obs-plugintemplate and we don't want to remove the ENABLE_QT option because we need to keep it familiar with the official plugin template.

My cmake version is 3.26.4.

our plugin must be built with Qt so considering the condition that ENABLE_QT is disabled is not reasonable.

Why is ENABLE_QT an option then, if it needs to be always enabled? Can't it just be removed as an option then and be always enabled?

We will appreciate your efforts to investigate why CMakePresets.json is not respected on Gentoo and suggest a reasonable workaround!

Thanks in advance!

Cheers 😘

OK, I figured it out, so the presets aren't automatically selected, I manually needed to add --preset linux-x86_64 to my cmake command (which then caused other problems, because the preset also overwrote the binaryDir, but I was able to set that back to the path Gentoo expects). But after selecting the preset, I was able to remove the -DENABLE_QT=ON parameter again, as that got now enabled by the preset.

I initially based my package on the arch package which is linked in the readme, and they also don't set any --preset. The arch package is still a much older version, but they probably eventually run into the same problem, once they try to build the latest version.

I saw you edited your answer about the ENABLE_QT, that you copied the option from the template. I still find it very confusing that there is an option, which is off by default (unless you manually enable it or manually select a preset which enables it), and if the option is disabled, it breaks the build. I think it should at least be enabled by default in the CMakeLists.txt (so it also builds without the preset). But if it's not allowed to be disabled ever, not having the option would still be better in my opinion.

@SuperTux88
Can you share the portage package script with me to let me investigate what happens on Gentoo?
I want to make this work on Gentoo properly.

But if it's not allowed to be disabled ever, not having the option would still be better in my opinion.

Not loading CMakePresets.json will be a problem because it has many other options than ENABLE_QT so we will discuss whether ENABLE_QT should be removed after we manage to have Gentoo load CMakePresets.json

I finally figured out that we need to provide the --preset option. I will add this option to the documents and AUR definitions.

Yes, I already wrote that in my last comment. Gentoo also loads the CMakePresets.json (as all other distributions, so this isn't really gentoo specific), but you need to actually select one of the presets with the --preset parameter for cmake, which I didn't know before as I never worked with presets.

So it's working now for me (with the --preset parameter), so if you don't want to change anything with the ENABLE_QT flag, you can close this.

We rather revise the document and clarify the building needs --prefix option.
Thank for helping us!