瀏覽代碼

FindMPI: Fix finding PkgConfg for fallback

In commit 0723b2c935 (MPI: Add fallback detection code for MPI when cross
compiling, 2021-09-17, v3.22.0-rc1~89^2) the FindPkgConfig module was
included directly.  This produces warnings like:

    The package name passed to `find_package_handle_standard_args` (PkgConfig)
    does not match the name of the calling package (MPI).

Use `find_package(PkgConfig)` instead, as other find modules do.

Fixes: #22823
Brad King 4 年之前
父節點
當前提交
56d949f05f
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      Modules/FindMPI.cmake

+ 2 - 2
Modules/FindMPI.cmake

@@ -267,7 +267,7 @@ cmake_policy(PUSH)
 cmake_policy(SET CMP0057 NEW) # if IN_LIST
 
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-include(${CMAKE_CURRENT_LIST_DIR}/FindPkgConfig.cmake)
+find_package(PkgConfig QUIET)
 
 # Generic compiler names
 set(_MPI_C_GENERIC_COMPILER_NAMES          mpicc    mpcc      mpicc_r mpcc_r)
@@ -1583,7 +1583,7 @@ foreach(LANG IN ITEMS C CXX Fortran)
           else()
             set(_MPI_PKG "")
           endif()
-          if(_MPI_PKG)
+          if(_MPI_PKG AND PKG_CONFIG_FOUND)
             pkg_check_modules("MPI_${LANG}_PKG" "${_MPI_PKG}")
             if("${MPI_${LANG}_PKG_FOUND}")
               set(MPI_${LANG}_COMPILE_OPTIONS  ${MPI_${LANG}_PKG_CFLAGS}        CACHE STRING "MPI ${LANG} compilation options"       FORCE)