Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add operator plugin function #20231

Open
wants to merge 4 commits into
base: task/biagas/cmake_modernization_with_blt
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 239 additions & 0 deletions src/CMake/PluginMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,242 @@ function(visit_add_plot_plugin)
VISIT_PLUGIN_TARGET_FOLDER(plots ${plot_PNAME} ${INSTALLTARGETS})
endfunction()

function(visit_add_operator_plugin)
# required arguments:
# ONAME Name of the operator plugin
# optional arguments:
# GSRC additional sources for the gui target
# VSRC additional sources for the viewer target
# ESRC additional sources for the engine targets
# GLIBS additional libraries for the gui target
# VLIBS additional libraries for the viewer target
# SLIBS additional libraries for the scripting target
# ESERLIBS additional libraries for the serial engine targets
# EPARLIBS additional libraries for the parallel engine targets
# DEFINES any defines for viewer,engine targets
# DISABLE_AUTOGEN disable xml autogeneration


# NOTES: not all of the target link libraries being added to the
# targets here are necessary for every operator. They are being added
# for convenience to ease plugin developement

set(OPTS DISABLE_AUTOGEN)
set(VALS ONAME)
set(MVALS GSRC VSRC ESRC GLIBS VLIBS SLIBS ESERLIBS EPARLIBS DEFINES)
cmake_parse_arguments(operator "${OPTS}" "${VALS}" "${MVALS}" ${ARGN})

if(NOT DEFINED operator_ONAME)
message(FATAL_ERROR "Incomplete arguments to visit_add_operator_plugin. Required: ONAME")
endif()

project(${operator_ONAME}_operator)

# if doing dev build ??
if(NOT ${operator_DISABLE_AUTOGEN})
ADD_OPERATOR_CODE_GEN_TARGETS(${operator_ONAME})
endif()

# Handle the different ways some operator's atts have been named.
# This was handled nicely in GenerateCMake when it was writing
# the full CMake code, becuase the Atts name is specified in the XML file.
# Could possibly have the CMake gen code add an ATTSNAME argument
# to this function instead of this logic ... Make it required so
# all plugins use it. Could do the same for FILTERNAME since some use
# 'Plugin' in the name.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${operator_ONAME}Attributes.C)
set(CATTS ${operator_ONAME}Attributes)
set(PYATTS Py${operator_ONAME}Attributes)
set(JATTS ${operator_ONAME}Attributes.java)
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${operator_ONAME}OperatorAttributes.C)
set(CATTS ${operator_ONAME}OperatorAttributes)
set(PYATTS Py${operator_ONAME}OperatorAttributes)
set(JATTS ${operator_ONAME}OperatorAttributes.java)
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${operator_ONAME}Atts.C)
set(CATTS ${operator_ONAME}Atts)
set(PYATTS Py${operator_ONAME}Atts)
set(JATTS ${operator_ONAME}Atts.java)
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${operator_ONAME}.C)
set(CATTS ${operator_ONAME})
set(PYATTS Py${operator_ONAME})
set(JATTS ${operator_ONAME}.java)
else()
message(FATAL_ERROR "Cound not find name for ${operator_ONAME}'s Attributes class. Expecting ${operator_ONAME}Attributes, ${operator_ONAME}OperatorAttributes, ${operator_ONAME}Atts or ${operator_ONAME}")
endif()

set(COMMON_SOURCES
${operator_ONAME}PluginInfo.C
${operator_ONAME}CommonPluginInfo.C
${CATTS}.C)
set(COMMON_HEADERS
${operator_ONAME}PluginInfo.h
${CATTS}.h)

set(LIBI_SOURCES ${operator_ONAME}PluginInfo.C)
set(LIBI_HEADERS ${operator_ONAME}PluginInfo.h)

set(LIBG_SOURCES
${operator_ONAME}GUIPluginInfo.C
Qvis${operator_ONAME}Window.C
${COMMON_SOURCES})
set(LIBG_HEADERS
Qvis${operator_ONAME}Window.h
${COMMON_HEADERS})
if(DEFINED operator_GSRC)
list(APPEND LIBG_SOURCES ${operator_GSRC})
foreach(src ${operator_GSRC})
string(REPLACE ".C" ".h" hdr ${src})
list(APPEND LIBG_HEADERS ${hdr})
endforeach()
endif()

set(LIBV_SOURCES
${operator_ONAME}ViewerEnginePluginInfo.C
${operator_ONAME}ViewerPluginInfo.C
${COMMON_SOURCES})
set(LIBV_HEADERS
${COMMON_HEADERS})

if(DEFINED operator_VSRC)
list(APPEND LIBV_SOURCES ${operator_VSRC})
foreach(src ${operator_VSRC})
string(REPLACE ".C" ".h" src hdr)
list(APPEND LIBV_HEADERS ${hdr})
endforeach()
endif()

set(LIBE_SOURCES
${operator_ONAME}ViewerEnginePluginInfo.C
${operator_ONAME}EnginePluginInfo.C
${COMMON_SOURCES})
set(LIBE_HEADERS
${COMMON_HEADERS})

# some operators don't use the standard filter name
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/avt${operator_ONAME}Filter.C)
list(APPEND LIBE_SOURCES avt${operator_ONAME}Filter.C)
list(APPEND LIBE_HEADERS avt${operator_ONAME}Filter.h)
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/avt${operator_ONAME}PluginFilter.C)
list(APPEND LIBE_SOURCES avt${operator_ONAME}PluginFilter.C)
list(APPEND LIBE_HEADERS avt${operator_ONAME}PluginFilter.h)
else()
message("FATAL_ERROR Could not determine name of ${operator_ONAME}'s filter class. Expecting avt${operator_ONAME}Filter or avt${operator_ONAME}PluginFilter.")
endif()


if(DEFINED operator_ESRC)
list(APPEND LIBE_SOURCES ${operator_ESRC})
foreach(src ${operator_ESRC})
string(REPLACE ".C" ".h" src hdr)
list(APPEND LIBE_HEADERS ${hdr})
endforeach()
endif()

set(ITarget I${operator_ONAME}Operator)
set(GTarget G${operator_ONAME}Operator)
set(VTarget V${operator_ONAME}Operator)
set(STarget S${operator_ONAME}Operator)
set(ESerTarget E${operator_ONAME}Operator_ser)
set(EParTarget E${operator_ONAME}Operator_par)

# we are setting SKIP_INSTALL for all visit_add_library calls
# because plugins don't need to be installed via the export-targets
# install path. Will use standard install logic at end of the method.
visit_add_library(
NAME ${ITarget}
SOURCES ${LIBI_SOURCES}
HEADERS ${LIBI_HEADERS}
INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
DEPENDS_ON visitcommon
SKIP_INSTALL)

set(INSTALLTARGETS ${ITarget})

if(NOT VISIT_SERVER_COMPONENTS_ONLY AND NOT VISIT_ENGINE_ONLY AND NOT VISIT_DBIO_ONLY)
visit_add_library(
NAME ${GTarget}
SOURCES ${LIBG_SOURCES}
HEADERS ${LIBG_HEADERS}
INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
DEPENDS_ON visitcommon gui winutil avtdbatts ${QT_QTWIDGETS_LIBRARY} ${operator_GLIBS}
SKIP_INSTALL)

set_target_properties(${GTarget} PROPERTIES AUTOMOC ON)

visit_add_library(
NAME ${VTarget}
SOURCES ${LIBV_SOURCES}
HEADERS ${LIBV_HEADERS}
INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
DEFINES VIEWER ${plot_DEFINES}
DEPENDS_ON visitcommon viewer ${operator_VLIBS}
SKIP_INSTALL)

set_target_properties(${VTarget} PROPERTIES AUTOMOC ON)

if(QT_VERSION VERSION_GREATER_EQUAL "6.2.0")
qt6_disable_unicode_defines(${GTarget})
qt6_disable_unicode_defines(${VTarget})
endif()

list(APPEND INSTALLTARGETS ${GTarget} ${VTarget})

if(VISIT_PYTHON_SCRIPTING)
visit_add_library(
NAME ${STarget}
SOURCES ${operator_ONAME}ScriptingPluginInfo.C
${PYATTS}.C
${COMMON_SOURCES}
HEADERS ${PYATTS}.h
${COMMON_HEADERS}
INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PYTHON_INCLUDE_DIR}>
DEPENDS_ON visitcommon visitpy ${PYTHON_LIBRARY} ${operator_SLIBS}
SKIP_INSTALL)

if(WIN32)
# This prevents python from #defining snprintf as _snprintf
target_compile_definitions(${STarget} PRIVATE HAVE_SNPRINTF)
endif()
list(APPEND INSTALLTARGETS ${STarget})
endif()

if(VISIT_JAVA)
file(COPY ${JATTS} DESTINATION ${JavaClient_BINARY_DIR}/src/operators)
add_custom_target(Java${plot_ONAME} ALL ${Java_JAVAC_EXECUTABLE} ${VISIT_Java_FLAGS} -d ${JavaClient_BINARY_DIR} -classpath ${JavaClient_BINARY_DIR} -sourcepath ${JavaClient_BINARY_DIR} ${JATTS}
DEPENDS_ON JavaClient
WORKING_DIRECTORY $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
endif()
endif()

visit_add_library(
NAME ${ESerTarget}
SOURCES ${LIBE_SOURCES}
HEADERS ${LIBE_HEADERS}
INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
DEFINES ENGINE ${operator_DEFINES}
DEPENDS_ON visitcommon
avtexpressions_ser ${operator_ESERLIBS}
SKIP_INSTALL)

list(APPEND INSTALLTARGETS ${ESerTarget})

if(VISIT_PARALLEL)
visit_add_parallel_library(
NAME ${EParTarget}
SOURCES ${LIBE_SOURCES}
HEADERS ${LIBE_HEADERS}
INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
DEFINES ENGINE ${operator_DEFINES}
DEPENDS_ON visitcommon
avtexpressions_par
${operator_EPARLIBS})
list(APPEND INSTALLTARGETS ${EParTarget})
endif()

# one of these is not needed for plugin vs install, which one?
VISIT_INSTALL_OPERATOR_PLUGINS(${INSTALLTARGETS})
VISIT_PLUGIN_TARGET_OUTPUT_DIR(operators ${INSTALLTARGETS})
VISIT_PLUGIN_TARGET_FOLDER(operators ${operator_ONAME} ${INSTALLTARGETS})
endfunction()

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <avtExprNode.h>

#include <visit-config.h> // for HAVE_LIBVTKM
#ifdef HAVE_LIBVTKM
#include <avtVtkmDataSet.h>
#endif
Expand Down
1 change: 1 addition & 0 deletions src/avt/Filters/avtContourFilter.C
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <float.h>
#include <vector>

#include <visit-config.h> // for HAVE_LIBVTKM
#ifdef HAVE_LIBVTKM
#include <avtVtkmDataSet.h>
#include <vtkm/cont/DataSet.h>
Expand Down
1 change: 1 addition & 0 deletions src/avt/Filters/avtThresholdFilter.C
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <ImproperUseException.h>
#include <NoDefaultVariableException.h>

#include <visit-config.h> // for HAVE_LIBVTKM
#ifdef HAVE_LIBVTKM
#include <avtVtkmDataSet.h>
#include <vtkm/cont/DataSet.h>
Expand Down
4 changes: 0 additions & 4 deletions src/operators/AMRStitchCell/AMRStitchCell.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version="1.0"?>
<Plugin name="AMRStitchCell" type="operator" label="AMR Dual Grid and Stitch Cells" version="1.0" enabled="true" mdspecificcode="false" engspecificcode="false" onlyengine="false" noengine="false" iconFile="AMRStitchCell.xpm" category="Geometry">
<CXXFLAGS>
${VISIT_INCLUDE_DIR}/avt/Database/Ghost
</CXXFLAGS>
<Files components="E">
avtAMRStitchCellFilter.C
AMRStitchCellTesselations3D.C
AMRStitchCellTesselations2D.C
</Files>
Expand Down
95 changes: 4 additions & 91 deletions src/operators/AMRStitchCell/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,93 +1,6 @@
# DO NOT EDIT THIS FILE! THIS FILE IS AUTOMATICALLY GENERATED BY xml2cmake
PROJECT(AMRStitchCell_operator)

ADD_OPERATOR_CODE_GEN_TARGETS(AMRStitchCell)

SET(COMMON_SOURCES
AMRStitchCellPluginInfo.C
AMRStitchCellCommonPluginInfo.C
AMRStitchCellAttributes.C
)

SET(LIBI_SOURCES
AMRStitchCellPluginInfo.C
)

SET(LIBG_SOURCES
AMRStitchCellGUIPluginInfo.C
QvisAMRStitchCellWindow.C
${COMMON_SOURCES}
)

SET(LIBV_SOURCES
AMRStitchCellViewerEnginePluginInfo.C
AMRStitchCellViewerPluginInfo.C
${COMMON_SOURCES}
)

SET(LIBE_SOURCES
AMRStitchCellViewerEnginePluginInfo.C
AMRStitchCellEnginePluginInfo.C
avtAMRStitchCellFilter.C
AMRStitchCellTesselations3D.C
AMRStitchCellTesselations2D.C
${COMMON_SOURCES}
)


INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${VISIT_OPERATOR_INCLUDES}
${VISIT_INCLUDE_DIR}/avt/Database/Ghost
)

LINK_DIRECTORIES(${VISIT_LIBRARY_DIR} )

ADD_LIBRARY(IAMRStitchCellOperator ${LIBI_SOURCES})
TARGET_LINK_LIBRARIES(IAMRStitchCellOperator visitcommon)
SET(INSTALLTARGETS IAMRStitchCellOperator)

IF(NOT VISIT_SERVER_COMPONENTS_ONLY AND NOT VISIT_ENGINE_ONLY AND NOT VISIT_DBIO_ONLY)
ADD_LIBRARY(GAMRStitchCellOperator ${LIBG_SOURCES})
set_target_properties(GAMRStitchCellOperator PROPERTIES AUTOMOC ON)
TARGET_LINK_LIBRARIES(GAMRStitchCellOperator visitcommon gui )

ADD_LIBRARY(VAMRStitchCellOperator ${LIBV_SOURCES})
ADD_TARGET_DEFINITIONS(VAMRStitchCellOperator VIEWER)
TARGET_LINK_LIBRARIES(VAMRStitchCellOperator visitcommon viewer )

SET(INSTALLTARGETS ${INSTALLTARGETS} GAMRStitchCellOperator VAMRStitchCellOperator)

IF(VISIT_PYTHON_SCRIPTING)
SET(LIBS_SOURCES
AMRStitchCellScriptingPluginInfo.C
PyAMRStitchCellAttributes.C
${COMMON_SOURCES}
)
ADD_LIBRARY(SAMRStitchCellOperator ${LIBS_SOURCES})
TARGET_LINK_LIBRARIES(SAMRStitchCellOperator visitcommon visitpy ${PYTHON_LIBRARY})
SET(INSTALLTARGETS ${INSTALLTARGETS} SAMRStitchCellOperator)
ENDIF(VISIT_PYTHON_SCRIPTING)

IF(VISIT_JAVA)
FILE(COPY AMRStitchCellAttributes.java DESTINATION ${JavaClient_BINARY_DIR}/src/operators)
ADD_CUSTOM_TARGET(JavaAMRStitchCell ALL ${Java_JAVAC_EXECUTABLE} ${VISIT_Java_FLAGS} -d ${JavaClient_BINARY_DIR} -classpath ${JavaClient_BINARY_DIR} -sourcepath ${JavaClient_BINARY_DIR} AMRStitchCellAttributes.java
DEPENDS JavaClient
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
ENDIF(VISIT_JAVA)
ENDIF(NOT VISIT_SERVER_COMPONENTS_ONLY AND NOT VISIT_ENGINE_ONLY AND NOT VISIT_DBIO_ONLY)

ADD_LIBRARY(EAMRStitchCellOperator_ser ${LIBE_SOURCES})
TARGET_LINK_LIBRARIES(EAMRStitchCellOperator_ser visitcommon avtpipeline_ser avtexpressions_ser avtfilters_ser )
SET(INSTALLTARGETS ${INSTALLTARGETS} EAMRStitchCellOperator_ser)

IF(VISIT_PARALLEL)
ADD_PARALLEL_LIBRARY(EAMRStitchCellOperator_par ${LIBE_SOURCES})
TARGET_LINK_LIBRARIES(EAMRStitchCellOperator_par visitcommon avtpipeline_par avtexpressions_par avtfilters_par )
SET(INSTALLTARGETS ${INSTALLTARGETS} EAMRStitchCellOperator_par)
ENDIF(VISIT_PARALLEL)

VISIT_INSTALL_OPERATOR_PLUGINS(${INSTALLTARGETS})
VISIT_PLUGIN_TARGET_OUTPUT_DIR(operators ${INSTALLTARGETS})
VISIT_PLUGIN_TARGET_FOLDER(operators AMRStitchCell ${INSTALLTARGETS})

visit_add_operator_plugin(
ONAME AMRStitchCell
ESRC AMRStitchCellTesselations3D.C
AMRStitchCellTesselations2D.C)
Loading