[cmake-developers] FindMPI take 2

Alin Marin Elena alinm.elena at gmail.com
Thu Dec 11 05:24:24 EST 2014


Hi Kelly
> I have been looking into this.  For my setup, I found it useful to compare the CMAKE_<LANG>_COMPILER to the list of known mpi wrapper names and prepend _MPI_${lang}_COMPILER_NAMES with CMAKE_<LANG>_COMPILER so that the remaining logic in FindMPI.cmake chooses the user supplied compiler/mpi-wrapper over any of the other choices.  Something like this:
>
> # append vendor-specific compilers to the list if we either don't know the compiler id,
> # or if we know it matches the regular compiler.
> foreach (lang C CXX Fortran)
>   foreach (id GNU Intel PGI XL)
>     if (NOT CMAKE_${lang}_COMPILER_ID OR CMAKE_${lang}_COMPILER_ID STREQUAL id)
>       list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES})
>     endif()
>     unset(_MPI_${id}_${lang}_COMPILER_NAMES)    # clean up the namespace here
>   endforeach()
>
> +  # If cmake_$lang_compiler matches a known mpi compiler wrapper name,
> +  # prefer the provided value.
> +  get_filename_component( compiler_wo_path "${CMAKE_${lang}_COMPILER}" NAME )
> +  set( ${lang}_compiler_is_mpiwrapper false )
> +  foreach( mpiwrapper ${_MPI_${lang}_COMPILER_NAMES} )
> +    if( "${mpiwrapper}" STREQUAL "${compiler_wo_path}" )
> +      set( ${lang}_compiler_is_mpiwrapper true )
> +    endif()
> +  endforeach()
> +  if( ${lang}_compiler_is_mpiwrapper )
> +    list( REMOVE_ITEM _MPI_${lang}_COMPILER_NAMES ${compiler_wo_path} )
> +    list( INSERT _MPI_${lang}_COMPILER_NAMES 0 ${compiler_wo_path} )
> +  endif()
> endforeach()

checked your patch and indeed works.

In addition to that I have noticed that in the interrogate function we
never check that we can actually generate a binary with the findings,
shall we have a try_mpi_compile at the end of interrogate function?

regards
Alin


More information about the cmake-developers mailing list