Make sure we don't leak our findmpi module

Consumers of VTK-m shouldn't use VTK-m find mpi module unless
they explicitly want to. This makes sure that by default only
VTK-m uses it.
This commit is contained in:
Robert Maynard 2020-06-18 15:48:48 -04:00
parent 45c29a0c62
commit 7092bb9210
6 changed files with 38 additions and 28 deletions

@ -0,0 +1,23 @@
##============================================================================
## Copyright (c) Kitware, Inc.
## All rights reserved.
## See LICENSE.txt for details.
##
## This software is distributed WITHOUT ANY WARRANTY; without even
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notice for more information.
##============================================================================
file(GLOB cmake_version_backports
LIST_DIRECTORIES true
RELATIVE "${CMAKE_CURRENT_LIST_DIR}/patches"
"${CMAKE_CURRENT_LIST_DIR}/patches/*")
foreach (cmake_version_backport IN LISTS cmake_version_backports)
if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/patches/${cmake_version_backport}")
continue ()
endif ()
if (CMAKE_VERSION VERSION_LESS "${cmake_version_backport}")
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/patches/${cmake_version_backport}")
endif ()
endforeach ()

@ -1,24 +0,0 @@
##============================================================================
## Copyright (c) Kitware, Inc.
## All rights reserved.
## See LICENSE.txt for details.
##
## This software is distributed WITHOUT ANY WARRANTY; without even
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notice for more information.
##============================================================================
if(VTKm_ENABLE_MPI AND NOT TARGET MPI::MPI_CXX)
if(CMAKE_VERSION VERSION_LESS 3.15)
#While CMake 3.10 introduced the new MPI module.
#Fixes related to MPI+CUDA that VTK-m needs are
#only found in CMake 3.15+.
find_package(MPI REQUIRED MODULE)
else()
#clunky but we need to make sure we use the upstream module if it exists
set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "")
find_package(MPI REQUIRED MODULE)
set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH})
endif()
endif()

@ -10,9 +10,13 @@
include(CMakeParseArguments)
include(VTKmCMakeBackports)
include(VTKmDeviceAdapters)
include(VTKmCPUVectorization)
include(VTKmMPI)
if(VTKm_ENABLE_MPI AND NOT TARGET MPI::MPI_CXX)
find_package(MPI REQUIRED MODULE)
endif()
#-----------------------------------------------------------------------------
# INTERNAL FUNCTIONS

7
CMake/patches/README.md Normal file

@ -0,0 +1,7 @@
# CMake backports
This directory contains backports from newer CMake versions to help support
actually using older CMake versions for building VTK-m. The directory name is the
minimum version of CMake for which the contained files are no longer necessary.
For example, the files under the `3.15` directory are not needed for 3.15 or
3.16, but are for 3.14.

@ -266,8 +266,9 @@ if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
# Install helper configure files.
install(
FILES
${VTKm_SOURCE_DIR}/CMake/VTKmCMakeBackports.cmake
${VTKm_SOURCE_DIR}/CMake/FindTBB.cmake
${VTKm_SOURCE_DIR}/CMake/FindMPI.cmake
${VTKm_SOURCE_DIR}/CMake/patches/3.15/FindMPI.cmake
DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
)
@ -279,7 +280,6 @@ if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
${VTKm_SOURCE_DIR}/CMake/VTKmDeviceAdapters.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmDIYUtils.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmExportHeaderTemplate.h.in
${VTKm_SOURCE_DIR}/CMake/VTKmMPI.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmRenderingContexts.cmake
${VTKm_SOURCE_DIR}/CMake/VTKmWrappers.cmake
DESTINATION ${VTKm_INSTALL_CMAKE_MODULE_DIR}
@ -313,7 +313,7 @@ endif ()
#-----------------------------------------------------------------------------
#add the benchmarking folder
if(VTKm_ENABLE_BENCHMARKS)
add_subdirectory(benchmarking)
add_subdirectory(benchmarking)
endif()
#-----------------------------------------------------------------------------