diff --git a/ports/msmpi/CONTROL b/ports/msmpi/CONTROL
index 9640f564b459bf..c7fcec34df55ea 100644
--- a/ports/msmpi/CONTROL
+++ b/ports/msmpi/CONTROL
@@ -1,5 +1,7 @@
Source: msmpi
Version: 10.1
+Port-Version: 1
Homepage: https://docs.microsoft.com/en-us/message-passing-interface/microsoft-mpi
Description: Microsoft MPI
Supports: windows
+Build-Depends: networkdirect-sdk
diff --git a/ports/msmpi/fix-external-symbols.patch b/ports/msmpi/fix-external-symbols.patch
new file mode 100644
index 00000000000000..0f8fa3939516e1
--- /dev/null
+++ b/ports/msmpi/fix-external-symbols.patch
@@ -0,0 +1,20 @@
+diff --git a/src/mpi/common/mpidef.h b/src/mpi/common/mpidef.h
+index bb1d146..8535d19 100644
+--- a/src/mpi/common/mpidef.h
++++ b/src/mpi/common/mpidef.h
+@@ -135,13 +135,13 @@ typedef MPIU_Bsize_t MPIDI_msg_sz_t;
+ */
+
+ /* PtrToInt converts a pointer to a int type, truncating bits if necessary */
+-#define MPIU_PtrToInt PtrToInt
++#define MPIU_PtrToInt(p) ((INT)(INT_PTR) (p) )
+
+ /* PtrToAint converts a pointer to an MPI_Aint type, truncating bits if necessary */
+ #define MPIU_PtrToAint(a) ((MPI_Aint)(INT_PTR) (a) )
+
+ /* IntToPtr converts a int to a pointer type, extending bits if necessary */
+-#define MPIU_IntToPtr IntToPtr
++#define MPIU_IntToPtr(i) ((VOID *)(INT_PTR)((int)i))
+
+
+ //
diff --git a/ports/msmpi/fix-invalid-boz-literals.patch b/ports/msmpi/fix-invalid-boz-literals.patch
new file mode 100644
index 00000000000000..51c5ac75e6b8bb
--- /dev/null
+++ b/ports/msmpi/fix-invalid-boz-literals.patch
@@ -0,0 +1,190 @@
+diff --git a/src/include/mpif.h b/src/include/mpif.h
+index f531a15..aaac5d1 100644
+--- a/src/include/mpif.h
++++ b/src/include/mpif.h
+@@ -224,7 +224,7 @@
+ INTEGER MPI_OP_NULL
+ PARAMETER (MPI_OP_NULL=402653184)
+ INTEGER MPI_DATATYPE_NULL
+- PARAMETER (MPI_DATATYPE_NULL=z'0c000000')
++ PARAMETER (MPI_DATATYPE_NULL=201326592)
+ INTEGER MPI_REQUEST_NULL
+ PARAMETER (MPI_REQUEST_NULL=738197504)
+ INTEGER MPI_ERRHANDLER_NULL
+@@ -300,104 +300,104 @@
+ INTEGER MPI_LOCK_SHARED
+ PARAMETER (MPI_LOCK_SHARED=235)
+ INTEGER MPI_CHAR
+- PARAMETER (MPI_CHAR=z'4c000101')
++ PARAMETER (MPI_CHAR=1275068673)
+ INTEGER MPI_UNSIGNED_CHAR
+- PARAMETER (MPI_UNSIGNED_CHAR=z'4c000102')
++ PARAMETER (MPI_UNSIGNED_CHAR=1275068674)
+ INTEGER MPI_SHORT
+- PARAMETER (MPI_SHORT=z'4c000203')
++ PARAMETER (MPI_SHORT=1275068931)
+ INTEGER MPI_UNSIGNED_SHORT
+- PARAMETER (MPI_UNSIGNED_SHORT=z'4c000204')
++ PARAMETER (MPI_UNSIGNED_SHORT=1275068932)
+ INTEGER MPI_INT
+- PARAMETER (MPI_INT=z'4c000405')
++ PARAMETER (MPI_INT=1275069445)
+ INTEGER MPI_UNSIGNED
+- PARAMETER (MPI_UNSIGNED=z'4c000406')
++ PARAMETER (MPI_UNSIGNED=1275069446)
+ INTEGER MPI_LONG
+- PARAMETER (MPI_LONG=z'4c000407')
++ PARAMETER (MPI_LONG=1275069447)
+ INTEGER MPI_UNSIGNED_LONG
+- PARAMETER (MPI_UNSIGNED_LONG=z'4c000408')
++ PARAMETER (MPI_UNSIGNED_LONG=1275069448)
+ INTEGER MPI_LONG_LONG
+- PARAMETER (MPI_LONG_LONG=z'4c000809')
++ PARAMETER (MPI_LONG_LONG=1275070473)
+ INTEGER MPI_LONG_LONG_INT
+- PARAMETER (MPI_LONG_LONG_INT=z'4c000809')
++ PARAMETER (MPI_LONG_LONG_INT=1275070473)
+ INTEGER MPI_FLOAT
+- PARAMETER (MPI_FLOAT=z'4c00040a')
++ PARAMETER (MPI_FLOAT=1275069450)
+ INTEGER MPI_DOUBLE
+- PARAMETER (MPI_DOUBLE=z'4c00080b')
++ PARAMETER (MPI_DOUBLE=1275070475)
+ INTEGER MPI_LONG_DOUBLE
+- PARAMETER (MPI_LONG_DOUBLE=z'4c00080c')
++ PARAMETER (MPI_LONG_DOUBLE=1275070476)
+ INTEGER MPI_BYTE
+- PARAMETER (MPI_BYTE=z'4c00010d')
++ PARAMETER (MPI_BYTE=1275068685)
+ INTEGER MPI_WCHAR
+- PARAMETER (MPI_WCHAR=z'4c00020e')
++ PARAMETER (MPI_WCHAR=1275068942)
+ INTEGER MPI_PACKED
+- PARAMETER (MPI_PACKED=z'4c00010f')
++ PARAMETER (MPI_PACKED=1275068687)
+ INTEGER MPI_LB
+- PARAMETER (MPI_LB=z'4c000010')
++ PARAMETER (MPI_LB=1275068432)
+ INTEGER MPI_UB
+- PARAMETER (MPI_UB=z'4c000011')
++ PARAMETER (MPI_UB=1275068433)
+ INTEGER MPI_2INT
+- PARAMETER (MPI_2INT=z'4c000816')
++ PARAMETER (MPI_2INT=1275070486)
+ INTEGER MPI_SIGNED_CHAR
+- PARAMETER (MPI_SIGNED_CHAR=z'4c000118')
++ PARAMETER (MPI_SIGNED_CHAR=1275068696)
+ INTEGER MPI_UNSIGNED_LONG_LONG
+- PARAMETER (MPI_UNSIGNED_LONG_LONG=z'4c000819')
++ PARAMETER (MPI_UNSIGNED_LONG_LONG=1275070489)
+ INTEGER MPI_CHARACTER
+- PARAMETER (MPI_CHARACTER=z'4c00011a')
++ PARAMETER (MPI_CHARACTER=1275068698)
+ INTEGER MPI_INTEGER
+- PARAMETER (MPI_INTEGER=z'4c00041b')
++ PARAMETER (MPI_INTEGER=1275069467)
+ INTEGER MPI_REAL
+- PARAMETER (MPI_REAL=z'4c00041c')
++ PARAMETER (MPI_REAL=1275069468)
+ INTEGER MPI_LOGICAL
+- PARAMETER (MPI_LOGICAL=z'4c00041d')
++ PARAMETER (MPI_LOGICAL=1275069469)
+ INTEGER MPI_COMPLEX
+- PARAMETER (MPI_COMPLEX=z'4c00081e')
++ PARAMETER (MPI_COMPLEX=1275070494)
+ INTEGER MPI_DOUBLE_PRECISION
+- PARAMETER (MPI_DOUBLE_PRECISION=z'4c00081f')
++ PARAMETER (MPI_DOUBLE_PRECISION=1275070495)
+ INTEGER MPI_2INTEGER
+- PARAMETER (MPI_2INTEGER=z'4c000820')
++ PARAMETER (MPI_2INTEGER=1275070496)
+ INTEGER MPI_2REAL
+- PARAMETER (MPI_2REAL=z'4c000821')
++ PARAMETER (MPI_2REAL=1275070497)
+ INTEGER MPI_DOUBLE_COMPLEX
+- PARAMETER (MPI_DOUBLE_COMPLEX=z'4c001022')
++ PARAMETER (MPI_DOUBLE_COMPLEX=1275072546)
+ INTEGER MPI_2DOUBLE_PRECISION
+- PARAMETER (MPI_2DOUBLE_PRECISION=z'4c001023')
++ PARAMETER (MPI_2DOUBLE_PRECISION=1275072547)
+ INTEGER MPI_2COMPLEX
+- PARAMETER (MPI_2COMPLEX=z'4c001024')
++ PARAMETER (MPI_2COMPLEX=1275072548)
+ INTEGER MPI_2DOUBLE_COMPLEX
+- PARAMETER (MPI_2DOUBLE_COMPLEX=z'4c002025')
++ PARAMETER (MPI_2DOUBLE_COMPLEX=1275076645)
+ INTEGER MPI_REAL2
+- PARAMETER (MPI_REAL2=z'0c000000')
++ PARAMETER (MPI_REAL2=201326592)
+ INTEGER MPI_REAL4
+- PARAMETER (MPI_REAL4=z'4c000427')
++ PARAMETER (MPI_REAL4=1275069479)
+ INTEGER MPI_COMPLEX8
+- PARAMETER (MPI_COMPLEX8=z'4c000828')
++ PARAMETER (MPI_COMPLEX8=1275070504)
+ INTEGER MPI_REAL8
+- PARAMETER (MPI_REAL8=z'4c000829')
++ PARAMETER (MPI_REAL8=1275070505)
+ INTEGER MPI_COMPLEX16
+- PARAMETER (MPI_COMPLEX16=z'4c00102a')
++ PARAMETER (MPI_COMPLEX16=1275072554)
+ INTEGER MPI_REAL16
+- PARAMETER (MPI_REAL16=z'0c000000')
++ PARAMETER (MPI_REAL16=201326592)
+ INTEGER MPI_COMPLEX32
+- PARAMETER (MPI_COMPLEX32=z'0c000000')
++ PARAMETER (MPI_COMPLEX32=201326592)
+ INTEGER MPI_INTEGER1
+- PARAMETER (MPI_INTEGER1=z'4c00012d')
++ PARAMETER (MPI_INTEGER1=1275068717)
+ INTEGER MPI_COMPLEX4
+- PARAMETER (MPI_COMPLEX4=z'0c000000')
++ PARAMETER (MPI_COMPLEX4=201326592)
+ INTEGER MPI_INTEGER2
+- PARAMETER (MPI_INTEGER2=z'4c00022f')
++ PARAMETER (MPI_INTEGER2=1275068975)
+ INTEGER MPI_INTEGER4
+- PARAMETER (MPI_INTEGER4=z'4c000430')
++ PARAMETER (MPI_INTEGER4=1275069488)
+ INTEGER MPI_INTEGER8
+- PARAMETER (MPI_INTEGER8=z'4c000831')
++ PARAMETER (MPI_INTEGER8=1275070513)
+ INTEGER MPI_INTEGER16
+- PARAMETER (MPI_INTEGER16=z'0c000000')
++ PARAMETER (MPI_INTEGER16=201326592)
+
+ INCLUDE 'mpifptr.h'
+
+ INTEGER MPI_OFFSET
+- PARAMETER (MPI_OFFSET=z'4c00083c')
++ PARAMETER (MPI_OFFSET=1275070524)
+ INTEGER MPI_COUNT
+- PARAMETER (MPI_COUNT=z'4c00083d')
++ PARAMETER (MPI_COUNT=1275070525)
+ INTEGER MPI_FLOAT_INT
+ PARAMETER (MPI_FLOAT_INT=-1946157056)
+ INTEGER MPI_DOUBLE_INT
+diff --git a/src/include/x64/mpifptr.h b/src/include/x64/mpifptr.h
+index 1d4a288..58d9b62 100644
+--- a/src/include/x64/mpifptr.h
++++ b/src/include/x64/mpifptr.h
+@@ -4,6 +4,6 @@
+ ! Licensed under the MIT License.
+ !
+ INTEGER MPI_AINT
+- PARAMETER (MPI_AINT=z'4c00083b')
++ PARAMETER (MPI_AINT=1275070523)
+ INTEGER MPI_ADDRESS_KIND
+ PARAMETER(MPI_ADDRESS_KIND = 8)
+diff --git a/src/include/x86/mpifptr.h b/src/include/x86/mpifptr.h
+index 1028a1d..ff28c14 100644
+--- a/src/include/x86/mpifptr.h
++++ b/src/include/x86/mpifptr.h
+@@ -4,6 +4,6 @@
+ ! Licensed under the MIT License.
+ !
+ INTEGER MPI_AINT
+- PARAMETER (MPI_AINT=z'4c00043b')
++ PARAMETER (MPI_AINT=1275069499)
+ INTEGER MPI_ADDRESS_KIND
+ PARAMETER(MPI_ADDRESS_KIND = 4)
diff --git a/ports/msmpi/fix-nuget-restore.patch b/ports/msmpi/fix-nuget-restore.patch
new file mode 100644
index 00000000000000..17006ebe5f9431
--- /dev/null
+++ b/ports/msmpi/fix-nuget-restore.patch
@@ -0,0 +1,80 @@
+diff --git a/.build/Local/CBTModules/CBTModules.proj b/.build/Local/CBTModules/CBTModules.proj
+deleted file mode 100644
+index 8a8d130..0000000
+--- a/.build/Local/CBTModules/CBTModules.proj
++++ /dev/null
+@@ -1,60 +0,0 @@
+-
+-
+-
+- net46
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+\ No newline at end of file
+diff --git a/.build/Local/CBTModules/packages.config b/.build/Local/CBTModules/packages.config
+new file mode 100644
+index 0000000..80dbe71
+--- /dev/null
++++ b/.build/Local/CBTModules/packages.config
+@@ -0,0 +1,6 @@
++
++
++
++
++
++
+\ No newline at end of file
diff --git a/ports/msmpi/networkdirect-no-nuget.patch b/ports/msmpi/networkdirect-no-nuget.patch
new file mode 100644
index 00000000000000..a0b267beb712d2
--- /dev/null
+++ b/ports/msmpi/networkdirect-no-nuget.patch
@@ -0,0 +1,44 @@
+diff --git a/src/mpi/msmpi/channels/mpichannels.vcxproj b/src/mpi/msmpi/channels/mpichannels.vcxproj
+index 2093a96..094500c 100644
+--- a/src/mpi/msmpi/channels/mpichannels.vcxproj
++++ b/src/mpi/msmpi/channels/mpichannels.vcxproj
+@@ -65,10 +65,6 @@
+
+
+
+-
+-
+-
+-
+
+
+
+diff --git a/src/mpi/msmpi/dll/msmpi.vcxproj b/src/mpi/msmpi/dll/msmpi.vcxproj
+index 255b9f5..e2a6455 100644
+--- a/src/mpi/msmpi/dll/msmpi.vcxproj
++++ b/src/mpi/msmpi/dll/msmpi.vcxproj
+@@ -119,9 +119,5 @@ if not %rc%==1 exit %rce% else exit 0
+
+
+
+-
+-
+-
+-
+
+
+diff --git a/src/mpi/msmpi/mpid/mpid.vcxproj b/src/mpi/msmpi/mpid/mpid.vcxproj
+index de9cebf..ac83ff3 100644
+--- a/src/mpi/msmpi/mpid/mpid.vcxproj
++++ b/src/mpi/msmpi/mpid/mpid.vcxproj
+@@ -95,10 +95,6 @@
+
+
+
+-
+-
+-
+-
+
+
+
diff --git a/ports/msmpi/no-toolsversion.patch b/ports/msmpi/no-toolsversion.patch
new file mode 100644
index 00000000000000..bc2880f94a7e28
--- /dev/null
+++ b/ports/msmpi/no-toolsversion.patch
@@ -0,0 +1,17 @@
+diff --git a/Directory.Build.props b/Directory.Build.props
+index 3177de8..208b4b2 100644
+--- a/Directory.Build.props
++++ b/Directory.Build.props
+@@ -114,9 +114,9 @@
+
+
+ $(StagingOutputRootPath)$(MSBuildProjectName)\
+- 14.15.26726
+- 10.0.16299.0
+- v141
++
++
++
+ $(OutputPath)
+ $(Platform)\$(Configuration)
+ $(Configuration)
diff --git a/ports/msmpi/no-wdk.patch b/ports/msmpi/no-wdk.patch
new file mode 100644
index 00000000000000..85fe58cfa506df
--- /dev/null
+++ b/ports/msmpi/no-wdk.patch
@@ -0,0 +1,59 @@
+diff --git a/src/launchSvc/msmpiLaunchSvcMc.vcxproj b/src/launchSvc/msmpiLaunchSvcMc.vcxproj
+index 2a6952b..e901dcc 100644
+--- a/src/launchSvc/msmpiLaunchSvcMc.vcxproj
++++ b/src/launchSvc/msmpiLaunchSvcMc.vcxproj
+@@ -11,16 +11,13 @@
+
+ None
+ false
+- WindowsUserModeDriver10.0
+
+
+
+-
+- true
+- $(SrcRoot)\launchsvc\$(O)
+- true
+- $(SrcRoot)\launchsvc\$(O)
+-
++
++ mc.exe -h $(SrcRoot)\launchsvc\$(O) -r $(SrcRoot)\launchsvc\$(O) launchsvcmsg.mc
++ $(SrcRoot)\launchsvc\$(O)\launchsvcmsg.h;$(SrcRoot)\launchsvc\$(O)\launchsvcmsg.rc
++
+
+
+
+\ No newline at end of file
+diff --git a/src/mpi/common/traceManifest.vcxproj b/src/mpi/common/traceManifest.vcxproj
+index f80e80b..736ef65 100644
+--- a/src/mpi/common/traceManifest.vcxproj
++++ b/src/mpi/common/traceManifest.vcxproj
+@@ -8,23 +8,16 @@
+
+ false
+ None
+- WindowsUserModeDriver10.0
+ None
+
+
+
+
+
+-
+- true
+- $(MPI_SRC_ROOT)\common\$(O)
+- true
+- $(MPI_SRC_ROOT)\common\$(O)
+- MpiTraceEvents
+- true
+- Trace
+- EVENT_
+-
++
++ mc.exe -um -p Trace -P EVENT_ -h $(MPI_SRC_ROOT)\common\$(O) -r $(MPI_SRC_ROOT)\common\$(O) -z MpiTraceEvents $(MPI_SRC_ROOT)\common\mpitrace.man
++ $(MPI_SRC_ROOT)\common\$(O)\MpiTraceEvents.h;$(MPI_SRC_ROOT)\common\$(O)\MpiTraceEvents.rc
++
+
+
+
+\ No newline at end of file
diff --git a/ports/msmpi/portfile.cmake b/ports/msmpi/portfile.cmake
index 58c3661c79d04d..3abbb831ba5867 100644
--- a/ports/msmpi/portfile.cmake
+++ b/ports/msmpi/portfile.cmake
@@ -1,127 +1,95 @@
vcpkg_fail_port_install(ON_TARGET "Linux" "OSX" "UWP")
-set(MSMPI_VERSION "10.1.12498")
-set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/msmpi-${MSMPI_VERSION})
-
-vcpkg_download_distfile(SDK_ARCHIVE
- URLS "https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisdk.msi"
- FILENAME "msmpisdk-${MSMPI_VERSION}.msi"
- SHA512 330fad53c1979dfae786abed228d82c82207f0d61148e2efc1f37c8931838b806eb50554e7f006a56962f748a21f7017c540bd70444b7a93a72c313a64e9254c
+vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO microsoft/Microsoft-MPI
+ REF v10.1.1
+ SHA512 c5aef7c15e815dab22a46bdc7ad14fea20e6ed4324f560c3d9df2dd236338b282ec2d4a45522eb04801e3733a0d3db8017ce0ed9f18c3844a452c182296b9e59
+ HEAD_REF master
+ PATCHES
+ # PlatformToolset and WindowsTargetPlatformVersion are explicitly set by `vcpkg_install_msbuild`
+ # and VCToolsVersion is automatically selected
+ no-toolsversion.patch
+
+ # Some symbols referenced from Basestd.h end up unresolved, so we just use the macro version
+ # of them directly.
+ fix-external-symbols.patch
+
+ # mpif.h uses invalid BOZ integer constants, which will not be accepted without `-fallow-invalid-boz`
+ # by gfortran >= 10.0, so we convert them to regular integer constants.
+ fix-invalid-boz-literals.patch
+
+ # Replace CBT project by packages.config
+ # See https://github.com/CommonBuildToolset/CBT.Modules/issues/292
+ fix-nuget-restore.patch
+
+ # Replace usage of the `MessageCompile` target by a custom build step.
+ # This removes the dependency to the Windows Driver Kit
+ no-wdk.patch
+
+ # Remove the NetworkDirect NuGet dependency because we want to use the library provided by vcpkg.
+ # It will be picked up because of USE_VCPKG_INTEGRATION used below.
+ networkdirect-no-nuget.patch
)
+if(VCPKG_CRT_LINKAGE STREQUAL dynamic)
+ set(PROPERTY_FILE_PATHS "${SOURCE_PATH}/Directory.Build.props" "${SOURCE_PATH}/src/mpi.props" )
+ foreach(PROPERTY_FILE_PATH IN LISTS PROPERTY_FILE_PATHS)
+ file(READ ${PROPERTY_FILE_PATH} _contents)
+ string(REPLACE "MultiThreaded" "MultiThreadedDLL" _contents "${_contents}")
+ string(REPLACE "MultiThreadedDebug" "MultiThreadedDebugDLL" _contents "${_contents}")
+ file(WRITE ${PROPERTY_FILE_PATH} "${_contents}")
+ endforeach()
+endif()
-#to enable CI, you should modify the following URL also in ${VCPKG_ROOT}/scripts/azure-pipelines/windows/provision-image.ps1
-macro(download_msmpi_redistributable_package)
- vcpkg_download_distfile(REDIST_ARCHIVE
- URLS "https://download.microsoft.com/download/a/5/2/a5207ca5-1203-491a-8fb8-906fd68ae623/msmpisetup.exe"
- FILENAME "msmpisetup-${MSMPI_VERSION}.exe"
- SHA512 1ee463e7dfc3e55a7ac048fdfde13fef09a5eea4b74d8fd7c22a7aad667a025b467ce939e5de308e25bbc186c3fe66e0e24ac03a3741656fc7558f2af2fa132a
- )
-endmacro()
-
-### Check for correct version of installed redistributable package
-
-# We always want the ProgramFiles folder even on a 64-bit machine (not the ProgramFilesx86 folder)
-vcpkg_get_program_files_platform_bitness(PROGRAM_FILES_PLATFORM_BITNESS)
-set(SYSTEM_MPIEXEC_FILEPATH "${PROGRAM_FILES_PLATFORM_BITNESS}/Microsoft MPI/Bin/mpiexec.exe")
-
-if(EXISTS "${SYSTEM_MPIEXEC_FILEPATH}")
- set(MPIEXEC_VERSION_LOGNAME "mpiexec-version")
- vcpkg_execute_required_process(
- COMMAND ${SYSTEM_MPIEXEC_FILEPATH}
- WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}
- LOGNAME ${MPIEXEC_VERSION_LOGNAME}
- )
- file(READ ${CURRENT_BUILDTREES_DIR}/${MPIEXEC_VERSION_LOGNAME}-out.log MPIEXEC_OUTPUT)
-
- if(MPIEXEC_OUTPUT MATCHES "\\[Version ([0-9]+\\.[0-9]+\\.[0-9]+)\\.[0-9]+\\]")
- if(NOT CMAKE_MATCH_1 STREQUAL MSMPI_VERSION)
- download_msmpi_redistributable_package()
-
- message(FATAL_ERROR
- " The version of the installed MSMPI redistributable packages does not match the version to be installed\n"
- " Expected version: ${MSMPI_VERSION}\n"
- " Found version: ${CMAKE_MATCH_1}\n"
- " Please upgrade the installed version on your system.\n"
- " The appropriate installer for the expected version has been downloaded to:\n"
- " ${REDIST_ARCHIVE}\n")
- endif()
- else()
- message(FATAL_ERROR
- " Could not determine installed MSMPI redistributable package version.\n"
- " See logs for more information:\n"
- " ${CURRENT_BUILDTREES_DIR}\\${MPIEXEC_VERSION_LOGNAME}-out.log\n"
- " ${CURRENT_BUILDTREES_DIR}\\${MPIEXEC_VERSION_LOGNAME}-err.log\n")
- endif()
+# Acquire gfortran
+if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
+ set(MINGW_PATH mingw32)
+ set(MSYS_TARGET i686)
+elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
+ set(MINGW_PATH mingw64)
+ set(MSYS_TARGET x86_64)
else()
- download_msmpi_redistributable_package()
-
- message(FATAL_ERROR
- " Could not find:\n"
- " ${SYSTEM_MPIEXEC_FILEPATH}\n"
- " Please install the MSMPI redistributable package before trying to install this port.\n"
- " The appropriate installer has been downloaded to:\n"
- " ${REDIST_ARCHIVE}\n")
+ message(FATAL_ERROR "Unknown architecture '${VCPKG_TARGET_ARCHITECTURE}' for MinGW Fortran build!")
endif()
-file(TO_NATIVE_PATH "${SDK_ARCHIVE}" SDK_ARCHIVE)
-file(TO_NATIVE_PATH "${SOURCE_PATH}/sdk" SDK_SOURCE_DIR)
-file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}/msiexec-${TARGET_TRIPLET}.log" MSIEXEC_LOG_PATH)
-
-set(PARAM_MSI "/a \"${SDK_ARCHIVE}\"")
-set(PARAM_LOG "/log \"${MSIEXEC_LOG_PATH}\"")
-set(PARAM_TARGET_DIR "TARGETDIR=\"${SDK_SOURCE_DIR}\"")
-set(SCRIPT_FILE ${CURRENT_BUILDTREES_DIR}/msiextract-msmpi.bat)
-# Write the command out to a script file and run that to avoid weird escaping behavior when spaces are present
-file(WRITE ${SCRIPT_FILE} "msiexec ${PARAM_MSI} /qn ${PARAM_LOG} ${PARAM_TARGET_DIR}")
-
-vcpkg_execute_required_process(
- COMMAND ${SCRIPT_FILE}
- WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}
- LOGNAME extract-sdk
+vcpkg_acquire_msys(MSYS_ROOT PACKAGES "mingw-w64-${MSYS_TARGET}-gcc-fortran")
+set(MINGW_BIN "${MSYS_ROOT}/${MINGW_PATH}/bin")
+vcpkg_add_to_path(PREPEND "${MINGW_BIN}")
+
+# Acquire Perl
+vcpkg_find_acquire_program(PERL)
+get_filename_component(PERL_PATH ${PERL} DIRECTORY)
+vcpkg_add_to_path(${PERL_PATH})
+
+# Build the project
+list(GET CONFIGURATIONS 0 HEADER_CONFIGURATION)
+vcpkg_install_msbuild(
+ SOURCE_PATH "${SOURCE_PATH}"
+ PROJECT_SUBPATH .
+ BINARIES_SUBPATH out/*/bin
+ LICENSE_SUBPATH LICENSE.txt
+ SKIP_CLEAN
+ PLATFORM ${VCPKG_TARGET_ARCHITECTURE}
+ USE_VCPKG_INTEGRATION
+ OPTIONS
+ "/p:GFORTRAN_BIN=${MINGW_BIN}"
)
-set(SOURCE_INCLUDE_PATH "${SOURCE_PATH}/sdk/PFiles/Microsoft SDKs/MPI/Include")
-set(SOURCE_LIB_PATH "${SOURCE_PATH}/sdk/PFiles/Microsoft SDKs/MPI/Lib")
-
-# Install include files
-file(INSTALL
- "${SOURCE_INCLUDE_PATH}/mpi.h"
- "${SOURCE_INCLUDE_PATH}/mpif.h"
- "${SOURCE_INCLUDE_PATH}/mpi.f90"
- "${SOURCE_INCLUDE_PATH}/mpio.h"
- "${SOURCE_INCLUDE_PATH}/mspms.h"
- "${SOURCE_INCLUDE_PATH}/pmidbg.h"
- "${SOURCE_INCLUDE_PATH}/${TRIPLET_SYSTEM_ARCH}/mpifptr.h"
- DESTINATION
- ${CURRENT_PACKAGES_DIR}/include
-)
-
-# NOTE: since the binary distribution does not include any debug libraries we always install the release libraries
-SET(VCPKG_POLICY_ONLY_RELEASE_CRT enabled)
-
-file(GLOB STATIC_LIBS
- ${SOURCE_LIB_PATH}/${TRIPLET_SYSTEM_ARCH}/msmpifec.lib
- ${SOURCE_LIB_PATH}/${TRIPLET_SYSTEM_ARCH}/msmpifmc.lib
- ${SOURCE_LIB_PATH}/${TRIPLET_SYSTEM_ARCH}/msmpifes.lib
- ${SOURCE_LIB_PATH}/${TRIPLET_SYSTEM_ARCH}/msmpifms.lib
-)
+# The headers to install are located in the build directories
+get_filename_component(SOURCE_PATH_SUFFIX "${SOURCE_PATH}" NAME)
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
+ set(INCLUDES_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/${SOURCE_PATH_SUFFIX}/out/Release-${VCPKG_TARGET_ARCHITECTURE}/bin/sdk/inc)
+elseif(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
+ set(INCLUDES_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-deb/${SOURCE_PATH_SUFFIX}/out/Debug-${VCPKG_TARGET_ARCHITECTURE}/bin/sdk/inc)
+endif()
-file(INSTALL
- "${SOURCE_LIB_PATH}/${TRIPLET_SYSTEM_ARCH}/msmpi.lib"
- DESTINATION ${CURRENT_PACKAGES_DIR}/lib
-)
-file(INSTALL
- "${SOURCE_LIB_PATH}/${TRIPLET_SYSTEM_ARCH}/msmpi.lib"
- DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib
-)
+file(COPY ${INCLUDES_DIR}/${TRIPLET_SYSTEM_ARCH}/mpifptr.h DESTINATION ${CURRENT_PACKAGES_DIR}/include/)
+file(REMOVE_RECURSE ${INCLUDES_DIR}/x64)
+file(REMOVE_RECURSE ${INCLUDES_DIR}/x86)
-if(VCPKG_CRT_LINKAGE STREQUAL "static")
- file(INSTALL ${STATIC_LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
- file(INSTALL ${STATIC_LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
-endif()
+file(COPY ${INCLUDES_DIR}/ DESTINATION ${CURRENT_PACKAGES_DIR}/include/)
-# Handle copyright
-file(COPY "${SOURCE_PATH}/sdk/PFiles/Microsoft SDKs/MPI/License/MicrosoftMPI-SDK-EULA.rtf" DESTINATION ${CURRENT_PACKAGES_DIR}/share/msmpi)
-file(COPY "${SOURCE_PATH}/sdk/PFiles/Microsoft SDKs/MPI/License/MPI-SDK-TPN.txt" DESTINATION ${CURRENT_PACKAGES_DIR}/share/msmpi)
-file(WRITE ${CURRENT_PACKAGES_DIR}/share/msmpi/copyright "See the accompanying MicrosoftMPI-SDK-EULA.rtf and MPI-SDK-TPN.txt")
+vcpkg_clean_msbuild()
diff --git a/ports/networkdirect-sdk/CONTROL b/ports/networkdirect-sdk/CONTROL
index 158183800d5d31..f608272728911c 100644
--- a/ports/networkdirect-sdk/CONTROL
+++ b/ports/networkdirect-sdk/CONTROL
@@ -1,5 +1,6 @@
Source: networkdirect-sdk
Version: 2.0.1
+Port-Version: 1
Description: The Network Direct architecture allows hardware vendors to expose the advanced capabilities of their networking devices.
Homepage: https://www.nuget.org/packages/NetworkDirect
Supports: windows&(x64|x86)
\ No newline at end of file
diff --git a/ports/networkdirect-sdk/portfile.cmake b/ports/networkdirect-sdk/portfile.cmake
index bb893ed9065117..d7cf0ffc4590b8 100644
--- a/ports/networkdirect-sdk/portfile.cmake
+++ b/ports/networkdirect-sdk/portfile.cmake
@@ -5,7 +5,7 @@ if (VCPKG_CMAKE_SYSTEM_NAME)
message(FATAL_ERROR "networkDirect-sdk only supports windows")
endif()
-if(NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
+if(NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" AND NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
message(FATAL_ERROR "networkDirect-sdk only supports x64 and x86")
endif()
diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt
index b8a17988f2569a..dde994e0bc36d0 100644
--- a/scripts/ci.baseline.txt
+++ b/scripts/ci.baseline.txt
@@ -1096,6 +1096,7 @@ msmpi:arm-uwp=fail
msmpi:x64-linux=fail
msmpi:x64-osx=fail
msmpi:x64-uwp=fail
+msmpi:x64-windows-static=fail
munit:arm-uwp=fail
munit:arm64-windows=fail
munit:x64-uwp=fail
@@ -1135,7 +1136,6 @@ networkdirect-sdk:arm-uwp=fail
networkdirect-sdk:x64-linux=fail
networkdirect-sdk:x64-osx=fail
networkdirect-sdk:x64-uwp=fail
-networkdirect-sdk:x86-windows=fail
ngspice:x64-windows-static=fail
nmslib:arm64-windows=fail
nmslib:arm-uwp=fail
diff --git a/scripts/cmake/vcpkg_install_msbuild.cmake b/scripts/cmake/vcpkg_install_msbuild.cmake
index 1a0d9513df190b..a08245fb851ae6 100644
--- a/scripts/cmake/vcpkg_install_msbuild.cmake
+++ b/scripts/cmake/vcpkg_install_msbuild.cmake
@@ -9,6 +9,7 @@
## PROJECT_SUBPATH
## [INCLUDES_SUBPATH ]
## [LICENSE_SUBPATH ]
+## [OUTPUT_SUBPATH