Commit 02a9769e authored by Mark Olesen's avatar Mark Olesen

COMP: handle unset WM_OSTYPE for cmake targets (issue #909)

- regularise referencing of OpenFOAM env variables, sources etc.

CONFIG: cmake targets are globally unique

- unify CMakeLists naming and align content
parent 39500de6
......@@ -4,14 +4,21 @@ cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
# CMake into objectsDir with external dependency
# - Can this function can be removed with OpenFOAM-1812 ?
#
# 1 - depend
# 2 - sourceDir
# 3... optional cmake defines
#
# Available directly in OpenFOAM-1812 but left here for a while
# to ensure we can build with slightly older versions too (2018-11-29)
#
unset -f cmakeVersionedInstall 2>/dev/null
cmakeVersionedInstall()
{
local depend="$1"
local sourceDir="$2"
local objectsDir
shift 2
local objectsDir sentinel
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
......@@ -20,8 +27,8 @@ cmakeVersionedInstall()
sentinel=$(sameDependency "$depend" "$sourceDir") || \
rm -rf "$objectsDir" > /dev/null 2>&1
mkdir -p $objectsDir \
&& (cd $objectsDir && _cmake "$@" $sourceDir && make install) \
mkdir -p "$objectsDir" \
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make install) \
&& echo "$depend" >| "${sentinel:-/dev/null}"
}
......
#------------------------------------------------------------------------------
# Standard definitions when using OpenFOAM
if (NOT EXISTS "$ENV{WM_PROJECT_DIR}")
message(FATAL_ERROR "WM_PROJECT_DIR not set - no OpenFOAM??")
endif()
# WM_OSTYPE env variable is optional (only POSIX anyhow)
if (EXISTS "$ENV{WM_OSTYPE}")
set(WM_OSTYPE "$ENV{WM_OSTYPE}")
else()
set(WM_OSTYPE "POSIX")
endif()
# Convenience name, as per wmake internals
set(LIB_SRC "$ENV{WM_PROJECT_DIR}/src")
# Needed for internal label-size, scalar-size, templates
add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
-DNoRepository
)
set(CMAKE_CXX_FLAGS_DEBUG
"-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
set(CMAKE_CXX_FLAGS_RELEASE
"-O3 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
#-----------------------------------------------------------------------------
include(${PARAVIEW_USE_FILE})
include_directories(
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteArea/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
$ENV{WM_PROJECT_DIR}/src/fileFormats/lnInclude
$ENV{WM_PROJECT_DIR}/src/conversion/lnInclude
$ENV{WM_PROJECT_DIR}/src/meshTools/lnInclude
$ENV{WM_PROJECT_DIR}/src/lagrangian/basic/lnInclude
$ENV{WM_PROJECT_DIR}/src/overset/lnInclude
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
link_directories(
$ENV{FOAM_LIBBIN}
$ENV{FOAM_LIBBIN}/dummy
)
add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION} -DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
-DNoRepository
)
set(CMAKE_BUILD_TYPE Release)
#------------------------------------------------------------------------------
project(catalyst)
set(CMAKE_CXX_FLAGS_DEBUG
"-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
set(CMAKE_CXX_FLAGS_RELEASE
"-O3 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
include(${PARAVIEW_USE_FILE})
# Some characteristics
# ----------------------------------------------------------------------
# Test some characteristics
set(test_file ${CMAKE_CURRENT_BINARY_DIR}/check_initialize.cxx)
file(WRITE ${test_file}
"#include <vtkCPProcessor.h>\n"
......@@ -55,6 +26,29 @@ else()
message(WARNING "==== CAUTION: ParaView Catalyst without chdir capability ====")
endif()
# ----------------------------------------------------------------------
include_directories(
${LIB_SRC}/OpenFOAM/lnInclude
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
${LIB_SRC}/finiteArea/lnInclude
${LIB_SRC}/finiteVolume/lnInclude
${LIB_SRC}/fileFormats/lnInclude
${LIB_SRC}/conversion/lnInclude
${LIB_SRC}/meshTools/lnInclude
${LIB_SRC}/lagrangian/basic/lnInclude
${LIB_SRC}/overset/lnInclude
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
link_directories(
$ENV{FOAM_LIBBIN}
$ENV{FOAM_LIBBIN}/dummy
)
set(CMAKE_BUILD_TYPE Release)
file(GLOB SOURCE_FILES
catalystCoprocess.C
......
#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0002 NEW) # Policy CMP0002 required for for cmake >= 3
# Fail immediately if not using an out-of-source build
# Fail if not building out-of-source
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
message(FATAL_ERROR
"In-source builds are not supported. Please create a build directory "
"separate from the source directory")
"In-source builds disallowed. Use a separate build directory")
endif()
project(catalyst)
# Set policy for CMP0002 needed for cmake > 3
cmake_policy(SET CMP0002 OLD)
include(CMakeLists-OpenFOAM.txt)
#------------------------------------------------------------------------------
# Simple sanity checks
if (NOT EXISTS "$ENV{WM_PROJECT_DIR}")
message(FATAL_ERROR "WM_PROJECT_DIR not set")
endif()
if (EXISTS "$ENV{ParaView_DIR}")
find_package(ParaView REQUIRED COMPONENTS vtkPVPythonCatalyst)
else()
......@@ -43,6 +35,6 @@ message("================")
#-----------------------------------------------------------------------------
include(CMakeLists-Common.txt)
include(CMakeLists-Project.txt)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Standard definitions when using OpenFOAM
if (NOT EXISTS "$ENV{WM_PROJECT_DIR}")
message(FATAL_ERROR "WM_PROJECT_DIR not set - no OpenFOAM??")
endif()
# WM_OSTYPE env variable is optional (only POSIX anyhow)
if (EXISTS "$ENV{WM_OSTYPE}")
set(WM_OSTYPE "$ENV{WM_OSTYPE}")
else()
set(WM_OSTYPE "POSIX")
endif()
# Convenience name, as per wmake internals
set(LIB_SRC "$ENV{WM_PROJECT_DIR}/src")
# Needed for internal label-size, scalar-size, templates
add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
-DNoRepository
-std=c++11
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# OpenFOAM reader plugin for ParaView GUI
link_directories(
$ENV{FOAM_LIBBIN}
)
include_directories(
${LIB_SRC}/OpenFOAM/lnInclude
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
${LIB_SRC}/conversion/lnInclude
${LIB_SRC}/finiteArea/lnInclude
${LIB_SRC}/finiteVolume/lnInclude
${PROJECT_SOURCE_DIR}/../foamPv
${PROJECT_SOURCE_DIR}/../vtkPVFoam
)
set(OPENFOAM_LIBRARIES
OpenFOAM
finiteVolume
finiteArea
conversion
)
# Set output library destination to plugin directory
set(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
CACHE INTERNAL
"Single output directory for building all libraries."
)
if (PARAVIEW_QT_VERSION VERSION_GREATER "4")
qt5_wrap_cpp(MOC_SRCS pqFoamReaderControls.h)
else()
qt4_wrap_cpp(MOC_SRCS pqFoamReaderControls.h)
endif()
add_paraview_property_group_widget(IFACES0 IFACES0_SRCS
TYPE "openfoam_reader_general_controls"
CLASS_NAME pqFoamReaderControls
)
add_paraview_plugin(
PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVFoamReader.cxx
GUI_INTERFACES
${IFACES0}
SOURCES
${IFACES0_SRCS}
${MOC_SRCS}
pqFoamReaderControls.cxx
)
target_link_libraries(
PVFoamReader_SM
LINK_PUBLIC
vtkPVFoam-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
${OPENFOAM_LIBRARIES}
)
#-----------------------------------------------------------------------------
# Create a plugin to add a reader to the ParaView GUI
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0002 NEW) # Policy CMP0002 required for for cmake >= 3
find_package(ParaView REQUIRED)
include(${PARAVIEW_USE_FILE})
link_directories(
$ENV{FOAM_LIBBIN}
)
include_directories(
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/conversion/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteArea/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
${PROJECT_SOURCE_DIR}/../foamPv
${PROJECT_SOURCE_DIR}/../vtkPVFoam
)
add_definitions(
-std=c++11
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
)
# Set output library destination to plugin directory
set(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
CACHE INTERNAL
"Single output directory for building all libraries."
)
if (PARAVIEW_QT_VERSION VERSION_GREATER "4")
qt5_wrap_cpp(MOC_SRCS
pqFoamReaderControls.h
)
else()
qt4_wrap_cpp(MOC_SRCS
pqFoamReaderControls.h
)
# Fail if not building out-of-source
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
message(FATAL_ERROR
"In-source builds disallowed. Use a separate build directory")
endif()
add_paraview_property_group_widget(IFACES0 IFACES0_SRCS
TYPE "openfoam_reader_general_controls"
CLASS_NAME pqFoamReaderControls
)
#-----------------------------------------------------------------------------
# Simple discovery and sanity checks
add_paraview_plugin(
PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVFoamReader.cxx
GUI_INTERFACES
${IFACES0}
SOURCES
${IFACES0_SRCS}
${MOC_SRCS}
pqFoamReaderControls.cxx
)
find_package(ParaView REQUIRED)
include(${PARAVIEW_USE_FILE})
#-----------------------------------------------------------------------------
target_link_libraries(
PVFoamReader_SM
LINK_PUBLIC
vtkPVFoam-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
conversion
finiteArea
finiteVolume
OpenFOAM
)
include(CMakeLists-OpenFOAM.txt)
include(CMakeLists-Project.txt)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Standard definitions when using OpenFOAM
if (NOT EXISTS "$ENV{WM_PROJECT_DIR}")
message(FATAL_ERROR "WM_PROJECT_DIR not set - no OpenFOAM??")
endif()
# WM_OSTYPE env variable is optional (only POSIX anyhow)
if (EXISTS "$ENV{WM_OSTYPE}")
set(WM_OSTYPE "$ENV{WM_OSTYPE}")
else()
set(WM_OSTYPE "POSIX")
endif()
# Convenience name, as per wmake internals
set(LIB_SRC "$ENV{WM_PROJECT_DIR}/src")
# Needed for internal label-size, scalar-size, templates
add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
-DNoRepository
-std=c++11
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# OpenFOAM blockMeshDict reader plugin for ParaView GUI
link_directories(
$ENV{FOAM_LIBBIN}
)
include_directories(
${LIB_SRC}/OpenFOAM/lnInclude
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
${LIB_SRC}/meshing/blockMesh/lnInclude
${PROJECT_SOURCE_DIR}/../foamPv
${PROJECT_SOURCE_DIR}/../vtkPVblockMesh
)
set(OPENFOAM_LIBRARIES
OpenFOAM
blockMesh
)
# Set output library destination to plugin directory
set(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
CACHE INTERNAL
"Single output directory for building all libraries."
)
if (PARAVIEW_QT_VERSION VERSION_GREATER "4")
qt5_wrap_cpp(MOC_SRCS pqFoamBlockMeshControls.h)
else()
qt4_wrap_cpp(MOC_SRCS pqFoamBlockMeshControls.h)
endif()
add_paraview_property_group_widget(IFACES0 IFACES0_SRCS
TYPE "openfoam_blockMesh_general_controls"
CLASS_NAME pqFoamBlockMeshControls
)
add_paraview_plugin(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES
${IFACES0}
SOURCES
${IFACES0_SRCS}
${MOC_SRCS}
pqFoamBlockMeshControls.cxx
)
target_link_libraries(
PVblockMeshReader_SM
LINK_PUBLIC
vtkPVblockMesh-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
${OPENFOAM_LIBRARIES}
)
#-----------------------------------------------------------------------------
# Create a plugin to add a reader to the ParaView GUI
cmake_minimum_required(VERSION 2.6)
find_package(ParaView REQUIRED)
include(${PARAVIEW_USE_FILE})
link_directories(
$ENV{FOAM_LIBBIN}
)
include_directories(
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/meshing/blockMesh/lnInclude
${PROJECT_SOURCE_DIR}/../foamPv
${PROJECT_SOURCE_DIR}/../vtkPVblockMesh
)
add_definitions(
-std=c++11
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
)
# Set output library destination to plugin directory
set(
LIBRARY_OUTPUT_PATH $ENV{PV_PLUGIN_PATH}
CACHE INTERNAL
"Single output directory for building all libraries."
)
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0002 NEW) # Policy CMP0002 required for for cmake >= 3
if (PARAVIEW_QT_VERSION VERSION_GREATER "4")
qt5_wrap_cpp(MOC_SRCS
pqFoamBlockMeshControls.h
)
else()
qt4_wrap_cpp(MOC_SRCS
pqFoamBlockMeshControls.h
)
# Fail if not building out-of-source
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
message(FATAL_ERROR
"In-source builds disallowed. Use a separate build directory")
endif()
add_paraview_property_group_widget(IFACES0 IFACES0_SRCS
TYPE "openfoam_blockMesh_general_controls"
CLASS_NAME pqFoamBlockMeshControls
)
#-----------------------------------------------------------------------------
# Simple discovery and sanity checks
add_paraview_plugin(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES
${IFACES0}
SOURCES
${IFACES0_SRCS}
${MOC_SRCS}
pqFoamBlockMeshControls.cxx
)
find_package(ParaView REQUIRED)
include(${PARAVIEW_USE_FILE})
#-----------------------------------------------------------------------------
target_link_libraries(
PVblockMeshReader_SM
LINK_PUBLIC
vtkPVblockMesh-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
foamPv-pv${PARAVIEW_VERSION_MAJOR}.${PARAVIEW_VERSION_MINOR}
blockMesh
OpenFOAM
)
include(CMakeLists-OpenFOAM.txt)
include(CMakeLists-Project.txt)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Standard definitions when using OpenFOAM
if (NOT EXISTS "$ENV{WM_PROJECT_DIR}")
message(FATAL_ERROR "WM_PROJECT_DIR not set - no OpenFOAM??")
endif()
# WM_OSTYPE env variable is optional (only POSIX anyhow)
if (EXISTS "$ENV{WM_OSTYPE}")
set(WM_OSTYPE "$ENV{WM_OSTYPE}")
else()
set(WM_OSTYPE "POSIX")
endif()
# Convenience name, as per wmake internals
set(LIB_SRC "$ENV{WM_PROJECT_DIR}/src")
# Needed for internal label-size, scalar-size, templates
add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
-DNoRepository
)
set(CMAKE_CXX_FLAGS_DEBUG
"-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
set(CMAKE_CXX_FLAGS_RELEASE
"-O3 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
project(runTimePostProcessing)
include(${VTK_USE_FILE})
if(VTK_LIBRARIES)
......@@ -7,15 +10,15 @@ endif()
if(${VTK_VERSION} VERSION_GREATER "6")
message("VTK version: " ${VTK_VERSION})
else()
message(FATAL_ERROR " VTK6 required")
message(FATAL_ERROR " VTK version is too old - requires VTK6 or newer")
endif()
include_directories(
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
$ENV{WM_PROJECT_DIR}/src/surfMesh/lnInclude
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
$ENV{WM_PROJECT_DIR}/src/conversion/lnInclude
${LIB_SRC}/OpenFOAM/lnInclude
${LIB_SRC}/OSspecific/${WM_OSTYPE}/lnInclude
${LIB_SRC}/finiteVolume/lnInclude
${LIB_SRC}/surfMesh/lnInclude
${LIB_SRC}/conversion/lnInclude
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
......@@ -24,23 +27,10 @@ link_directories(
$ENV{FOAM_LIBBIN}
)
add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION} -DNoRepository
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS_DEBUG
"-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++11")
set(CMAKE_CXX_FLAGS_RELEASE
"-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
# Build intermediate (library) directly into the OpenFOAM libdir
# - implies CMAKE_INSTALL_PREFIX is ignored and there is no 'install' phase
set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN}
CACHE INTERNAL
""
......@@ -72,8 +62,8 @@ file(GLOB SOURCE_FILES
set(OPENFOAM_LIBRARIES
OpenFOAM
surfMesh
finiteVolume
surfMesh
conversion
)
......@@ -84,10 +74,10 @@ add_library(
)
set_target_properties(
runTimePostProcessing
PROPERTIES
VERSION ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}
SOVERSION ${VTK_MAJOR_VERSION}
runTimePostProcessing
PROPERTIES
VERSION ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}
SOVERSION ${VTK_MAJOR_VERSION}
)
target_link_libraries(
......