Skip to content

Commit

Permalink
Revert "add option to use mpi imported targets (#482)"
Browse files Browse the repository at this point in the history
This reverts commit 68c98b7.
  • Loading branch information
cyrush committed Apr 22, 2021
1 parent 68c98b7 commit 0fee231
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 69 deletions.
3 changes: 0 additions & 3 deletions RELEASE-NOTES.md
Expand Up @@ -9,9 +9,6 @@ The project release numbers follow [Semantic Versioning](http://semver.org/spec/

## [Unreleased] - Release date yyyy-mm-dd

## Added
- Added ``BLT_USE_FIND_MPI_TARGETS`` option that directly uses the CMake targets provided by CMake's Find MPI for BLT's MPI support.

## [Version 0.4.0] - Release date 2021-04-09

## Added
Expand Down
2 changes: 0 additions & 2 deletions cmake/BLTOptions.cmake
Expand Up @@ -117,8 +117,6 @@ option(BLT_EXPORT_THIRDPARTY "Configure the third-party targets created by BLT t
#------------------------------------------------------------------------------

option(ENABLE_FIND_MPI "Enables CMake's Find MPI support (Turn off when compiling with the mpi wrapper directly)" ON)
option(BLT_USE_FIND_MPI_TARGETS "Directly use the CMake targets provided by CMake's Find MPI" OFF)


option(
ENABLE_GTEST_DEATH_TESTS
Expand Down
65 changes: 8 additions & 57 deletions cmake/thirdparty/SetupMPI.cmake
Expand Up @@ -31,25 +31,7 @@ set(_mpi_includes )
set(_mpi_libraries )
set(_mpi_link_flags )


if(ENABLE_FIND_MPI)
message(STATUS "FindMPI Enabled (ENABLE_FIND_MPI == ON)")
else()
message(STATUS "FindMPI Disabled (ENABLE_FIND_MPI == OFF) ")
endif()


if(BLT_USE_FIND_MPI_TARGETS)
message(STATUS "Using MPI CMake imported targets (BLT_USE_FIND_MPI_TARGETS == ON)")
else()
message(STATUS "Not using MPI CMake imported targets (BLT_USE_FIND_MPI_TARGETS == OFF)")
endif()


if(NOT ENABLE_FIND_MPI AND BLT_USE_FIND_MPI_TARGETS)
message(FATAL_ERROR "ENABLE_FIND_MPI == false, but BLT_USE_FIND_MPI_TARGETS == true."
"BLT_USE_FIND_MPI_TARGETS == true requires ENABLE_FIND_MPI == true.")
endif()
message(STATUS "Enable FindMPI: ${ENABLE_FIND_MPI}")

if (ENABLE_FIND_MPI)
find_package(MPI REQUIRED)
Expand Down Expand Up @@ -141,33 +123,16 @@ if (ENABLE_FIND_MPI)
endif()

# Allow users to override CMake's FindMPI
# Assuming we are not directly using targets it provides
if (BLT_MPI_COMPILE_FLAGS)
if(BLT_USE_FIND_MPI_TARGETS)
message(FATAL_ERROR "Cannot override MPI Compile Flags when BLT_USE_FIND_MPI_TARGETS == true. "
"(BLT_MPI_COMPILE_FLAGS provided, but BLT_USE_FIND_MPI_TARGETS == true)")
endif()
set(_mpi_compile_flags ${BLT_MPI_COMPILE_FLAGS})
endif()
if (BLT_MPI_INCLUDES)
if(BLT_USE_FIND_MPI_TARGETS)
message(FATAL_ERROR "Cannot override MPI Includes when BLT_USE_FIND_MPI_TARGETS == true. "
"(BLT_MPI_INCLUDES provided, but BLT_USE_FIND_MPI_TARGETS == true)")
endif()
set(_mpi_includes ${BLT_MPI_INCLUDES})
endif()
if (BLT_MPI_LIBRARIES)
if(BLT_USE_FIND_MPI_TARGETS)
message(FATAL_ERROR "Cannot override MPI Libraries when BLT_USE_FIND_MPI_TARGETS == true. "
"(BLT_MPI_LIBRARIES provided, but BLT_USE_FIND_MPI_TARGETS == true)")
endif()
set(_mpi_libraries ${BLT_MPI_LIBRARIES})
endif()
if (BLT_MPI_LINK_FLAGS)
if(BLT_USE_FIND_MPI_TARGETS)
message(FATAL_ERROR "Cannot override MPI Link Flags when BLT_USE_FIND_MPI_TARGETS == true. "
"(BLT_MPI_LINK_FLAGS provided, but BLT_USE_FIND_MPI_TARGETS == true)")
endif()
set(_mpi_link_flags ${BLT_MPI_LINK_FLAGS})
endif()

Expand Down Expand Up @@ -212,24 +177,10 @@ if (ENABLE_FORTRAN)
endif()
endif()


if(BLT_USE_FIND_MPI_TARGETS)
if(TARGET MPI::MPI_C)
message(STATUS "Using MPI CMake imported targets: MPI::MPI_C MPI::MPI_CXX")
blt_register_library(NAME mpi
LIBRARIES MPI::MPI_C MPI::MPI_CXX)
else()
message(FATAL_ERROR "Cannot use CMake imported targets for MPI."
"(BLT_USE_FIND_MPI_TARGETS == true) "
"but MPI::MPI_C CMake target is missing.")
endif()
else()
# non imported targets case
blt_import_library(NAME mpi
INCLUDES ${_mpi_includes}
TREAT_INCLUDES_AS_SYSTEM ON
LIBRARIES ${_mpi_libraries}
COMPILE_FLAGS ${_mpi_compile_flags}
LINK_FLAGS ${_mpi_link_flags}
EXPORTABLE ${BLT_EXPORT_THIRDPARTY})
endif()
blt_import_library(NAME mpi
INCLUDES ${_mpi_includes}
TREAT_INCLUDES_AS_SYSTEM ON
LIBRARIES ${_mpi_libraries}
COMPILE_FLAGS ${_mpi_compile_flags}
LINK_FLAGS ${_mpi_link_flags}
EXPORTABLE ${BLT_EXPORT_THIRDPARTY})
7 changes: 0 additions & 7 deletions docs/tutorial/common_hpc_dependencies.rst
Expand Up @@ -86,13 +86,6 @@ Test. ``test_2.cpp`` provides an example driver for MPI with GoogleTest.
BLT also has the variable ``ENABLE_FIND_MPI`` which turns off all CMake's ``FindMPI``
logic and then uses the MPI wrapper directly when you provide them as the default
compilers.

BLT also provides ``BLT_USE_FIND_MPI_TARGETS`` that will directly use the
``MPI::MPI_C`` and ``MPI::MPI_CXX`` targets provided by CMake's ``FindMPI``.
When enabled these targets are available for BLT ``DEPENDS_ON`` arguments
via unified name of ``mpi``.
This option requires ``ENABLE_FIND_MPI == true`` and is not compatible with
the ``BLT_`` override options above.


CUDA
Expand Down

0 comments on commit 0fee231

Please sign in to comment.