From 6f46e4768d12894ff7fa708506eb1381a6147b2f Mon Sep 17 00:00:00 2001 From: "Pipikin, Oleg" Date: Fri, 18 Oct 2024 15:51:08 +0200 Subject: [PATCH] Link VC++ runtime staticaly --- .github/workflows/job_build_windows.yml | 1 + .../workflows/windows_conditional_compilation.yml | 1 + cmake/toolchains/mt.runtime.win32.toolchain.cmake | 12 ++++++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/job_build_windows.yml b/.github/workflows/job_build_windows.yml index 24503a52878f88..592653bc42a19e 100644 --- a/.github/workflows/job_build_windows.yml +++ b/.github/workflows/job_build_windows.yml @@ -45,6 +45,7 @@ jobs: ARTIFACTS_SHARE: "C:\\mount\\build-artifacts" MANIFEST_PATH: "${{ github.workspace }}\\manifest.yml" PRODUCT_TYPE: 'public_windows_vs2019_${{ inputs.build-type }}' + CMAKE_TOOLCHAIN_FILE: "${{ github.workspace }}\\openvino\\cmake\\toolchains\\mt.runtime.win32.toolchain.cmake" steps: - name: Clone OpenVINO uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 diff --git a/.github/workflows/windows_conditional_compilation.yml b/.github/workflows/windows_conditional_compilation.yml index c382795854b030..36373efa71977b 100644 --- a/.github/workflows/windows_conditional_compilation.yml +++ b/.github/workflows/windows_conditional_compilation.yml @@ -67,6 +67,7 @@ jobs: BUILD_DIR: "${{ github.workspace }}\\openvino_build" MODELS_PATH: "${{ github.workspace }}\\testdata" SELECTIVE_BUILD_STAT_DIR: "${{ github.workspace }}\\selective_build_stat" + CMAKE_TOOLCHAIN_FILE: "${{ github.workspace }}\\openvino\\cmake\\toolchains\\mt.runtime.win32.toolchain.cmake" # TODO: specify version of compiler here if: ${{ !needs.smart_ci.outputs.skip_workflow && github.event_name != 'merge_group' }} diff --git a/cmake/toolchains/mt.runtime.win32.toolchain.cmake b/cmake/toolchains/mt.runtime.win32.toolchain.cmake index d23b79570b190b..72a351286e9c7d 100644 --- a/cmake/toolchains/mt.runtime.win32.toolchain.cmake +++ b/cmake/toolchains/mt.runtime.win32.toolchain.cmake @@ -26,15 +26,19 @@ if(use_static_runtime) foreach(lang C CXX) foreach(build_type "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO") set(flag_var "CMAKE_${lang}_FLAGS${build_type}_INIT") - set(flag_var_noninit "CMAKE_${lang}_FLAGS${build_type}") string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endforeach() + endforeach() + foreach(type EXE SHARED MODULE) + foreach(build_type "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO") + set(flag_var "CMAKE_${type}_LINKER_FLAGS${build_type}_INIT") if (build_type STREQUAL "_DEBUG") - set(${flag_var_noninit} "${${flag_var_noninit}} /MTd") + string(APPEND ${flag_var} " /NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib") else() - set(${flag_var_noninit} "${${flag_var_noninit}} /MT") + string(APPEND ${flag_var} " /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") endif() endforeach() - endforeach() + endforeach() endif() macro(ov_set_msvc_runtime var value)