Commit 26f5a091 authored by Mark Olesen's avatar Mark Olesen

ENH: support plugin building for paraview-5.7

Note
    For paraview-5.7 (and later?) plugins are built into their own subdirs.
    It also is not possible to suppress creation of static libraries in
    the process.

The current solution is still a bit ugly
  - install into a local "staged" location (within the build directory)
  - use rsync to relocate to the .so files to the plugin directory
parent 0b0e85b7
Pipeline #135 failed with stages
......@@ -3,7 +3,19 @@ cd "${0%/*}" || exit # Run from this directory
export WM_CONTINUE_ON_ERROR=true # Optional unit
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
. ${WM_PROJECT_DIR:?}/wmake/scripts/paraviewFunctions # CMake, PV functions
# -----------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Note
# For paraview-5.7 (and later?) plugins are built into their own subdirs.
# It also is not possible to suppress creation of static libraries in the
# process.
#
# Current solution (ugly)
# - install into a local "staged" location (within the build directory)
# - use rsync to relocate to the .so files to the plugin directory
#------------------------------------------------------------------------------
warnIncomplete()
{
......@@ -20,6 +32,7 @@ then
wmakeLibPv foamReader/library
unset cmakeOpts cmakeType
unset installDir
if [ "$targetType" != objects ]
then
......@@ -28,16 +41,50 @@ then
cmakeType="cmakePv"
;;
(*)
# cmakeType="cmakePvInstall"
warnIncomplete "(unknown/unsupported version: $PARAVIEW_API)"
if installDir=$(findObjectDir '.')
then
installDir="$installDir/install-prefix"
# Require an absolute directory for CMake
if [ "${installDir#/}" = "$installDir" ]
then
installDir="$PWD/$installDir"
fi
cmakeOpts="$cmakeOpts -DSTAGED_INSTALL_PREFIX=$installDir"
cmakeType="cmakePvInstall"
else
cmakeType="cmakePv" # cmakeType="cmakePvInstall"
fi
;;
esac
fi
rm -rf "$installDir"
if [ -n "$cmakeType" ]
then
"$cmakeType" $PWD/blockMeshReader "$cmakeOpts" || warnIncomplete "blockMesh"
"$cmakeType" $PWD/foamReader "$cmakeOpts" || warnIncomplete "OpenFOAM"
"$cmakeType" "$PWD"/blockMeshReader "$cmakeOpts" || warnIncomplete "blockMesh"
"$cmakeType" "$PWD"/foamReader "$cmakeOpts" || warnIncomplete "OpenFOAM"
fi
if [ -d "$installDir" ]
then
[ -d "$FOAM_PV_PLUGIN_LIBBIN" ] || mkdir -p "$FOAM_PV_PLUGIN_LIBBIN"
# TODO: handle via targets via CMake
for dir in "$installDir/lib" "$installDir/lib64"
do
if [ -d "$dir" ]
then
echo
for libName in $(find "$dir" -name '*.so')
do
echo "Plugin: ${FOAM_PV_PLUGIN_LIBBIN##*/}/${libName##*/}"
rsync -a "$libName" "$FOAM_PV_PLUGIN_LIBBIN"
done
fi
done
fi
)
fi
......
#-----------------------------------------------------------------------------
# OpenFOAM blockMeshDict reader plugin for ParaView GUI (5.7+)
message(FATAL_ERROR "paraview-${pv_api} not yet supported")
set(CMAKE_BUILD_TYPE Release)
cmake_minimum_required(VERSION 3.8)
project(ParaFoamBlockReader)
find_package(ParaView REQUIRED)
include(GNUInstallDirs)
if (STAGED_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${STAGED_INSTALL_PREFIX}")
## message("use staged install: ${STAGED_INSTALL_PREFIX}")
else()
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(PARAVIEW_PLUGIN_ENABLE_ParaFoamBlockReader TRUE)
set("_paraview_plugin_default_${CMAKE_PROJECT_NAME}" ON)
paraview_plugin_scan(
PLUGIN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/plugin/paraview.plugin"
PROVIDES_PLUGINS plugins
REQUIRES_MODULES required_modules)
foreach(module IN LISTS required_modules)
if(NOT TARGET "${module}")
message("Missing required module: ${module}")
return()
endif()
endforeach()
# Install under <platform>/<arch>/lib, not lib64
paraview_plugin_build(
PLUGINS ${plugins}
AUTOLOAD ${plugins}
RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY_SUBDIRECTORY "${PARAVIEW_PLUGIN_SUBDIR}"
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# OpenFOAM blockMesh reader plugin for ParaView GUI
qt5_wrap_cpp(MOC_SRCS pqFoamBlockMeshControls.h)
paraview_plugin_add_property_widget(
KIND GROUP_WIDGET
TYPE "openfoam_blockreader_general_controls"
CLASS_NAME pqFoamBlockMeshControls
INTERFACES IFACES0
SOURCES IFACES0_SRCS)
set(BUILD_SHARED_LIBS_BACKUP ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS ON)
paraview_add_plugin(ParaFoamBlockReader
VERSION "${foam_api}"
UI_INTERFACES
${IFACES0}
SOURCES
${IFACES0_SRCS}
${MOC_SRCS}
pqFoamBlockMeshControls.cxx
MODULES blockMeshReader
MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/reader/vtk.module"
SERVER_MANAGER_XML ParaFoamBlockReader.xml
)
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_BACKUP})
target_link_libraries(ParaFoamBlockReader
PUBLIC ParaView::pqApplicationComponents)
#-----------------------------------------------------------------------------
NAME
ParaFoamBlockReader
DESCRIPTION
Provides an OpenFOAM blockMesh reader plugin for ParaView GUI
CONDITION
PARAVIEW_BUILD_QT_GUI
REQUIRES_MODULES
ParaView::Core
ParaView::ClientServerCoreCore
ParaView::ServerManagerCore
ParaView::ServerManagerRendering
ParaView::pqApplicationComponents
#-----------------------------------------------------------------------------
set(classes vtkPVblockMeshReader)
vtk_module_add_module(blockMeshReader
FORCE_STATIC
CLASSES ${classes})
target_include_directories(blockMeshReader
PUBLIC
${LIB_SRC}/OpenFOAM/include
${LIB_SRC}/OpenFOAM/lnInclude
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
${LIB_SRC}/fileFormats/lnInclude
${LIB_SRC}/conversion/lnInclude
${LIB_SRC}/meshTools/lnInclude
${PROJECT_SOURCE_DIR}/../common
${PROJECT_SOURCE_DIR}/library
)
set(OPENFOAM_LIBNAMES
OpenFOAM
fileFormats
conversion
meshTools
)
# With cmake 3.12 and newer, can simply use target_link_directories
# target_link_directories(blockMeshReader
# PUBLIC
# $ENV{FOAM_LIBBIN}
# )
# target_link_libraries(blockMeshReader
# PUBLIC
# vtkPVFoamCommon${foamPvLibQualifier}
# vtkPVblockReader${foamPvLibQualifier}
# ${OPENFOAM_LIBNAMES}
# )
# Older cmake. Do manually
link_directories(
$ENV{FOAM_LIBBIN}
)
unset(OPENFOAM_LIBS)
foreach(libname ${OPENFOAM_LIBNAMES})
unset(libpath CACHE)
find_library(libpath ${libname} PATHS $ENV{FOAM_LIBBIN})
list(APPEND OPENFOAM_LIBS ${libpath})
endforeach(libname)
target_link_libraries(blockMeshReader
PUBLIC
vtkPVFoamCommon${foamPvLibQualifier}
vtkPVblockReader${foamPvLibQualifier}
${OPENFOAM_LIBS}
)
#-----------------------------------------------------------------------------
NAME
blockMeshReader
DEPENDS
VTK::CommonCore
VTK::CommonDataModel
VTK::CommonExecutionModel
PRIVATE_DEPENDS
ParaView::pqCore
ParaView::ServerManagerRendering
#-----------------------------------------------------------------------------
# OpenFOAM reader plugin for ParaView GUI (5.7+)
message(FATAL_ERROR "paraview-${pv_api} not yet supported")
set(CMAKE_BUILD_TYPE Release)
cmake_minimum_required(VERSION 3.8)
project(ParaFoamReader)
find_package(ParaView REQUIRED)
include(GNUInstallDirs)
if (STAGED_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${STAGED_INSTALL_PREFIX}")
## message("use staged install: ${STAGED_INSTALL_PREFIX}")
else()
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(PARAVIEW_PLUGIN_ENABLE_ParaFoamReader TRUE)
set("_paraview_plugin_default_${CMAKE_PROJECT_NAME}" ON)
paraview_plugin_scan(
PLUGIN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/plugin/paraview.plugin"
PROVIDES_PLUGINS plugins
REQUIRES_MODULES required_modules)
foreach(module IN LISTS required_modules)
if(NOT TARGET "${module}")
message("Missing required module: ${module}")
return()
endif()
endforeach()
paraview_plugin_build(
PLUGINS ${plugins}
AUTOLOAD ${plugins}
RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY_SUBDIRECTORY "${PARAVIEW_PLUGIN_SUBDIR}"
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# OpenFOAM reader plugin for ParaView GUI
qt5_wrap_cpp(MOC_SRCS pqFoamReaderControls.h)
paraview_plugin_add_property_widget(
KIND GROUP_WIDGET
TYPE "openfoam_reader_general_controls"
CLASS_NAME pqFoamReaderControls
INTERFACES IFACES0
SOURCES IFACES0_SRCS)
set(BUILD_SHARED_LIBS_BACKUP ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS ON)
paraview_add_plugin(ParaFoamReader
VERSION "${foam_api}"
UI_INTERFACES
${IFACES0}
SOURCES
${IFACES0_SRCS}
${MOC_SRCS}
pqFoamReaderControls.cxx
MODULES FoamReader
MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/reader/vtk.module"
SERVER_MANAGER_XML ParaFoamReader.xml
)
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_BACKUP})
target_link_libraries(ParaFoamReader
PUBLIC ParaView::pqApplicationComponents)
#-----------------------------------------------------------------------------
NAME
ParaFoamReader
DESCRIPTION
Provides an OpenFOAM reader plugin for ParaView GUI
CONDITION
PARAVIEW_BUILD_QT_GUI
REQUIRES_MODULES
ParaView::Core
ParaView::ClientServerCoreCore
ParaView::ServerManagerCore
ParaView::ServerManagerRendering
ParaView::pqApplicationComponents
#-----------------------------------------------------------------------------
set(classes vtkPVFoamReader)
vtk_module_add_module(FoamReader
FORCE_STATIC
CLASSES ${classes})
target_include_directories(FoamReader
PUBLIC
${LIB_SRC}/OpenFOAM/include
${LIB_SRC}/OpenFOAM/lnInclude
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
${LIB_SRC}/fileFormats/lnInclude
${LIB_SRC}/conversion/lnInclude
${LIB_SRC}/finiteArea/lnInclude
${LIB_SRC}/finiteVolume/lnInclude
${PROJECT_SOURCE_DIR}/../common
${PROJECT_SOURCE_DIR}/library
)
set(OPENFOAM_LIBNAMES
OpenFOAM
fileFormats
conversion
finiteArea
finiteVolume
)
# With cmake 3.12 and newer, can simply use target_link_directories
# target_link_directories(FoamReader
# PUBLIC
# $ENV{FOAM_LIBBIN}
# )
# target_link_libraries(FoamReader
# PUBLIC
# vtkPVFoamCommon${foamPvLibQualifier}
# vtkPVFoamReader${foamPvLibQualifier}
# ${OPENFOAM_LIBNAMES}
# )
# Older cmake. Do manually
link_directories(
$ENV{FOAM_LIBBIN}
)
unset(OPENFOAM_LIBS)
foreach(libname ${OPENFOAM_LIBNAMES})
unset(libpath CACHE)
find_library(libpath ${libname} PATHS $ENV{FOAM_LIBBIN})
list(APPEND OPENFOAM_LIBS ${libpath})
endforeach(libname)
target_link_libraries(FoamReader
PUBLIC
vtkPVFoamCommon${foamPvLibQualifier}
vtkPVFoamReader${foamPvLibQualifier}
${OPENFOAM_LIBS}
)
#-----------------------------------------------------------------------------
NAME
FoamReader
DEPENDS
VTK::CommonCore
VTK::CommonDataModel
VTK::CommonExecutionModel
PRIVATE_DEPENDS
ParaView::pqCore
ParaView::ServerManagerRendering
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