From cc3a9f1e818727432b14494cbd0d0eacb5c85e2f Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 22 Jan 2024 14:59:23 +0100 Subject: [PATCH] build: Fix finding .NET runtime when there's multiple installed versions --- cmake/modules/FindCoreClrEmbed.cmake | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake/modules/FindCoreClrEmbed.cmake b/cmake/modules/FindCoreClrEmbed.cmake index 9bcb6738b..83f0356e1 100644 --- a/cmake/modules/FindCoreClrEmbed.cmake +++ b/cmake/modules/FindCoreClrEmbed.cmake @@ -49,13 +49,16 @@ endif() set(CoreClrEmbed_ROOT_PATH "${CORECLR_RUNTIME_ROOT_PATH}") -file(GLOB _CORECLR_HOST_ARCH_PATH "${CORECLR_RUNTIME_ROOT_PATH}/packs/Microsoft.NETCore.App.Host.*-${CORECLR_SUBARCH}") -if (_CORECLR_HOST_ARCH_PATH) - get_filename_component(_CORECLR_HOST_ARCH_FILENAME ${_CORECLR_HOST_ARCH_PATH} NAME) - string(REPLACE "Microsoft.NETCore.App.Host." "" _CORECLR_COMPUTED_ARCH "${_CORECLR_HOST_ARCH_FILENAME}") - if (_CORECLR_COMPUTED_ARCH) - set(CORECLR_ARCH "${_CORECLR_COMPUTED_ARCH}") - endif() +file(GLOB _CORECLR_HOST_ARCH_PATH_LIST "${CORECLR_RUNTIME_ROOT_PATH}/packs/Microsoft.NETCore.App.Host.*-${CORECLR_SUBARCH}") +if (_CORECLR_HOST_ARCH_PATH_LIST) + foreach(_CORECLR_HOST_ARCH_PATH ${_CORECLR_HOST_ARCH_PATH_LIST}) + get_filename_component(_CORECLR_HOST_ARCH_FILENAME ${_CORECLR_HOST_ARCH_PATH} NAME) + string(REPLACE "Microsoft.NETCore.App.Host." "" _CORECLR_COMPUTED_ARCH "${_CORECLR_HOST_ARCH_FILENAME}") + if (_CORECLR_COMPUTED_ARCH) + set(CORECLR_ARCH "${_CORECLR_COMPUTED_ARCH}") + break() + endif() + endforeach() endif() set(CORECLR_HOST_BASE_PATH "${CORECLR_RUNTIME_ROOT_PATH}/packs/Microsoft.NETCore.App.Host.${CORECLR_ARCH}/${CORECLR_RUNTIME_VERSION_FULL}")