diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2d7a89cf30..82e9d04e7d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -127,12 +127,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") diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index c87caf2138..99c8d7494e 100755 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -136,6 +136,7 @@ Use the individual flags to only run the specified stages. 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("--skip_onnx_tests", action='store_true', help="Explicitly disable all onnx related tests") + 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): @@ -325,6 +326,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home # TensorRT provider currently only supports full_protobuf option. "-Donnxruntime_USE_FULL_PROTOBUF=" + ("ON" if args.use_full_protobuf or args.use_tensorrt 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)