Skip to content

Commit 404cd4e

Browse files
committed
update cmake file to force dynamic release CRT globally for all dependencies if it's release build
1 parent cca956d commit 404cd4e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

plugin_execution_providers/tensorrt/CMakeLists.txt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@ enable_language(CUDA)
99
file(TO_CMAKE_PATH CUDAToolkit_ROOT "/usr/local/cuda")
1010
find_package(CUDAToolkit REQUIRED)
1111

12-
# CMake config to force dynamic debug CRT globally for all dependencies.
12+
# CMake config to force dynamic debug CRT or dynamic release CRT globally for all dependencies.
1313
# This is to address the issue of:
1414
# libprotobufd.lib(common.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in unary_elementwise_ops_impl.obj
1515
if (WIN32)
1616
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
1717
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL" CACHE STRING "" FORCE) # /MDd
1818
set(BUILD_SHARED_LIBS OFF) # Build protobuf as static .lib, but using dynamic runtime
1919
endif()
20+
21+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
22+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" CACHE STRING "" FORCE)
23+
set(BUILD_SHARED_LIBS OFF) # Build protobuf as static .lib, but using dynamic runtime
24+
endif()
2025
endif()
2126

2227
add_definitions(-DONNX_NAMESPACE=onnx)
@@ -50,10 +55,8 @@ FetchContent_Declare(
5055
)
5156

5257
if (WIN32)
53-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
54-
# Sometimes, protobuf ignores CMAKE_MSVC_RUNTIME_LIBRARY. To ensure it works:
55-
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "" FORCE)
56-
endif()
58+
# Sometimes, protobuf ignores CMAKE_MSVC_RUNTIME_LIBRARY. To ensure it works:
59+
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "" FORCE)
5760
endif()
5861

5962
FetchContent_MakeAvailable(protobuf)
@@ -67,10 +70,6 @@ FetchContent_Declare(
6770

6871
FetchContent_MakeAvailable(onnx)
6972

70-
#set(ONNX_USE_LITE_PROTO OFF CACHE BOOL "" FORCE)
71-
#set(ONNX_BUILD_TESTS OFF CACHE BOOL "" FORCE)
72-
#set(ONNX_GEN_PB_TYPE_STUBS OFF CACHE BOOL "" FORCE)
73-
7473
# Add GSL
7574
FetchContent_Declare(
7675
gsl

0 commit comments

Comments
 (0)