Commit c17de09f authored by T.J. Corona's avatar T.J. Corona

Add logic for generating plugins config file

parent eb430e6b
......@@ -10,18 +10,40 @@ define_property(GLOBAL PROPERTY SMTK_PLUGINS
BRIEF_DOCS "Global property for aggregating smtk plugin targets"
FULL_DOCS "Global property for aggregating smtk plugin targets")
define_property(TARGET PROPERTY ENABLED_BY_DEFAULT
BRIEF_DOCS "Option to enable plugin by default"
FULL_DOCS "Option to enable plugin by default")
# Enable an SMTK plugin by default
#
# enable_smtk_plugin_by_default(target choice)
function(enable_smtk_plugin_by_default target choice)
# Append a property to the plugin target that conveys whether or not the
# plugin should be loaded by default
set_property(TARGET ${target} PROPERTY ENABLED_BY_DEFAULT ${choice})
# Mark the property for export (so consuming libraries can access it)
set_property(TARGET ${target} APPEND PROPERTY EXPORT_PROPERTIES ENABLED_BY_DEFAULT)
endfunction(enable_smtk_plugin_by_default)
# create a plugin
# ENABLED_BY_DEFAULT is an option to indicate whether or not the plugin should
# be loaded by default. This only applies when plugins are loaded via a
# plugin list at runtime (as opposed to directly linking to plugins).
# REGISTRAR is used to register the plugin
# REGISTRAR_HEADER is the include file for the registrar (if unset, a file name
# is inferred from the REGISTRAR value)
# is inferred from the REGISTRAR value)
# MANAGERS is a list of managers to which the plugin can register
# LIBRARIES is a list of libraries against which the plugin must link
# LIBRARIES_PRIVATE is a list of libraries against which the plugin must
# privately link
# privately link
#
# All other arguments are forwarded to add_paraview_plugin()
#
# add_smtk_plugin(Name Version
# [ENABLED_BY_DEFAULT]
# [REGISTRAR registrar]
# [REGISTRAR_HEADER headerfile]
# [MANAGERS list of managers used]
......@@ -29,7 +51,7 @@ define_property(GLOBAL PROPERTY SMTK_PLUGINS
# [LIBRARIES list of required private libraries]
# )
function(add_smtk_plugin SMTK_PLUGIN_NAME SMTK_PLUGIN_VERSION)
set(options)
set(options ENABLED_BY_DEFAULT)
set(oneValueArgs REGISTRAR REGISTRAR_HEADER)
set(multiValueArgs MANAGERS LIBRARIES LIBRARIES_PRIVATE)
cmake_parse_arguments(SMTK_PLUGIN
......@@ -65,6 +87,8 @@ function(add_smtk_plugin SMTK_PLUGIN_NAME SMTK_PLUGIN_VERSION)
${SMTK_PLUGIN_UNPARSED_ARGUMENTS}
)
enable_smtk_plugin_by_default(${SMTK_PLUGIN_NAME} ${SMTK_PLUGIN_ENABLED_BY_DEFAULT})
target_link_libraries(${SMTK_PLUGIN_NAME}
LINK_PUBLIC
${SMTK_PLUGIN_LIBRARIES}
......@@ -76,3 +100,42 @@ function(add_smtk_plugin SMTK_PLUGIN_NAME SMTK_PLUGIN_VERSION)
)
endfunction(add_smtk_plugin)
# create a plugin config file including all of the plugins generated by this
# project.
# PLUGIN_CONFIG_FILE_NAME is the name of the file to create
# RELATIVE_DIRECTORY is a directory relative to which plugin locations should
# be described.
function(generate_smtk_plugin_config_file PLUGIN_CONFIG_FILE_NAME)
set(options)
set(oneValueArgs RELATIVE_DIRECTORY)
set(multiValueArgs)
cmake_parse_arguments(SMTK_PLUGIN_CONFIG
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}
)
set(plugins_file ${PLUGIN_CONFIG_FILE_NAME})
set(SMTK_PLUGINS_FILE_CONTENTS)
foreach (plugin IN LISTS SMTK_PLUGINS)
get_property(${plugin}_location TARGET ${plugin} PROPERTY LOCATION)
if (SMTK_PLUGIN_CONFIG_RELATIVE_DIRECTORY)
file(RELATIVE_PATH ${plugin}_location
${SMTK_PLUGIN_CONFIG_RELATIVE_DIRECTORY} ${${plugin}_location})
endif ()
get_property(${plugin}_enabled_by_default TARGET ${plugin} PROPERTY ENABLED_BY_DEFAULT)
set(${plugin}_enabled_by_default_val 0)
if (${plugin}_enabled_by_default)
set(${plugin}_enabled_by_default_val 1)
endif ()
string(APPEND SMTK_PLUGINS_FILE_CONTENTS
" <"
"Plugin name=\"${plugin}\" "
"filename=\"${${plugin}_location}\" "
"auto_load=\"${${plugin}_enabled_by_default_val}\" "
"/>\n")
endforeach ()
configure_file(${smtk_cmake_dir}/plugins.xml.in ${plugins_file} @ONLY)
endfunction(generate_smtk_plugin_config_file)
<?xml version="1.0"?>
<Plugins>
@SMTK_PLUGINS_FILE_CONTENTS@
</Plugins>
......@@ -648,6 +648,7 @@ install(
FILES
${PROJECT_SOURCE_DIR}/CMake/SMTKMacros.cmake
${PROJECT_SOURCE_DIR}/CMake/EncodeStringFunctions.cmake
${PROJECT_SOURCE_DIR}/CMake/plugins.xml.in
${PROJECT_SOURCE_DIR}/CMake/SMTKOperationXML.cmake
${PROJECT_SOURCE_DIR}/CMake/SMTKPluginMacros.cmake
${PROJECT_SOURCE_DIR}/CMake/serverSource.cxx.in
......
Add cmake logic to generate a plugin config file
ParaView-derived applications currently ingest plugins in one of two
ways: the plugins are either linked directly into the application, or
they are loaded at runtime. For the latter case, plugin discovery is
performed by reading xml files that describe the plugin's name,
location and whether or not it should be automatically loaded.
When SMTK (and SMTK-derived) plugins are intended to be loaded at
runtime, it is convenient to have the plugin config file generated
using the CMake target properties from the plugins themselves. This
change introduces the exported plugin target property
`ENABLED_BY_DEFAULT` and adds the CMake function
`generate_smtk_plugin_config_file` for ParaView-derived applications
that consume SMTK plugins to generate a plugins file.
......@@ -203,6 +203,7 @@ smtk_public_headers(smtkCore ${attributeHeaders})
if (SMTK_ENABLE_PARAVIEW_SUPPORT)
add_smtk_plugin(
smtkAttributePlugin "1.0"
ENABLED_BY_DEFAULT
REGISTRAR smtk::attribute::Registrar
MANAGERS smtk::operation::Manager smtk::resource::Manager
LIBRARIES smtkCore)
......
......@@ -341,6 +341,7 @@ add_paraview_plugin(
${PLUGIN_DOCK_IFACES_SRCS}
)
set_property(GLOBAL APPEND PROPERTY SMTK_PLUGINS "smtkPQComponentsPlugin")
enable_smtk_plugin_by_default(smtkPQComponentsPlugin TRUE)
target_link_libraries(smtkPQComponentsPlugin
LINK_PUBLIC
......
......@@ -86,6 +86,7 @@ add_paraview_plugin(
vtkSMTKWidgetsExt
)
set_property(GLOBAL APPEND PROPERTY SMTK_PLUGINS "smtkPQOperationViewsPlugin")
enable_smtk_plugin_by_default(smtkPQOperationViewsPlugin TRUE)
target_link_libraries(smtkPQOperationViewsPlugin
LINK_PUBLIC
smtkPQOperationViewsExt
......
......@@ -88,6 +88,7 @@ add_paraview_plugin(
CS_KITS ${serverModules}
)
set_property(GLOBAL APPEND PROPERTY SMTK_PLUGINS "smtkPVServerExtPlugin")
enable_smtk_plugin_by_default(smtkPVServerExtPlugin TRUE)
target_link_libraries(smtkPVServerExtPlugin
LINK_PUBLIC
......
......@@ -132,6 +132,7 @@ add_paraview_plugin(
vtkSMTKWidgetsExt
)
set_property(GLOBAL APPEND PROPERTY SMTK_PLUGINS "smtkPQWidgetsPlugin")
enable_smtk_plugin_by_default(smtkPQWidgetsPlugin TRUE)
target_link_libraries(smtkPQWidgetsPlugin
LINK_PUBLIC
......
......@@ -136,6 +136,7 @@ smtk_public_headers(smtkCore ${meshHeaders})
if (SMTK_ENABLE_PARAVIEW_SUPPORT)
add_smtk_plugin(
smtkMeshPlugin "1.0"
ENABLED_BY_DEFAULT
REGISTRAR smtk::mesh::Registrar
REGISTRAR_HEADER smtk/mesh/resource/Registrar.h
MANAGERS smtk::operation::Manager smtk::resource::Manager
......
......@@ -120,6 +120,7 @@ smtk_public_headers(smtkCore ${modelHeaders})
if (SMTK_ENABLE_PARAVIEW_SUPPORT)
add_smtk_plugin(
smtkModelPlugin "1.0"
ENABLED_BY_DEFAULT
REGISTRAR smtk::model::Registrar
MANAGERS smtk::operation::Manager smtk::resource::Manager
LIBRARIES smtkCore)
......
......@@ -87,6 +87,7 @@ install(
if (SMTK_ENABLE_PARAVIEW_SUPPORT)
add_smtk_plugin(
smtkOperationPlugin "1.0"
ENABLED_BY_DEFAULT
REGISTRAR smtk::operation::Registrar
MANAGERS smtk::operation::Manager smtk::resource::Manager
LIBRARIES smtkCore)
......
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