I’m developing a loadable extension.
As I know, a C++ loadable extension has three part: vtkSlicer${Module_Name}ModuleLogic
, qSlicer${MODULE_NAME}ModuleWidgets
, and the module itself.
If I build moduleLogic or ModuleWidgets with my own shared libraries, CMake will throw an error below
export called with target "*ModuleWidgets/ModuleLogic*" which requires target "*SomeSharedLibrary*" that is not in any export set.
My CMakeLists.txt
for ModuleWidgets is shown below.
It works fine when I link a library to module,but doesn’t work when link to logic or widgets.
project(qSlicer${MODULE_NAME}ModuleWidgets)
set(KIT ${PROJECT_NAME})
set(${KIT}_EXPORT_DIRECTIVE "Q_SLICER_MODULE_${MODULE_NAME_UPPER}_WIDGETS_EXPORT")
set(${KIT}_INCLUDE_DIRECTORIES
)
set(${KIT}_SRCS
...
)
set(${KIT}_MOC_SRCS
qSlicer${MODULE_NAME}FooBarWidget.h
...
)
set(${KIT}_UI_SRCS
../Resources/UI/qSlicer${MODULE_NAME}FooBarWidget.ui
...
)
set(${KIT}_RESOURCES
../Resources/qSlicer${MODULE_NAME}Module.qrc
)
set(${KIT}_TARGET_LIBRARIES
vtkSlicer${MODULE_NAME}ModuleLogic
SomeSharedLibary
)
#-----------------------------------------------------------------------------
SlicerMacroBuildModuleWidgets(
NAME ${KIT}
EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE}
INCLUDE_DIRECTORIES ${${KIT}_INCLUDE_DIRECTORIES}
SRCS ${${KIT}_SRCS}
MOC_SRCS ${${KIT}_MOC_SRCS}
UI_SRCS ${${KIT}_UI_SRCS}
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
RESOURCES ${${KIT}_RESOURCES}
WRAP_PYTHONQT
)
How can I fix this problem?