Skip to content

Commit 4cdffec

Browse files
fix: ensure extension works with the shared code base
1 parent 27a3c94 commit 4cdffec

File tree

6 files changed

+53
-1
lines changed

6 files changed

+53
-1
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ cmake_minimum_required(VERSION 3.16.3...4.0)
55
# SlicerLayerDM can be built in two different ways:
66
# - A 3DSlicer extension
77
# - A slicer-core based python wheel
8-
# Using include like this enables the CMake code to be in the expected source/binary directory and add_subdirectory to work seamlessly
8+
# Using include like this enables the CMake code to be in the expected
9+
# source/binary directory and add_subdirectory to work seamlessly
910
if(DEFINED SKBUILD_PROJECT_NAME)
1011
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION})
1112
include(${CMAKE_CURRENT_SOURCE_DIR}/wheel.cmake)
1213
else()
1314
project(LayerDisplayableManager)
15+
16+
# disable https://cmake.org/cmake/help/latest/policy/CMP0148.html as vtkAddon may still need it
17+
if(POLICY CMP0148)
18+
cmake_policy(SET CMP0148 OLD)
19+
endif()
20+
1421
include(${CMAKE_CURRENT_SOURCE_DIR}/extension.cmake)
1522
endif()

LayerDM/Logic/extension.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ configure_file(
1414
set(${KIT}_SRCS
1515
vtkSlicer${MODULE_NAME}Logic.cxx
1616
vtkSlicer${MODULE_NAME}Logic.h
17+
${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerLayerDMModuleLogicModule.h
1718
)
1819

1920
set(${KIT}_TARGET_LIBRARIES
@@ -30,6 +31,12 @@ SlicerMacroBuildModuleLogic(
3031
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
3132
)
3233

34+
include(GenerateExportHeader)
35+
generate_export_header(${KIT}
36+
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerLayerDMModuleLogicModule.h
37+
EXPORT_MACRO_NAME ${${KIT}_EXPORT_DIRECTIVE}
38+
)
39+
3340
target_include_directories(
3441
${KIT}
3542
PUBLIC

LayerDM/MRML/extension.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ set(${KIT}_SRCS
1616
vtkMRMLLayerDMSelectionObserver.h
1717
vtkMRMLLayerDMWidgetEventTranslationNode.cxx
1818
vtkMRMLLayerDMWidgetEventTranslationNode.h
19+
${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerLayerDMModuleMRMLModule.h
1920
)
2021

2122

@@ -41,6 +42,12 @@ SlicerMacroBuildModuleMRML(
4142
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
4243
)
4344

45+
include(GenerateExportHeader)
46+
generate_export_header(${KIT}
47+
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/vtkSlicerLayerDMModuleMRMLModule.h
48+
EXPORT_MACRO_NAME ${${KIT}_EXPORT_DIRECTIVE}
49+
)
50+
4451
target_compile_features(${KIT} PUBLIC cxx_std_17)
4552

4653
target_include_directories(

LayerDM/MRMLDM/extension.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ target_include_directories(
7575
${${KIT}_BINARY_DIR}
7676
)
7777

78+
configure_file(
79+
${${KIT}_SOURCE_DIR}/vtkSlicerLayerDMModuleMRMLDisplayableManagerModule.h.in
80+
${${KIT}_BINARY_DIR}/vtkSlicerLayerDMModuleMRMLDisplayableManagerModule.h
81+
COPYONLY
82+
)
83+
7884
if(${KIT}_AUTOINIT)
7985
set_property(TARGET ${KIT}
8086
APPEND PROPERTY COMPILE_DEFINITIONS
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// vtkSlicerLayerDMModuleMRMLDisplayableManagerModule
2+
///
3+
/// The vtkSlicerLayerDMModuleMRMLDisplayableManagerModule captures some system differences between Unix
4+
/// and Windows operating systems, and enables auto init for the VTK module.
5+
6+
#ifndef __vtkSlicerLayerDMModuleMRMLDisplayableManagerExport_h
7+
#define __vtkSlicerLayerDMModuleMRMLDisplayableManagerExport_h
8+
9+
#if defined(_WIN32) && !defined(MRMLLayerDM_STATIC)
10+
# if defined(vtkSlicerLayerDMModuleMRMLDisplayableManager_EXPORTS)
11+
# define VTK_SLICER_LAYERDM_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT __declspec(dllexport)
12+
# else
13+
# define VTK_SLICER_LAYERDM_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT __declspec(dllimport)
14+
# endif
15+
#else
16+
# define VTK_SLICER_LAYERDM_MODULE_MRMLDISPLAYABLEMANAGER_EXPORT
17+
#endif
18+
19+
#if defined(vtkSlicerLayerDMModuleMRMLDisplayableManager_AUTOINIT)
20+
# include <vtkAutoInit.h>
21+
VTK_AUTOINIT(vtkSlicerLayerDMModuleMRMLDisplayableManager)
22+
#endif
23+
24+
#endif

extension.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if(NOT git_code EQUAL 0)
3232
)
3333
endif()
3434

35+
string(STRIP "${git_stdout}" git_stdout) # git output will end with a newline
3536
string(SUBSTRING "${git_stdout}" 1 -1 LayerDM_VERSION)
3637
string(REPLACE "." ";" version_components "${LayerDM_VERSION}") # this creates a list
3738
list(GET version_components 0 LayerDM_VERSION_MAJOR)

0 commit comments

Comments
 (0)