From 786e1e91e2c3d6073211dae054c3fa299618eb7a Mon Sep 17 00:00:00 2001 From: Petukhov Maksim Date: Thu, 27 Jul 2023 23:53:12 +0300 Subject: [PATCH] Use env variables instead of hardcoded paths for ms-mpi search --- src/tools/mpi.jam | 50 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/src/tools/mpi.jam b/src/tools/mpi.jam index 77941cf114..3fe2ff9e10 100644 --- a/src/tools/mpi.jam +++ b/src/tools/mpi.jam @@ -246,35 +246,60 @@ rule init ( mpicxx ? : options * : mpirun-with-options * ) if ! $(mpicxx) && [ os.on-windows ] { # Paths for Microsoft MPI - local ms_mpi_path_native = "C:\\Program Files\\Microsoft MPI" ; - local ms_mpi_sdk_path_native = "C:\\Program Files (x86)\\Microsoft SDKs\\MPI" ; + # Treat them explicitly as native OS path references + local ms_mpi_bin_native = [ os.environ MSMPI_BIN ] ; + if $(ms_mpi_bin_native) + { + ms_mpi_bin_native = [ path.make $(ms_mpi_bin_native) ] ; + ms_mpi_bin_native = [ path.native $(ms_mpi_bin_native) ] ; + } + + local ms_mpi_inc_native = [ os.environ MSMPI_INC ] ; + if $(ms_mpi_inc_native) + { + ms_mpi_inc_native = [ path.make $(ms_mpi_inc_native) ] ; + ms_mpi_inc_native = [ path.native $(ms_mpi_inc_native) ] ; + } # Path for Microsoft Compute Cluster Pack local cluster_pack_path_native = "C:\\Program Files\\Microsoft Compute Cluster Pack" ; # Try to auto-configure Microsoft MPI - if [ GLOB $(ms_mpi_path_native)\\Bin : mpiexec.exe ] && - [ GLOB $(ms_mpi_sdk_path_native)\\Include : mpi.h ] + if $(ms_mpi_bin_native) && + $(ms_mpi_inc_native) && + [ GLOB $(ms_mpi_bin_native) : mpiexec.exe ] && + [ GLOB $(ms_mpi_inc_native) : mpi.h ] { if $(.debug-configuration) { - ECHO "Found Microsoft MPI: $(ms_mpi_path_native)" ; - ECHO "Found Microsoft MPI SDK: $(ms_mpi_sdk_path_native)" ; + ECHO "Found Microsoft MPI and Microsoft MPI SDK" ; + } + + local ms_mpi_lib32 = [ os.environ MSMPI_LIB32 ] ; + if $(ms_mpi_lib32) + { + ms_mpi_lib32 = [ path.make $(ms_mpi_lib32) ] ; + } + + local ms_mpi_lib64 = [ os.environ MSMPI_LIB64 ] ; + if $(ms_mpi_lib64) + { + ms_mpi_lib64 = [ path.make $(ms_mpi_lib64) ] ; } - local ms_mpi_sdk_path = [ path.make $(ms_mpi_sdk_path_native) ] ; + local ms_mpi_inc = [ path.make $(ms_mpi_inc_native) ] ; # Pick up either the 32-bit or 64-bit library, depending on which address # model the user has selected. Default to 32-bit. - options = $(ms_mpi_sdk_path)/Include - 64:$(ms_mpi_sdk_path)/Lib/x64 - $(ms_mpi_sdk_path)/Lib/x86 + options = $(ms_mpi_inc) + 64:$(ms_mpi_lib64) + $(ms_mpi_lib32) msmpi msvc:_SECURE_SCL=0 ; # Setup the "mpirun" equivalent (mpiexec) - .mpirun = "\"$(ms_mpi_path_native)\\Bin\\mpiexec.exe"\" ; + .mpirun = "\"$(ms_mpi_bin_native)\\mpiexec.exe"\" ; .mpirun_flags = -n ; } # Try to auto-configure to the Microsoft Compute Cluster Pack @@ -302,8 +327,7 @@ rule init ( mpicxx ? : options * : mpirun-with-options * ) } else if $(.debug-configuration) { - ECHO "Did not find Microsoft MPI in $(ms_mpi_path_native)" ; - ECHO " and/or Microsoft MPI SDK in $(ms_mpi_sdk_path_native)." ; + ECHO "Did not find Microsoft MPI and/or Microsoft MPI SDK" ; ECHO "Did not find Microsoft Compute Cluster Pack in $(cluster_pack_path_native)." ; } }