mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-18 18:52:16 +00:00
Enable static linking of MSVC CRT using a build option. (#757)
* Enable static linking of MSVC CRT using a build option. * Add the C flags back
This commit is contained in:
parent
a28b42a42c
commit
7d3ea33daf
2 changed files with 4 additions and 2 deletions
|
|
@ -126,12 +126,12 @@ if (MSVC)
|
|||
# so that MSVCR*.DLL is not required at runtime.
|
||||
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
|
||||
# This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
|
||||
# https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime
|
||||
foreach(flag_var
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE__FLAGS_RELWITHDEBINFO)
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag_var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif(${flag_var} MATCHES "/MD")
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ Use the individual flags to only run the specified stages.
|
|||
parser.add_argument("--tensorrt_home", help="Path to TensorRT installation dir")
|
||||
parser.add_argument("--use_full_protobuf", action='store_true', help="Use the full protobuf library")
|
||||
parser.add_argument("--disable_contrib_ops", action='store_true', help="Disable contrib ops (reduces binary size)")
|
||||
parser.add_argument("--enable_msvc_static_runtime", action='store_true', help="Enable static linking of MSVC runtimes.")
|
||||
return parser.parse_args()
|
||||
|
||||
def resolve_executable_path(command_or_path):
|
||||
|
|
@ -318,6 +319,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home
|
|||
"-Donnxruntime_BUILD_x86=" + ("ON" if args.x86 else "OFF"),
|
||||
"-Donnxruntime_USE_FULL_PROTOBUF=" + ("ON" if args.use_full_protobuf else "OFF"),
|
||||
"-Donnxruntime_DISABLE_CONTRIB_OPS=" + ("ON" if args.disable_contrib_ops else "OFF"),
|
||||
"-Donnxruntime_MSVC_STATIC_RUNTIME=" + ("ON" if args.enable_msvc_static_runtime else "OFF"),
|
||||
]
|
||||
if args.use_brainslice:
|
||||
bs_pkg_name = args.brain_slice_package_name.split('.', 1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue