From d27c7edab5596ad83d7e43f4411b87eee7d4b5c4 Mon Sep 17 00:00:00 2001 From: Rafael Palomar Date: Mon, 8 Dec 2025 12:51:20 +0100 Subject: [PATCH] ENH: Enable AutoInit for LayerDM This commit provides the project with a specific `vtkSlicerLayerDMModuleMRMLDisplayableManagerExport.h` file, which replaces the generic one created by the build process; this file explicitly performs vtk module autoinit, thus removing the need for explicit code to do this when `vtkSlicerLayerDMModuleMRMLDisplayableManager` is used . In addition, this commit removes the no longer needed autoinit code for `qSlicerLayerDMModule.cxx`, which exemplifies the point. --- LayerDM/MRMLDM/CMakeLists.txt | 8 +++++++ ...ayerDMModuleMRMLDisplayableManagerExport.h | 24 +++++++++++++++++++ LayerDM/qSlicerLayerDMModule.cxx | 4 ---- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 LayerDM/MRMLDM/vtkSlicerLayerDMModuleMRMLDisplayableManagerExport.h diff --git a/LayerDM/MRMLDM/CMakeLists.txt b/LayerDM/MRMLDM/CMakeLists.txt index a22135d..09a2509 100644 --- a/LayerDM/MRMLDM/CMakeLists.txt +++ b/LayerDM/MRMLDM/CMakeLists.txt @@ -64,6 +64,7 @@ set(${KIT}_TARGET_LIBRARIES ) #----------------------------------------------------------------------------- + SlicerMacroBuildModuleLogic( NAME ${KIT} EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE} @@ -79,4 +80,11 @@ target_include_directories( ${${KIT}_BINARY_DIR} ) +if(${KIT}_AUTOINIT) + set_property(TARGET ${KIT} + APPEND PROPERTY COMPILE_DEFINITIONS + "${KIT}_AUTOINIT=1(${KIT})" + ) +endif() + target_compile_features(${KIT} PUBLIC cxx_std_17) diff --git a/LayerDM/MRMLDM/vtkSlicerLayerDMModuleMRMLDisplayableManagerExport.h b/LayerDM/MRMLDM/vtkSlicerLayerDMModuleMRMLDisplayableManagerExport.h new file mode 100644 index 0000000..b5bfa44 --- /dev/null +++ b/LayerDM/MRMLDM/vtkSlicerLayerDMModuleMRMLDisplayableManagerExport.h @@ -0,0 +1,24 @@ +/// vtkSlicerLayerDMModuleMRMLDisplayableManagerExport +/// +/// The vtkSlicerLayerDMModuleMRMLDisplayableManagerExport captures some system differences between Unix +/// and Windows operating systems, and enables auto init for the VTK module. + +#ifndef __vtkSlicerLayerDMModuleMRMLDisplayableManagerExport_h +#define __vtkSlicerLayerDMModuleMRMLDisplayableManagerExport_h + +#if defined(_WIN32) && !defined(MRMLLayerDM_STATIC) +# if defined(vtkSlicerLayerDMModuleMRMLDisplayableManager_EXPORTS) +# define VTK_SLICER_LAYERDM_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT __declspec(dllexport) +# else +# define VTK_SLICER_LAYERDM_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT __declspec(dllimport) +# endif +#else +# define VTK_SLICER_LAYERDM_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT +#endif + +#if defined(vtkSlicerLayerDMModuleMRMLDisplayableManager_AUTOINIT) +# include +VTK_AUTOINIT(vtkSlicerLayerDMModuleMRMLDisplayableManager) +#endif + +#endif diff --git a/LayerDM/qSlicerLayerDMModule.cxx b/LayerDM/qSlicerLayerDMModule.cxx index af651d9..1aaf5f8 100644 --- a/LayerDM/qSlicerLayerDMModule.cxx +++ b/LayerDM/qSlicerLayerDMModule.cxx @@ -19,10 +19,6 @@ #include "vtkMRMLLayerDisplayableManager.h" -#include - -VTK_MODULE_INIT(vtkSlicerLayerDMModuleMRMLDisplayableManager); - //----------------------------------------------------------------------------- qSlicerLayerDMModule::qSlicerLayerDMModule(QObject* _parent) : Superclass(_parent)