Commit 9128cc61 authored by T.J. Corona's avatar T.J. Corona

Generalize plugin logic to include user-defined plugin projects

parent ad18c97b
......@@ -185,34 +185,85 @@ endif()
# reliable.
set(MODELBUILDER_DIRECTLY_LINK_TO_SMTK ON CACHE BOOL "Directly link SMTK plugins into ModelBuilder")
set(MODELBUILDER_PLUGINS "" CACHE LIST "Plugins to build into ModelBuilder.")
if (MODELBUILDER_DIRECTLY_LINK_TO_SMTK)
# If we are directly linking to SMTK, then SMTK is a required dependency.
find_package(smtk REQUIRED)
include(SMTKPluginMacros)
# In between SMTK 3.0.1 and 3.1.0, a feature was introduced to SMTK that
# enabled it to generate a plugin library from the contents of SMTK_PLUGINS, a
# global property that is a list of all SMTK plugin targets (both local to
# this project and imported from other projects). We check if this function
# exists in the SMTK we found. If it doesn't, we fall back to directly linking
# the plugins defined in SMTK.
if (COMMAND generate_smtk_plugin_library)
# For each plugin target listed by the user, locate the project. If the
# project uses SMTK's plugin macros to define its plugins, this will append
# the project's plugin targets to the global property SMTK_PLUGINS.
list(REMOVE_DUPLICATES MODELBUILDER_PLUGINS)
foreach(plugin ${MODELBUILDER_PLUGINS})
find_package(${plugin})
endforeach()
# Generate the target PluginsForModelBuilder, along with its header files
# (defined in ${PluginsForModelBuilder_HEADERS}).
list(REMOVE_DUPLICATES SMTK_PLUGINS)
generate_smtk_plugin_library(PluginsForModelBuilder)
list(APPEND modelbuilder_HDRS
${PluginsForModelBuilder_HEADERS})
target_link_libraries(modelbuilder
LINK_PRIVATE
smtkCore
PluginsForModelBuilder
)
# There is also a bit of code that must be present in ModelBuilder to load
# SMTK's plugins. We enable it here.
set_property(SOURCE mbMainWindow.cxx APPEND PROPERTY COMPILE_DEFINITIONS "DIRECTLY_LINK_TO_SMTK")
# the identified plugins. We enable it here.
set_property(SOURCE mbMainWindow.cxx APPEND PROPERTY COMPILE_DEFINITIONS
"DIRECTLY_LINK_TO_PLUGINS")
# Finally, we must link our application against smtkDefaultPlugins, which
# brings in all of the plugins created by the SMTK we are using.
target_link_libraries(modelbuilder
LINK_PRIVATE
else()
# If "generate_smtk_plugin_library" doesn't exist, then the version of SMTK
# we found has the target "smtkDefaultPlugins" that allows the application
# to direclty link SMTK's plugins to it.
target_link_libraries(modelbuilder
LINK_PRIVATE
smtkCore
smtkDefaultPlugins
)
)
endif ()
else()
# We are not directly linking to SMTK, so SMTK is no longer a required
# dependency. If we find it, we will generate a custom .plugins file for
# ModelBuilder to use during testing and for installation.
find_package(smtk)
if (smtk_FOUND)
# Create a custom .plugins xml file that contains all of the plugins made by
# the associated smtk. This file will be used to load plugins during testing.
# For each plugin target listed by the user, locate the project. If the
# project uses SMTK's plugin macros to define its plugins, this will append
# the project's plugin targets to the global property SMTK_PLUGINS.
list(REMOVE_DUPLICATES MODELBUILDER_PLUGINS)
foreach(plugin ${MODELBUILDER_PLUGINS})
find_package(${plugin})
endforeach()
# Create a custom .plugins xml file that contains all of the plugins we have
# found. This file will be used to load plugins during testing.
if (WIN32)
set(plugins_file ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins/.plugins)
else()
set(plugins_file ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/modelbuilder-${cmb_version}/plugins/.plugins)
set(plugins_file
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/modelbuilder-${cmb_version}/plugins/.plugins)
endif()
set(plugin_dir ${CMAKE_INSTALL_PREFIX}/${PARAVIEW_INSTALL_PLUGINS_DIR})
......@@ -220,6 +271,8 @@ else()
set(plugin_dir "${MACOSX_APP_INSTALL_PREFIX}/modelbuilder.app/Contents/Plugins")
endif ()
include(SMTKPluginMacros)
# In between SMTK 3.0.1 and 3.1.0, a feature was introduced to SMTK that
# enabled it to generate plugin configuration files for ParaView-branded
# consuming applications. This logic also allowed the plugin creator to flag
......@@ -227,15 +280,13 @@ else()
# plugins). To preserve backwards-compatibility, we key off of the existence
# of this CMake function and fall back to generating our own configuration
# file if it does not exist.
include(CheckFunctionExists)
include(SMTKPluginMacros)
if (COMMAND generate_smtk_plugin_config_file)
generate_smtk_plugin_config_file(${plugins_file}
RELATIVE_DIRECTORY ${plugin_dir})
list(REMOVE_DUPLICATES SMTK_PLUGINS)
generate_smtk_plugin_config_file(${plugins_file})
else()
set(contents "<?xml version=\"1.0\"?>\n<Plugins>\n</Plugins>\n")
list(REMOVE_DUPLICATES SMTK_PLUGINS)
foreach (plugin IN LISTS SMTK_PLUGINS)
get_property(${plugin}_location TARGET ${plugin} PROPERTY LOCATION)
file(RELATIVE_PATH ${plugin}_location ${plugin_dir} ${${plugin}_location})
......
......@@ -54,6 +54,8 @@
#ifdef DIRECTLY_LINK_TO_SMTK
#include "smtk/plugin/InitializeDefaultPlugins.h"
#elif DIRECTLY_LINK_TO_PLUGINS
#include "InitializePluginsForModelBuilder.h"
#endif
class mbMainWindow::pqInternals : public Ui::pqClientMainWindow
......@@ -164,6 +166,9 @@ mbMainWindow::mbMainWindow()
#ifdef DIRECTLY_LINK_TO_SMTK
smtk::extension::paraview::initializeDefaultPlugins();
smtk::extension::paraview::loadDefaultPlugins();
#elif defined DIRECTLY_LINK_TO_PLUGINS
smtk::extension::paraview::initializePluginsForModelBuilder();
smtk::extension::paraview::loadPluginsForModelBuilder();
#else
mbPluginConfigLoader::loadPluginConfigFile();
#endif
......
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