Link to module library (not logic, mrml, widgets)

Hello all,

Has anyone linked to a module library? I am trying to call a function in the public interface of the module class, and when I have

...
set(MODULE_TARGET_LIBRARIES
  vtkSlicer${MODULE_NAME}ModuleLogic
  qSlicerVirtualRealityModuleWidgets
  qSlicerVirtualRealityModule
  )
...

the qSlicerVirtualRealityModule target does not exist.

So, has anyone done something like this?

Cheers,
Adam

Targets listed in Slicer_TARGETS CMake variable are exported to the targets file here. Each library is added to Slicer_TARGETS, for example Qt libraries are added here. Try to find out why module library target is not exported: is it not included in Slicer_TARGETS, or there are no exported symbols, …?

The library is exported (.lib file exists).

Adding the .lib file manually to the linker inputs results in a successful compile (dumpbin also shows symbol exists in exports).

Target does not exist in CMake, investigating CMake system now.

The following line exists in the Qt module macro

set_property(GLOBAL APPEND PROPERTY Slicer_TARGETS ${MODULEQTLIBRARY_NAME})

but is not present in the loadable module CMake.

Presumably this means it is not exported by design? Could it be exported?

Update: I have added the export line to the macro, and the target is included in the XYZTargets.cmake file (as expected).

Edit: compilation fails however, as it most likely has PRIVATE interface_libraries that should be public?

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK1181	cannot open input file 'qSlicerBaseQTCLI.lib'	vtkSlicerVideoPassthroughModuleLogic	C:\d\Slcr\SARR\VideoPassthrough\Logic\LINK	1	
Error	LNK1181	cannot open input file 'qSlicerBaseQTApp.lib'	qSlicerVideoPassthroughModule	C:\d\Slcr\SARR\VideoPassthrough\LINK	1	
Error	LNK1181	cannot open input file 'vtkAddonPythonD.lib'	vtkSlicerVideoPassthroughModuleLogicPythonD	C:\d\Slcr\SARR\VideoPassthrough\Logic\LINK	1	
Error	LNK1181	cannot open input file 'qSlicerBaseQTCLI.lib'	vtkSlicerVideoPassthroughModuleLogicPython	C:\d\Slcr\SARR\VideoPassthrough\Logic\LINK	1	
Error	LNK1181	cannot open input file 'vtkSlicerCamerasModuleLogic.lib'	qSlicerVideoPassthroughModuleGenericCxxTests	C:\d\Slcr\SARR\VideoPassthrough\LINK	1	

I think it could make sense to make Qt module class (derived from qSlicerLoadableModule) available for other modules. Some features that require Qt and not related to the module widget are implemented in the module class and may be needed to be accessed from other modules.

@jcfr what do you think?

Talked to @jcfr, he suggested not to expose the module to protect the design decision of MRML/logic/widget reusability.

I will use a workaround to get the view via Qt methods (find by children by name/class) as the VR subsystem is a “special” snowflake.

SlicerVirtualReality is not the only extension that uses module class for module-specific functions that may be useful for other modules. For example, Sequence Browser module uses the module class, too (for managing sequence browser toolbar). Any other logic that requires Qt but it should be available regardless of a module widget must live in the module class.

I agree that it is better if we don’t need to expose the module class, but only if we don’t need uglier workarounds to achieve what we need.