Commit 9bc0deca authored by Mark Olesen's avatar Mark Olesen

COMP: update MPI detection for runTimePostProcessing

parent 8f05fcbb
......@@ -20,13 +20,14 @@ add_definitions(
-DWM_$ENV{WM_PRECISION_OPTION}
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
-DNoRepository
-std=c++11
)
set(CMAKE_CXX_FLAGS_DEBUG
"-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
"-g -O0 -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"
"-O3 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
project(runTimePostProcessing)
message("VTK version: " ${VTK_VERSION})
set(CMAKE_BUILD_TYPE Release)
if(${VTK_VERSION_MAJOR} LESS 6)
message(FATAL_ERROR " VTK version is too old - requires VTK6 or newer")
endif()
#-----------------------------------------------------------------------------
unset(LINK_LIBRARIES)
unset(FOAM_USING_VTK_MPI)
# Test some characteristics
set(test_file ${CMAKE_CURRENT_BINARY_DIR}/check_mpi.cxx)
file(WRITE ${test_file}
"#include <vtkMPICommunicator.h>\n"
"int main() {\n"
" vtkMPICommunicator* p = vtkMPICommunicator::New();\n"
" p->Delete();\n"
" return 0;\n"
"}"
)
try_compile(FOAM_USING_VTK_MPI
${CMAKE_CURRENT_BINARY_DIR} ${test_file}
LINK_LIBRARIES vtkParallelMPI
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${VTK_INCLUDE_DIRS}"
)
if (${ParaView_VERSION} GREATER_EQUAL 5.7)
if (TARGET "VTK::ParallelMPI")
set(FOAM_USING_VTK_MPI TRUE)
endif()
elseif (${VTK_VERSION} LESS 8.90)
# Older way to test for VTK MPI
set(test_file ${CMAKE_CURRENT_BINARY_DIR}/check_mpi.cxx)
file(WRITE ${test_file}
"#include <vtkMPICommunicator.h>\n"
"int main() {\n"
" vtkMPICommunicator* p = vtkMPICommunicator::New();\n"
" p->Delete();\n"
" return 0;\n"
"}"
)
try_compile(FOAM_USING_VTK_MPI
${CMAKE_CURRENT_BINARY_DIR} ${test_file}
LINK_LIBRARIES vtkParallelMPI
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${VTK_INCLUDE_DIRS}"
)
if (FOAM_USING_VTK_MPI)
include(vtkMPI)
set(LINK_LIBRARIES vtkParallelMPI)
endif()
elseif (${ParaView_VERSION} LESS_EQUAL 0)
#TODO if (TARGET "ParallelMPI")
#TODO set(FOAM_USING_VTK_MPI TRUE)
#TODO endif()
endif()
#-----------------------------------------------------------------------------
if (FOAM_USING_VTK_MPI)
add_definitions(-DFOAM_USING_VTK_MPI)
message("Building with VTK MPI")
include(vtkMPI)
else()
message(WARNING "==== Building without VTK MPI ====")
endif()
#-----------------------------------------------------------------------------
link_directories(
$ENV{FOAM_LIBBIN}
)
include_directories(
${LIB_SRC}/OpenFOAM/include
${LIB_SRC}/OpenFOAM/lnInclude
......@@ -45,12 +72,6 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
link_directories(
$ENV{FOAM_LIBBIN}
)
set(CMAKE_BUILD_TYPE Release)
# 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}
......@@ -98,12 +119,6 @@ set(OPENFOAM_LIBRARIES
conversion
)
if (FOAM_USING_VTK_MPI)
set(LINK_LIBRARIES vtkParallelMPI)
else()
set(LINK_LIBRARIES)
endif()
add_library(
runTimePostProcessing
SHARED
......
#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0002 NEW) # Policy CMP0002 required for for cmake >= 3
cmake_policy(SET CMP0002 NEW) # For cmake >= 3
cmake_policy(SET CMP0057 NEW) # For cmake >= 3.10.2
# Fail if not building out-of-source
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
......@@ -11,15 +12,22 @@ endif()
#-----------------------------------------------------------------------------
# Simple discovery and sanity checks
set(ParaView_VERSION 0)
unset(VTK_VERSION)
unset(VTK_VERSION_MAJOR)
if (EXISTS "$ENV{VTK_DIR}")
message("Building with VTK from $ENV{VTK_DIR}")
find_package(VTK REQUIRED HINTS $ENV{VTK_DIR})
find_package(VTK REQUIRED)
elseif (EXISTS "$ENV{ParaView_DIR}")
message("Building with Paraview from $ENV{ParaView_DIR}")
find_package(ParaView REQUIRED HINTS $ENV{ParaView_DIR})
find_package(ParaView REQUIRED)
if (${ParaView_VERSION} GREATER_EQUAL 5.7)
find_package(ParaView REQUIRED
OPTIONAL_COMPONENTS VTK::ParallelMPI)
endif()
else()
message(FATAL_ERROR "VTK not found using VTK_DIR or ParaView_DIR")
endif()
......@@ -47,6 +55,23 @@ if (VTK_MAJOR_VERSION AND NOT VTK_VERSION_MAJOR)
endif()
endif()
if (${ParaView_VERSION} GREATER 0)
# Newer VTK - try to load optional MPI?
if (${VTK_VERSION} GREATER 8.2)
find_package(VTK REQUIRED OPTIONAL_COMPONENTS ParallelMPI)
endif()
endif()
#-----------------------------------------------------------------------------
message("================")
if (${ParaView_VERSION} GREATER 0)
message("Using ParaView ${ParaView_VERSION} (VTK ${VTK_VERSION})")
else()
message("Using VTK ${VTK_VERSION}")
endif()
message("================")
#-----------------------------------------------------------------------------
include(CMakeLists-OpenFOAM.txt)
......
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