Commit 44637c79 authored by Ben Boeckel's avatar Ben Boeckel

GUISupportQt: clean up the plugin build

This fixes the build to place it into the right location in the build
and install trees as well as removes the duplicate moc invocation.
parent 8741b3c5
......@@ -71,65 +71,47 @@ cmake_dependent_option(VTK_BUILD_QT_DESIGNER_PLUGIN
mark_as_advanced(VTK_BUILD_QT_DESIGNER_PLUGIN)
if (VTK_BUILD_QT_DESIGNER_PLUGIN)
set(PluginLibSrcs Q4VTKWidgetPlugin.cxx)
set(plugin_srcs
Q4VTKWidgetPlugin.cxx
Q4VTKWidgetPlugin.h)
set(PluginMocHeaders Q4VTKWidgetPlugin.h)
# The VTK_INSTALL_QT_PLUGIN_DIR variable sets the location
# in which the Qt plugin will be installed.
if(NOT VTK_INSTALL_QT_PLUGIN_DIR)
set(VTK_INSTALL_QT_PLUGIN_DIR qt5/plugins/designer)
endif()
set(qt_component UiPlugin)
if (Qt5_VERSION VERSION_LESS "5.5.0")
set(qt_component Designer)
set(module_destination "${CMAKE_INSTALL_LIBDIR}")
if (WIN32)
set(module_destination "${CMAKE_INSTALL_BINDIR}")
endif ()
find_package(Qt5 COMPONENTS ${qt_component} REQUIRED)
qt5_wrap_cpp(PluginMocSrcs ${PluginMocHeaders} TARGET QVTKWidgetPlugin)
# add QVTK plugin from sources
# stand-alone as it doesn't depend on QVTK library
add_library(QVTKWidgetPlugin
SHARED
${PluginLibSrcs}
${PluginMocSrcs}
)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${module_destination}/${VTK_INSTALL_QT_PLUGIN_DIR}")
set_target_properties(QVTKWidgetPlugin PROPERTIES COMPILE_DEFINITIONS QT_NO_DEBUG)
find_package(Qt5 COMPONENTS UiPlugin REQUIRED)
# link with Qt libs
target_link_libraries(QVTKWidgetPlugin Qt5::${qt_component})
# add QVTK plugin from sources
# stand-alone as it doesn't depend on QVTK library
add_library(QVTKWidgetPlugin MODULE
${plugin_srcs})
target_compile_definitions(QVTKWidgetPlugin
PRIVATE
QT_NO_DEBUG)
target_link_libraries(QVTKWidgetPlugin
PRIVATE
Qt5::UiPlugin)
if (WIN32)
set_target_properties(QVTKWidgetPlugin
PROPERTIES
DEBUG_POSTFIX "d")
endif ()
# install rules
# The VTK_INSTALL_QT_PLUGIN_DIR variable sets the location
# in which the Qt plugin will be installed. It may or may not contain
# variable references to CMAKE_INSTALL_PREFIX and VTK_INSTALL_QT_DIR.
# The default is to install to VTK_INSTALL_QT_DIR under the installation
# prefix. The default VTK_INSTALL_QT_DIR will allow the designer plugin
# path to be set to vtk-install-prefix/plugins to get the plugin.
if(NOT VTK_INSTALL_QT_DIR)
set(VTK_INSTALL_QT_DIR plugins/designer)
endif()
# If no runtime is to be installed then do not install the qt plugin.
if(VTK_INSTALL_NO_RUNTIME)
set(VTK_INSTALL_NO_QT_PLUGIN 1)
endif()
if(NOT VTK_INSTALL_NO_QT_PLUGIN)
# Set default plugin install directory.
set(DOLLAR "$")
if(DEFINED VTK_INSTALL_QT_PLUGIN_DIR)
else()
set(VTK_INSTALL_QT_PLUGIN_DIR
"${DOLLAR}{CMAKE_INSTALL_PREFIX}/${DOLLAR}{VTK_INSTALL_QT_DIR}"
CACHE STRING "Directory in which the VTK Qt plugin is placed during installation.")
mark_as_advanced(VTK_INSTALL_QT_PLUGIN_DIR)
endif()
# Configure the plugin install script. This is used instead of
# INSTALL TARGETS to allow the plugin to be installed outside the
# main install prefix. Attach the script as a post-install script.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/PluginInstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/PluginInstall.cmake
@ONLY)
set_target_properties(GUISupportQt PROPERTIES POST_INSTALL_SCRIPT
${CMAKE_CURRENT_BINARY_DIR}/PluginInstall.cmake)
endif()
if(NOT VTK_INSTALL_NO_RUNTIME)
install(
TARGETS QVTKWidgetPlugin
LIBRARY DESTINATION "${module_destination}/${VTK_INSTALL_QT_PLUGIN_DIR}")
endif ()
endif ()
# Configured file and directory locations.
set(VTK_LIB_DIR "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
set(VTK_INSTALL_QT_DIR "@VTK_INSTALL_QT_DIR@")
set(VTK_INSTALL_QT_PLUGIN_DIR "@VTK_INSTALL_QT_PLUGIN_DIR@")
set(BUILDTYPE_SUFFIX)
if (WIN32)
if (BUILD_TYPE STREQUAL "Debug")
set(BUILDTYPE_SUFFIX @CMAKE_DEBUG_POSTFIX@)
else ()
set(BUILDTYPE_SUFFIX @CMAKE_RELEASE_POSTFIX@)
endif ()
endif ()
set(VTK_INSTALL_QT_PLUGIN_FILE "@CMAKE_SHARED_LIBRARY_PREFIX@QVTKWidgetPlugin${BUILDTYPE_SUFFIX}@CMAKE_SHARED_LIBRARY_SUFFIX@")
set(VTK_CONFIGURATIONS "@CMAKE_CONFIGURATION_TYPES@")
if(VTK_CONFIGURATIONS)
set(VTK_LIBSUBDIR "/${BUILD_TYPE}")
endif()
# Install the file to the specified location.
file(INSTALL DESTINATION "${VTK_INSTALL_QT_PLUGIN_DIR}" TYPE SHARED_LIBRARY
FILES "${VTK_LIB_DIR}${VTK_LIBSUBDIR}/${VTK_INSTALL_QT_PLUGIN_FILE}")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment