Debian Codegraph @

cmake/tribits/core/std_tpls/FindTPLMPI.cmake

raw
1 # @HEADER
2 # *****************************************************************************
3 # TriBITS: Tribal Build, Integrate, and Test System
4 #
5 # Copyright 2013-2016 NTESS and the TriBITS contributors.
6 # SPDX-License-Identifier: BSD-3-Clause
7 # *****************************************************************************
8 # @HEADER
9
10 # Either the MPI compiler wrappers take care of these or the user has to set
11 # the explicitly using basic compile flags and ${PROJECT_NAME}_EXTRA_LINK_FLAGS.
12 global_set(TPL_MPI_INCLUDE_DIRS "")
13 global_set(TPL_MPI_LIBRARIES "")
14 global_set(TPL_MPI_LIBRARY_DIRS "")
15
16 if(WIN32 AND TPL_ENABLE_MPI)
17 find_package(MPI)
18 include_directories(${MPI_INCLUDE_PATH})
19 global_set(TPL_MPI_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
20 global_set(TPL_MPI_LIBRARIES ${MPI_LIBRARIES})
21 endif()
22
23 # Don't allow calling find_package(MPI) by default. Force the user to set
24 # MPI_ALLOW_PACKAGE_PREFIND=TRUE or even MPI_FORCE_PRE_FIND_PACKAGE if then
25 # want to force the finding of MPI using find_package(MPI).
26 set(MPI_ALLOW_PACKAGE_PREFIND FALSE CACHE BOOL
27 "Allow calling find_package(MPI) by default (default is FALSE)")
28
29 tribits_tpl_allow_pre_find_package(MPI MPI_ALLOW_PREFIND)
30 if(MPI_ALLOW_PREFIND)
31 find_package(MPI)
32 if(MPI_C_FOUND AND MPI_CXX_FOUND)
33 tribits_extpkg_create_imported_all_libs_target_and_config_file(
34 MPI
35 INNER_FIND_PACKAGE_NAME MPI
36 IMPORTED_TARGETS_FOR_ALL_LIBS MPI::MPI_C MPI::MPI_CXX)
37 endif()
38 endif()
39
40 if(NOT TARGET MPI::all_libs)
41 tribits_tpl_find_include_dirs_and_libraries(MPI)
42 # NOTE: Above, we need to generate the MPI::all_libs target and the
43 # MPIConfig.cmake file that will also provide the MPI::all_libs target.
44 endif()