Skip to content

Commit

Permalink
Combine necessary changes for static build with VS runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
artanokhov committed Oct 28, 2024
1 parent f980ba8 commit 489b975
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/job_build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows_conditional_compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}

Expand Down
21 changes: 15 additions & 6 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,21 @@ function(ov_download_tbb)
if(WIN32 AND X86_64)
# TODO: add target_path to be platform specific as well, to avoid following if
# build oneTBB 2021.2.1 with Visual Studio 2019 (MSVC 14.21)
RESOLVE_DEPENDENCY(TBB
ARCHIVE_WIN "oneapi-tbb-2021.2.5-win-trim.zip"
TARGET_PATH "${TEMP}/tbb"
ENVIRONMENT "TBBROOT"
SHA256 "a9384a25861946648db58f7f294c4aa2b1be7ae52748024fef3e13ca2762a1ba"
USE_NEW_LOCATION TRUE)
if (TBB_STATIC_CRT)
RESOLVE_DEPENDENCY(TBB
ARCHIVE_WIN "oneapi-tbb-2021.2.5-win-vcruntime.zip"
TARGET_PATH "${TEMP}/tbb"
ENVIRONMENT "TBBROOT"
SHA256 "dc6d5caed18fe4a30e088d1e45f92aac8fa10f542d19019edafa6aeea4465551"
USE_NEW_LOCATION TRUE)
else()
RESOLVE_DEPENDENCY(TBB
ARCHIVE_WIN "oneapi-tbb-2021.2.5-win-trim-cfg-simplify.zip"
TARGET_PATH "${TEMP}/tbb"
ENVIRONMENT "TBBROOT"
SHA256 "63bf0992406d69dfb3c402f46466face2388ca55b6678f29072ba304f3622fe7"
USE_NEW_LOCATION TRUE)
endif()
elseif(ANDROID AND X86_64)
RESOLVE_DEPENDENCY(TBB
ARCHIVE_ANDROID "tbb2020_20200404_android.tgz"
Expand Down
16 changes: 11 additions & 5 deletions cmake/toolchains/mt.runtime.win32.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -58,6 +62,8 @@ ov_set_msvc_runtime(CLDNN__COMPILE_LINK_USE_STATIC_RUNTIME ${use_static_runtime}
ov_set_msvc_runtime(USE_DYNAMIC_VCXX_RUNTIME ${use_dynamic_runtime})
# google-test
ov_set_msvc_runtime(gtest_force_shared_crt ${use_dynamic_runtime})
# tbb package
ov_set_msvc_runtime(TBB_STATIC_CRT ${use_static_runtime})

unset(use_static_runtime)
unset(use_dynamic_runtime)
unset(use_dynamic_runtime)

0 comments on commit 489b975

Please sign in to comment.