Skip to content
Snippets Groups Projects
makeParaView 12.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • Henry's avatar
    Henry committed
    #!/bin/sh
    #------------------------------------------------------------------------------
    # =========                 |
    # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    #  \\    /   O peration     |
    
    #   \\  /    A nd           | www.openfoam.com
    
    OpenFOAM bot's avatar
    OpenFOAM bot committed
    #    \\/     M anipulation  |
    #------------------------------------------------------------------------------
    
    #     Copyright (C) 2011-2016 OpenFOAM Foundation
    
    #     Copyright (C) 2016-2021 OpenCFD Ltd.
    
    Henry's avatar
    Henry committed
    #------------------------------------------------------------------------------
    # License
    
    #     This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
    
    Henry's avatar
    Henry committed
    #
    # Script
    #     makeParaView
    #
    # Description
    
    #     Make and install ParaView.
    
    #     The ParaView sources should be located under one of these locations:
    #       - $WM_THIRD_PARTY_DIR/ParaView-VERSION
    #       - $WM_THIRD_PARTY_DIR/ParaView-vVERSION
    #
    #     Note the capitalization of ParaView in the directory names.
    
    Henry's avatar
    Henry committed
    #
    
    # ----------------------------------------------
    # NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
    
    #------------------------------------------------------------------------------
    
    if :    # Run from third-party directory
    then
        cd "${0%/*}" || exit
        wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
            echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
            echo "    Check your OpenFOAM environment and installation"
            exit 1
        }
    fi
    . "${WM_THIRD_PARTY_DIR:?}"/etc/tools/ThirdPartyFunctions
    
    . "${WM_THIRD_PARTY_DIR:?}"/etc/tools/CMakeFunctions
    
    . "${WM_THIRD_PARTY_DIR:?}"/etc/tools/ParaViewFunctions
    
    #------------------------------------------------------------------------------
    
    # ParaView_VERSION from etc/config.sh file:
    
    unset ParaView_VERSION                  # Purge current values
    
    
    # Avoid any potential conflicts (especially if building from git)
    if [ -d "$ParaView_DIR" ]
    then
        _foamClean PATH "$ParaView_DIR"
        _foamClean LD_LIBRARY_PATH "$ParaView_DIR"
    fi
    unset ParaView_DIR ParaView_INCLUDE_DIR PV_PLUGIN_PATH
    
    case "$ParaView_VERSION" in
    [Pp]*)
        ParaView_VERSION="${ParaView_VERSION##*-}"  # Without "ParaView-" prefix
        ;;
    esac
    ParaView_VERSION="${ParaView_VERSION%%-*}"      # Without suffix (eg, -python)
    
    
    # Set initial ParaView_MAJOR based on current value of ParaView_VERSION
    setParaViewVersion ${ParaView_VERSION:-none}
    
    # New rendering backend (starting with paraview 5.0).
    
    withGL2=auto # auto-config based on version
    
    # Hint for cmake findMPI
    if [ -d "$MPI_ARCH_PATH" ]
    then
        export MPI_HOME="$MPI_ARCH_PATH"
    fi
    
    
    #------------------------------------------------------------------------------
    
    printVersions() { listPackageVersions paraview; exit 0; }
    printHelp() {
    
        : ${ParaView_VERSION:=none} # some dummy value for usage information
    
    Henry's avatar
    Henry committed
        cat<<USAGE
    
    
    Usage: ${0##*/} [OPTION] [paraview-VERSION] [CMAKE-OPTION]
    
    Henry's avatar
    Henry committed
    options:
    
      -gcc              Force use of gcc/g++
      -cmake PATH       with cmake from the given path
    
    Henry's avatar
    Henry committed
      -rebuild          for repeated builds (-make -install) *use with caution*
    
      -gl2              with new rendering backend (default: auto)
      -mesa             with mesa
    
      -mesa-prefix DIR  location of mesa installation (sets -mesa-include, -mesa-lib)
    
      -mesa-include DIR location of mesa headers (current: ${MESA_INCLUDE:-none})
      -mesa-lib PATH    path to mesa library     (current: ${MESA_LIBRARY:-none})
      -mpi              with mpi
    
      -mpi=N            with max 'N' mpi processes. N=0 for no upper-limit.
    
      -mpi-home PATH    with mpi and hint for MPI_HOME
    
      -python | -python2 | -python3
                        with python
    
      -python-include DIR
                        location of python headers (current: ${PYTHON_INCLUDE:-none})
    
      -python-lib PATH  path to python library (current: ${PYTHON_LIBRARY:-none})
    
      -qmake PATH       with QT version corresponding to the qmake in given path
    
    Henry's avatar
    Henry committed
      -qt               with extra Qt gui support (if not already enabled)
    
      -qt-<VER>         with QT version corresponding to
    
    Henry's avatar
    Henry committed
                            \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/qt-VER/bin/qmake
      -verbose          verbose output in Makefiles
    
      -version VER      specify an alternative version (current: $ParaView_VERSION)
    
    Henry's avatar
    Henry committed
      -major   VER      specify an alternative major version for special builds
    
      -buildType NAME   specify the build type (default: Release)
    
      -suffix NAME      specify a suffix to distinguish the build
    
      -DNAME=VALUE      add cmake variable
    
      -list             List available unpacked source versions
      -help             Display usage help
    
    The -no-FEATURE option can be used to forcibly disable these features:
    
      -no-gl2 | -no-mesa | -no-mpi | -no-python | -no-qt
    
    Henry's avatar
    Henry committed
    
    CMake options start with a capital letter and contain an '='.
    For example,
    
    Henry's avatar
    Henry committed
    
    For finer control, the build stages can be selected or deselected individually:
    
      -patch     -no-patch
    
    Henry's avatar
    Henry committed
      -config    -no-config
      -make      -no-make
      -install   -no-install
    
    
    * Make and install paraview-$ParaView_VERSION located under
          \$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION
    
      ->  \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-$ParaView_VERSION$BUILD_SUFFIX
    
    To make a different paraview version, simply specify on the command-line.
    
    Or change the \$WM_PROJECT_DIR/etc/config.sh/paraview settings.
    
    
    Henry's avatar
    Henry committed
    USAGE
    
        showDownloadHint paraview
        exit 0  # Clean exit
    
    Henry's avatar
    Henry committed
    }
    #------------------------------------------------------------------------------
    
    exportCompiler minimal  # Minimal compiler info for CMake/configure
    
    # Various building stages
    
    unset runPATCH runCONFIG runMAKE runINSTALL
    
    Henry's avatar
    Henry committed
    runDEFAULT=true
    
    
    Henry's avatar
    Henry committed
    while [ "$#" -gt 0 ]
    do
        case "$1" in
    
        -h | -help*) printHelp;;
        -list)      printVersions;;
    
        # paraview version
        paraview/* | vtk/* | sources/paraview* | sources/vtk* |\
        [0-9]* | paraview-[0-9]* | ParaView-[0-9]* | ParaView-v[0-9]*)
            setParaViewVersion "$(basename "$1")"
    
        -D[A-Z]*=* | [A-Z]*=*)  # cmake variables
    
    Henry's avatar
    Henry committed
            addCMakeVariable "$1"
            ;;
    
        -patch)              # stage 0: patch sources
            runPATCH=true
            unset runDEFAULT
            ;;
        -no-patch)
            runPATCH=false
            ;;
    
    Henry's avatar
    Henry committed
        -config)             # stage 1: config only
            runCONFIG=true
            unset runDEFAULT
            ;;
        -no-config)
            runCONFIG=false
            ;;
        -make)               # stage 2: make only
            runMAKE=true
            unset runDEFAULT
            ;;
        -no-make)
            runMAKE=false
            ;;
        -install)            # stage 3: install only
            runINSTALL=true
            unset runDEFAULT
            ;;
        -no-install)
            runINSTALL=false
            ;;
        -rebuild)            # shortcut for rebuilding
            runMAKE=true
            runINSTALL=true
            unset runDEFAULT
            ;;
    
        -gl2)
            withGL2=true
            ;;
        -no-gl2)
            withGL2=false
            ;;
    
    Henry's avatar
    Henry committed
        -mesa)
            withMESA=true
            ;;
    
        -osmesa)
            echo
            echo "The -osmesa option is currently ignored"
            echo
            # withMESA=true
            # withOSMESA=true
            ;;
    
    Henry's avatar
    Henry committed
        -no-mesa)
            withMESA=false
    
            withOSMESA=false
    
    Henry's avatar
    Henry committed
            ;;
    
        -mesa-prefix)
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
            withMESA=true
            MESA_INCLUDE="${2%%/}/include"
    
            # Could be under (lib64 | lib)
    
            MESA_LIBRARY="${2%%/}/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
    
            [ -f "$MESA_LIBRARY" ] || MESA_LIBRARY="${2%%/}/lib/libOSMesa.so"
    
    Henry's avatar
    Henry committed
        -mesa-include)
    
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
    
            withMESA=true
    
            MESA_INCLUDE="${2%%/}"
    
    Henry's avatar
    Henry committed
            ;;
        -mesa-lib)
    
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
    
            withMESA=true
    
            MESA_LIBRARY="${2%%/}"
    
    Henry's avatar
    Henry committed
            ;;
        -mpi)
            withMPI=true
            ;;
    
        -mpi=[0-9]*) # mpi and max mpi processes
            withMPI=true
            MPI_MAX_PROCS="${1##*=}"
            ;;
    
        -mpi-home) # mpi with hint
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
            withMPI=true
            export MPI_HOME="${2%%/}"
            case "${MPI_HOME:-none}" in (false|none) unset MPI_HOME;; esac
            shift
            ;;
    
    Henry's avatar
    Henry committed
        -no-mpi)
            withMPI=false
            ;;
        -python)
            withPYTHON=true
            ;;
    
        -python2)
            withPYTHON=true; withPYTHON3=false
            ;;
        -python3)
            withPYTHON=true; withPYTHON3=true
            ;;
    
    Henry's avatar
    Henry committed
        -no-python)
    
            withPYTHON=false; unset withPYTHON3
    
    Henry's avatar
    Henry committed
            ;;
    
        -python-include)
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
            withPYTHON=true
            PYTHON_INCLUDE="${2%%/}"
            shift
            ;;
    
    Henry's avatar
    Henry committed
        -python-lib)
    
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
    
            PYTHON_LIBRARY="${2%%/}"
    
    Henry's avatar
    Henry committed
            ;;
        -cmake)
    
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
    
            CMAKE_PATH="${2%%/}"
    
    Henry's avatar
    Henry committed
            ;;
        -qmake)
    
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
    
            QMAKE_PATH="${2%%/}"
    
    Henry's avatar
    Henry committed
            ;;
        -qt)
            withQT=true
            ;;
        -no-qt)
            withQT=false
            ;;
    
        -qt-[0-9]*)
    
    Henry's avatar
    Henry committed
            QMAKE_PATH="$installBASE/${1##-}"
            ;;
        -verbose)
            withVERBOSE=true
            ;;
        -version)
    
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
    
            setParaViewVersion "${2%%/}"
    
    Henry's avatar
    Henry committed
            ;;
        -major)
    
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
    
    Henry's avatar
    Henry committed
            export ParaView_MAJOR="$2"
    
    Henry's avatar
    Henry committed
            ;;
    
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
    
            BUILD_TYPE="$2"
    
        -suffix)
            [ "$#" -ge 2 ] || die "'$1' option requires an argument"
            setBuildSuffix "$2"
            shift
            ;;
    
    Henry's avatar
    Henry committed
        *)
    
            die "unknown option/argument: '$1'"
    
    Henry's avatar
    Henry committed
            ;;
        esac
    
    [ -n "$ParaView_VERSION" ] || die "The paraview-VERSION was not specified"
    
    
    Mark OLESEN's avatar
    Mark OLESEN committed
    # Nothing to build
    
    if _foamIsNone "$ParaView_VERSION"
    then
        echo "Using paraview-none (skip ThirdParty build of ParaView)"
        exit 0
    fi
    
    # Version-specific adjustments
    if [ "$withGL2" = auto ]
    then
        if [ "${ParaView_VERSION%%.*}" = 4 ]
        then
            withGL2=false
        else
            withGL2=true
        fi
    fi
    
    # ParaView-5.7.0 default is python3
    if [ "$withPYTHON" = true ] && [ -z "$withPYTHON3" ]
    then
        case "${ParaView_VERSION}" in
        (5.[7-9]* | [6-9]* | [1-9][0-9].*)
            withPYTHON3=true
            ;;
        esac
    fi
    
    
    Henry's avatar
    Henry committed
    if [ "$runDEFAULT" = true ]
    then
    
        : ${runPATCH:=true}
    
    Henry's avatar
    Henry committed
        : ${runCONFIG:=true}
        : ${runMAKE:=true}
        : ${runINSTALL:=true}
    fi
    
    
    if [ "$withMESA" = true ]
    then
        : ${withQT:=false}  # No QT unless explicitly requested
        addCMakeVariable "VTK_USE_X=OFF"
        # addCMakeVariable "OPENGL_INCLUDE_DIR=IGNORE"
        # addCMakeVariable "OPENGL_gl_LIBRARY=IGNORE"
        # addCMakeVariable "OPENGL_xmesa_INCLUDE_DIR=IGNORE"
        ## seems to be unnecessary => addCMakeVariable "VTK_USE_OFFSCREEN=OFF"
    fi
    
    
    Henry's avatar
    Henry committed
    
    # Set configure options
    #~~~~~~~~~~~~~~~~~~~~~~
    
    addGeneral          # general settings (version-dependent)
    
    Henry's avatar
    Henry committed
    addVerbosity        # verbose makefiles
    addMpiSupport       # set MPI-specific options
    addPythonSupport    # set Python-specific options
    addMesaSupport      # set MESA-specific options
    
    addGL2Support       # new rendering backend
    
    Henry's avatar
    Henry committed
    addQtSupport        # add extra Qt support
    
    
    setParaViewDirs     # where things are or should be put
    
    Henry's avatar
    Henry committed
    
    
    # Build and install
    # ~~~~~~~~~~~~~~~~~
    cat<<SUMMARY
    
    Build stages selected
    ---------------------
    
        -patch    ${runPATCH:-false}
    
    Henry's avatar
    Henry committed
        -config   ${runCONFIG:-false}
        -make     ${runMAKE:-false}
        -install  ${runINSTALL:-false}
    ---------------------
    Features selected
        mesa      ${withMESA:-false}
        mpi       ${withMPI:-false}
        python    ${withPYTHON:-false}
        qt        ${withQT:-false}
    ---------------------
    
    Compiler
        cxx       ${CXX:-unknown}
        flags     ${CXXFLAGS:-none}
    ---------------------
    
    Henry's avatar
    Henry committed
    Version information
    
        paraview  ${ParaView_VERSION:-unknown}
    
    Henry's avatar
    Henry committed
        major     ${ParaView_MAJOR:-unknown}
    
        build     ${BUILD_TYPE:-unknown}
    
    Henry's avatar
    Henry committed
    ---------------------
    SUMMARY
    
    
    [ "$runPATCH"   = true ] && patchParaView
    
    Henry's avatar
    Henry committed
    [ "$runCONFIG"  = true ] && configParaView
    [ "$runMAKE"    = true ] && makeParaView
    [ "$runINSTALL" = true ] && installParaView
    
    echo
    echo Done
    
    #------------------------------------------------------------------------------