diff --git a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake index 2f89bc4c8a..13eb3a9470 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake @@ -7,84 +7,8 @@ export WM_CONTINUE_ON_ERROR=true # Parse arguments for library compilation . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments -# Source the wmake functions -. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions - -# ----------------------------------------------------------------------------- - -# -# There are several prerequisites for building plugins -# -#set -x -canBuildPlugin() -{ - [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] || { - echo "==> cannot build ParaView plugins without paraview directory" - echo " ParaView_DIR=$ParaView_DIR" - return 1 - } - - [ -n "$PV_PLUGIN_PATH" ] || { - echo "==> ${PWD##*/} : invalid PV_PLUGIN_PATH for building ParaView plugins" - echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-unset}" - return 1 - } - - type cmake > /dev/null 2>&1 || { - echo "==> cannot build ParaView plugins without cmake" - return 1 - } - - return 0 # success -} - - -# -# Check sentinel file(s) to handle paraview version changes -# -versionOk() -{ - findObjectDir "$1" # Where generated files are stored - local sentinel="$objectsDir/ThirdParty" - - echo $sentinel - - local prev - if read -r prev 2>/dev/null < $sentinel - then - case "$prev" in - ("ParaView_DIR=$ParaView_DIR") - return 0 - ;; - (*) - echo "ParaView_DIR changed between builds" 1>&2 - return 1 - ;; - esac - elif [ -f "$objectsDir/CMakeCache.txt" ] - then - echo "previous build was incomplete" 1>&2 - return 1 - else - return 0 - fi -} - - -# -# Build library - use sentinel file(s) to handle paraview version changes -# -wmakeLibPv() -{ - for libName - do - sentinel=$(versionOk $libName) || wclean $libName # version changed - wmake $targetType $libName && { - echo "ParaView_DIR=$ParaView_DIR" > $sentinel - } - done -} - +# Source CMake functions +. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # ----------------------------------------------------------------------------- diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwmake index afba137322..b9f216f54e 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwmake @@ -4,94 +4,8 @@ cd ${0%/*} || exit 1 # Run from this directory # Parse arguments for library compilation . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments -# Source the wmake functions -. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions - -# Ensure CMake gets the correct C/C++ compilers -[ -n "$WM_CC" ] && export CC="$WM_CC" -[ -n "$WM_CXX" ] && export CXX="$WM_CXX" - -# ----------------------------------------------------------------------------- - -# -# Check sentinel file(s) to handle paraview version changes -# -versionOk() -{ - findObjectDir "$1" # Where generated files are stored - local sentinel="$objectsDir/ThirdParty" - - echo $sentinel - - local prev - if read -r prev 2>/dev/null < $sentinel - then - case "$prev" in - ("ParaView_DIR=$ParaView_DIR") - return 0 - ;; - (*) - echo "ParaView_DIR changed between builds" 1>&2 - return 1 - ;; - esac - elif [ -f "$objectsDir/CMakeCache.txt" ] - then - echo "previous build was incomplete" 1>&2 - return 1 - else - return 0 - fi -} - - -# CMake into objectsDir, -# with an additional attempt if (possibly incorrect) CMakeCache.txt existed -doCmake() -{ - local sourceDir="$1" - findObjectDir $sourceDir # Where are generated files stored? - - # version changed - sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1 - - test -f "$objectsDir/CMakeCache.txt" - retry=$? # CMakeCache.txt exists, but sources may have moved - - mkdir -p $objectsDir && \ - ( - cd $objectsDir || exit 1 - - cmake $sourceDir || { - if [ $retry -eq 0 ] - then - echo "Removing CMakeCache.txt and attempt again" - rm -f CMakeCache.txt - cmake $sourceDir - else - exit 1 - fi - } && make && { - echo "ParaView_DIR=$ParaView_DIR" > $sentinel - } - ) -} - - -# -# Build library - use sentinel file(s) to handle paraview version changes -# -wmakeLibPv() -{ - for libName - do - sentinel=$(versionOk $libName) || wclean $libName # version changed - wmake $targetType $libName && { - echo "ParaView_DIR=$ParaView_DIR" > $sentinel - } - done -} - +# Source CMake functions +. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # ----------------------------------------------------------------------------- @@ -101,7 +15,7 @@ then if [ "$targetType" != objects ] then - doCmake $PWD/PVFoamReader || { + cmakePv $PWD/PVFoamReader || { echo echo " WARNING: incomplete build of ParaView OpenFOAM plugin" echo diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwmake index 844b129306..24d577b2ae 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwmake @@ -4,94 +4,8 @@ cd ${0%/*} || exit 1 # Run from this directory # Parse arguments for library compilation . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments -# Source the wmake functions -. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions - -# Ensure CMake gets the correct C/C++ compilers -[ -n "$WM_CC" ] && export CC="$WM_CC" -[ -n "$WM_CXX" ] && export CXX="$WM_CXX" - -# ----------------------------------------------------------------------------- - -# -# Check sentinel file(s) to handle paraview version changes -# -versionOk() -{ - findObjectDir "$1" # Where generated files are stored - local sentinel="$objectsDir/ThirdParty" - - echo $sentinel - - local prev - if read -r prev 2>/dev/null < $sentinel - then - case "$prev" in - ("ParaView_DIR=$ParaView_DIR") - return 0 - ;; - (*) - echo "ParaView_DIR changed between builds" 1>&2 - return 1 - ;; - esac - elif [ -f "$objectsDir/CMakeCache.txt" ] - then - echo "previous build was incomplete" 1>&2 - return 1 - else - return 0 - fi -} - - -# CMake into objectsDir, -# with an additional attempt if (possibly incorrect) CMakeCache.txt existed -doCmake() -{ - local sourceDir="$1" - findObjectDir $sourceDir # Where are generated files stored? - - # version changed - sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1 - - test -f "$objectsDir/CMakeCache.txt" - retry=$? # CMakeCache.txt exists, but sources may have moved - - mkdir -p $objectsDir && \ - ( - cd $objectsDir || exit 1 - - cmake $sourceDir || { - if [ $retry -eq 0 ] - then - echo "Removing CMakeCache.txt and attempt again" - rm -f CMakeCache.txt - cmake $sourceDir - else - exit 1 - fi - } && make && { - echo "ParaView_DIR=$ParaView_DIR" > $sentinel - } - ) -} - - -# -# Build library - use sentinel file(s) to handle paraview version changes -# -wmakeLibPv() -{ - for libName - do - sentinel=$(versionOk $libName) || wclean $libName # version changed - wmake $targetType $libName && { - echo "ParaView_DIR=$ParaView_DIR" > $sentinel - } - done -} - +# Source CMake functions +. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # ----------------------------------------------------------------------------- @@ -101,7 +15,7 @@ then if [ "$targetType" != objects ] then - doCmake $PWD/PVblockMeshReader || { + cmakePv $PWD/PVblockMeshReader || { echo echo " WARNING: incomplete build of ParaView BlockMesh plugin" echo diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwmake b/src/functionObjects/graphics/runTimePostProcessing/Allwmake index 66ba0b7cc1..d7d73741dc 100755 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwmake +++ b/src/functionObjects/graphics/runTimePostProcessing/Allwmake @@ -1,87 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory -# Source the wmake functions -. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions - -# Ensure CMake gets the correct C/C++ compilers -[ -n "$WM_CC" ] && export CC="$WM_CC" -[ -n "$WM_CXX" ] && export CXX="$WM_CXX" - -# ----------------------------------------------------------------------------- - -# -# Check sentinel file(s) to handle vtk/paraview version changes -# -versionOk() -{ - findObjectDir "$1" # Where generated files are stored - local sentinel="$objectsDir/ThirdParty" - - echo $sentinel - - local prev - if read -r prev 2>/dev/null < $sentinel - then - case "$prev" in - ("ParaView_DIR=$ParaView_DIR" | "VTK_DIR=$VTK_DIR") - return 0 - ;; - (*) - echo "ParaView_DIR or VTK_DIR changed between builds" 1>&2 - return 1 - ;; - esac - elif [ -f "$objectsDir/CMakeCache.txt" ] - then - echo "previous build was incomplete" 1>&2 - return 1 - else - return 0 - fi -} - - -# CMake into objectsDir, -# with an additional attempt if (possibly incorrect) CMakeCache.txt existed -doCmake() -{ - local sourceDir="$1" - findObjectDir $sourceDir # Where are generated files stored? - - # version changed - sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1 - - test -f "$objectsDir/CMakeCache.txt" - retry=$? # CMakeCache.txt exists, but sources may have moved - - mkdir -p $objectsDir && \ - ( - cd $objectsDir || exit 1 - - cmake $sourceDir || { - if [ $retry -eq 0 ] - then - echo "Removing CMakeCache.txt and attempt again" - rm -f CMakeCache.txt - cmake $sourceDir - else - exit 1 - fi - } && make && { - if [ -d "$VTK_DIR" ] - then - echo "VTK_DIR=$VTK_DIR" - elif [ -d "$ParaView_DIR" ] - then - echo "ParaView_DIR=$ParaView_DIR" - else - echo unknown - fi > $sentinel - } - ) -} - +# Source CMake functions +. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # ----------------------------------------------------------------------------- @@ -89,13 +10,22 @@ echo "======================================================================" echo "${PWD##*/} : $PWD" echo -if [ -d "$VTK_DIR" -o -d "$ParaView_DIR" ] +unset depend +if [ -d "$VTK_DIR" ] +then + depend="VTK_DIR=$VTK_DIR" +elif [ -d "$ParaView_DIR" ] +then + depend="ParaView_DIR=$ParaView_DIR" +fi + +if [ -n "$depend" ] then if [ "$targetType" != objects ] then if type cmake > /dev/null 2>&1 then - doCmake $PWD || { + cmakeVersioned "$depend" $PWD || { echo echo " WARNING: incomplete build of VTK-based post-processing" echo diff --git a/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-Common.txt b/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-Common.txt index 3e7a61e625..3f23c20c3e 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-Common.txt +++ b/src/functionObjects/graphics/runTimePostProcessing/CMakeLists-Common.txt @@ -32,13 +32,13 @@ add_definitions( set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_FLAGS_DEBUG - "-g -O0 -std=c++0x -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual" + "-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual" ) -set(CMAKE_C_FLAGS_DEBUG "-g -O0 -std=c++0x") +set(CMAKE_C_FLAGS_DEBUG "-g -O0 -std=c++11") set(CMAKE_CXX_FLAGS_RELEASE - "-O3 -std=c++0x -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual") -set(CMAKE_C_FLAGS_RELEASE "-O3 -std=c++0x") + "-O3 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual") +set(CMAKE_C_FLAGS_RELEASE "-O3 -std=c++11") # Set output library destination to plugin directory set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN} @@ -46,6 +46,12 @@ set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN} "" ) +## Record VTK version for general bookkeeping +# file(WRITE +# ${CMAKE_BINARY_DIR}/version +# "VTK_VERSION=${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}\n" +# ) + file(GLOB SOURCE_FILES fieldVisualisationBase.C functionObjectBase.C @@ -75,11 +81,17 @@ add_library( ${SOURCE_FILES} ) +set_target_properties( + runTimePostProcessing + PROPERTIES + VERSION ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION} + SOVERSION ${VTK_MAJOR_VERSION} +) + target_link_libraries( runTimePostProcessing ${VTK_LIBRARIES} ${OPENFOAM_LIBRARIES} ) - #----------------------------------------------------------------------------- diff --git a/wmake/scripts/cmakeFunctions b/wmake/scripts/cmakeFunctions new file mode 100644 index 0000000000..a95e686aea --- /dev/null +++ b/wmake/scripts/cmakeFunctions @@ -0,0 +1,163 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM. If not, see . +# +# Script +# cmakeFunctions +# +# Description +# Helper functions for CMake +#------------------------------------------------------------------------------ + +# Source the wmake functions +. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions + +# Ensure CMake gets the correct C/C++ compilers +[ -n "$WM_CC" ] && export CC="$WM_CC" +[ -n "$WM_CXX" ] && export CXX="$WM_CXX" + + +#------------------------------------------------------------------------------ + +# +# Check sentinel file(s) to handle paraview / vtk version changes +# +sameDependency() +{ + local depend="$1" + findObjectDir "$2" # Where generated files are stored + local sentinel="$objectsDir/ThirdParty" + + echo $sentinel + + local prev + if read -r prev 2>/dev/null < $sentinel + then + if [ "$prev" = "$depend" ] + then + return 0 + else + echo "${depend%=*} changed between builds" 1>&2 + return 1 + fi + elif [ -f "$objectsDir/CMakeCache.txt" ] + then + echo "previous build was incomplete" 1>&2 + return 1 + else + return 0 + fi +} + + +# CMake into objectsDir with external dependency +cmakeVersioned() +{ + local depend="$1" + local sourceDir="$2" + findObjectDir $sourceDir # Where are generated files stored? + + local sentinel + + # version changed + sentinel=$(sameDependency "$depend" "$sourceDir") \ + || rm -rf "$objectsDir" > /dev/null 2>&1 + + test -f "$objectsDir/CMakeCache.txt" + retry=$? # Additional attempt if sources moved + + mkdir -p $objectsDir && \ + ( + cd $objectsDir || exit 1 + + cmake $sourceDir || { + if [ $retry -eq 0 ] + then + echo "Removing CMakeCache.txt and attempt again" 1>&2 + rm -f CMakeCache.txt + cmake $sourceDir + else + exit 1 + fi + } && make && { echo "$depend" > $sentinel; } + ) +} + + +# CMake into objectsDir with VTK_DIR dependency +cmakeVtk() +{ + cmakeVersioned "VTK_DIR=$VTK_DIR" "$1" +} + + +# CMake into objectsDir with ParaView_DIR dependency +cmakePv() +{ + cmakeVersioned "ParaView_DIR=$ParaView_DIR" "$1" +} + + +# +# Build library - use sentinel file(s) to handle paraview version changes +# +wmakeLibPv() +{ + local depend="ParaView_DIR=$ParaView_DIR" + local sentinel + + for libName + do + # version changed + sentinel=$(sameDependency "$depend" $libName) || wclean $libName + wmake $targetType $libName && { echo "$depend" > $sentinel; } + done +} + + +# +# There are several prerequisites for building plugins +# +canBuildPlugin() +{ + [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] || { + echo "==> cannot build ParaView plugins without paraview directory" + echo " ParaView_DIR=$ParaView_DIR" + return 1 + } + + [ -n "$PV_PLUGIN_PATH" ] || { + echo "==> ${PWD##*/} : invalid PV_PLUGIN_PATH for building ParaView plugins" + echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-unset}" + return 1 + } + + type cmake > /dev/null 2>&1 || { + echo "==> cannot build ParaView plugins without cmake" + return 1 + } + + return 0 # success +} + + +#------------------------------------------------------------------------------ diff --git a/wmake/scripts/wmakeFunctions b/wmake/scripts/wmakeFunctions old mode 100755 new mode 100644 index 0262350c20..7a12ad0545 --- a/wmake/scripts/wmakeFunctions +++ b/wmake/scripts/wmakeFunctions @@ -1,11 +1,10 @@ -#!/bin/sh -#------------------------------------------------------------------------------ +#----------------------------------*-sh-*-------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation # \\/ M anipulation | -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. #