# Plugin with ui\_resources in environment without Qt

**URL:** https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953
**Category:** Development
**Created:** [September 28, 2023, 10:37am UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953 "2023-09-28T10:37:23Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![guillaume\_Peillex](https://discourse.paraview.org/user_avatar/discourse.paraview.org/guillaume_peillex/32/10449_2.png) [@guillaume\_Peillex](https://discourse.paraview.org/u/guillaume_Peillex)
#### Post date: [September 28, 2023, 10:37am UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/1 "2023-09-28T10:37:23Z")

</div>

Hi all,

I’m currently trying to build a plugin that has its own ui\_resources. So i’am declaring it with the `UI_RESOURCES` keyword of the `paraview_add_plugin` function.

I need to compile this plugin in an environment where ParaView is built with Qt support (in this case the compilation succeed) but also in an environment where ParaView has no Qt support and in this case i got configuration failure with the `Cannot find Qt` message.

A workaround is to use the `UI_RESOURCES` only if the variable `PARAVIEW_USE_QT` is true.  
Is it the right way to do?

thanks in advance

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [September 28, 2023, 2:08pm UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/2 "2023-09-28T14:08:18Z")

</div>

> [@guillaume\_Peillex](#):
>
> A workaround is to use the `UI_RESOURCES` only if the variable `PARAVIEW_USE_QT` is true.  
> Is it the right way to do?

Yes.

---

<div class="post-metadata">

### Author: ![guillaume\_Peillex](https://discourse.paraview.org/user_avatar/discourse.paraview.org/guillaume_peillex/32/10449_2.png) [@guillaume\_Peillex](https://discourse.paraview.org/u/guillaume_Peillex)
#### Post date: [September 28, 2023, 2:21pm UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/3 "2023-09-28T14:21:31Z")

</div>

Thanks @ben.boeckel for your quick answer.

I was wondering why in the `ParaViewPlugin.cmake` file, the link to Qt, when dealing with such ui\_resources, is not conditionally made according to the value of `${PARAVIEW_USE_QT}` ?

According to you, does it worth a MR in ParaView ?

Thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [September 28, 2023, 6:17pm UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/4 "2023-09-28T18:17:41Z")

</div>

I’m not sure what you mean? Are you saying that `UI_RESOURCES` should add some Qt library to `_paraview_add_plugin_required_libraries`? I guess it’s needed for the `Q_` macro that is injected.

---

<div class="post-metadata">

### Author: ![guillaume\_Peillex](https://discourse.paraview.org/user_avatar/discourse.paraview.org/guillaume_peillex/32/10449_2.png) [@guillaume\_Peillex](https://discourse.paraview.org/u/guillaume_Peillex)
#### Post date: [September 29, 2023, 6:07am UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/5 "2023-09-29T06:07:59Z")

</div>

No that’s not what i meant. Sorry to have been unclear.

I was just wondering why i have to do this “manually” in my plugin and why the lines in `ParaViewPlugin.cmake` dealing with `ui_resources` are not wrapped in a `if (${PARAVIEW_USE_QT})/endif()`. It is probably a very naive question.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [September 30, 2023, 3:44pm UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/6 "2023-09-30T15:44:30Z")

</div>

Oh, I see. A plugin could be built for an application that is not ParaView that brings its own Qt layer. I suppose it’s probably a long shot, but if we have a better signal (say, `if (TARGET ParaView::pqCore)` perhaps?), we can no-op the Qt bits based on that.

Looking, we do assume that exists, so it would probably be one way.

However…silently turning off things based on environmental things is also something I’ve tried to avoid in VTK and ParaView. Maybe an explicit `DISABLE_QT_IF_NOT_PRESENT` flag would suffice?

---

<div class="post-metadata">

### Author: ![guillaume\_Peillex](https://discourse.paraview.org/user_avatar/discourse.paraview.org/guillaume_peillex/32/10449_2.png) [@guillaume\_Peillex](https://discourse.paraview.org/u/guillaume_Peillex)
#### Post date: [October 3, 2023, 6:23am UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/7 "2023-10-03T06:23:48Z")

</div>

@ben.boeckel thanks for your answer.

If i understand you well, you suggest to introduce a new option in **ParaView** ’s build system : `DISABLE_QT_IF_NOT_PRESENT`.  
If this option is on and `PARAVIEW_USE_QT` is also true then we can no-op the Qt bits?  
I’am i right?  
If so i’ll be glad to make a MR.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [October 3, 2023, 10:41am UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/8 "2023-10-03T10:41:32Z")

</div>

No, there would be a new argument to `paraview_add_plugin` that would no-op any Qt bits if it is present and the requisite ParaView target(s) are not available.

---

<div class="post-metadata">

### Author: ![guillaume\_Peillex](https://discourse.paraview.org/user_avatar/discourse.paraview.org/guillaume_peillex/32/10449_2.png) [@guillaume\_Peillex](https://discourse.paraview.org/u/guillaume_Peillex)
#### Post date: [October 3, 2023, 10:53am UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/9 "2023-10-03T10:53:24Z")

</div>

All right. I see. It’s very clear thanks.

I’ll try to do a MR ASAP.  
Thanks

---

<div class="post-metadata">

### Author: ![guillaume\_Peillex](https://discourse.paraview.org/user_avatar/discourse.paraview.org/guillaume_peillex/32/10449_2.png) [@guillaume\_Peillex](https://discourse.paraview.org/u/guillaume_Peillex)
#### Post date: [December 21, 2023, 4:06pm UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/10 "2023-12-21T16:06:38Z")

</div>

I just saw that the lines below have been recently added to the `paraview_add_plugin` function.

```auto
  if (_paraview_add_plugin_UI_INTERFACES OR _paraview_add_plugin_UI_FILES OR _paraview_add_plugin_UI_RESOURCES)
    if (NOT PARAVIEW_USE_QT)
      message(FATAL_ERROR "UI_INTERFACES, UI_FILES and UI_RESOURCES require ParaView to be built with Qt enabled.")
    endif()
  endif()

```

As the warning is very explicit i suppose there is not anymore the need for the `DISABLE_QT_IF_NOT_PRESENT` option. What do you think about it @ben.boeckel ?

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [December 21, 2023, 4:15pm UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/11 "2023-12-21T16:15:38Z")

</div>

Indeed, trying to add `ui_resources` when building against a non-qt build of paraview now fails at cmake configuration time.

If the plugin still need the resources, they should be handled “manually” in the CMakeLists, as shown in this (new) example [https://gitlab.kitware.com/paraview/paraview/-/tree/master/Examples/Plugins/ServerSideQt](https://gitlab.kitware.com/paraview/paraview/-/tree/master/Examples/Plugins/ServerSideQt)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [December 21, 2023, 5:13pm UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/12 "2023-12-21T17:13:55Z")

</div>

> [@guillaume\_Peillex](#):
>
> `DISABLE_QT_IF_NOT_PRESENT`

What is this option? I don’t see it in the source tree.

---

<div class="post-metadata">

### Author: ![guillaume\_Peillex](https://discourse.paraview.org/user_avatar/discourse.paraview.org/guillaume_peillex/32/10449_2.png) [@guillaume\_Peillex](https://discourse.paraview.org/u/guillaume_Peillex)
#### Post date: [December 22, 2023, 7:23am UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/13 "2023-12-22T07:23:57Z")

</div>

@ben.boeckel this option was a suggestion you made a few lines above.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [December 22, 2023, 1:15pm UTC](https://discourse.paraview.org/t/plugin-with-ui-resources-in-environment-without-qt/12953/14 "2023-12-22T13:15:43Z")

</div>

Ah, I see. It’s something we can add if plugins are using Qt independently and there’s no ParaView/Qt related logic with the option that “makes sense” to just turn off.
