From 00de4cd9ae69f473630ecf598e48d6f87ee20ce1 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Thu, 17 Sep 2020 23:49:22 +0800 Subject: [PATCH] fix(whl/windows): force use /MT for windows whl GitOrigin-RevId: 54a7814c17d6d008c360dc06e4088e363008ade5 --- CMakeLists.txt | 8 ++++++++ imperative/CMakeLists.txt | 2 ++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42cf25571..0179b0b43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,6 +152,14 @@ if(${MGE_ARCH} STREQUAL "x86_64" OR ${MGE_ARCH} STREQUAL "i386" OR ${MGE_ARCH} S endif() if(MSVC OR WIN32) + # for cmake after 3.15.2 + cmake_policy(SET CMP0091 NEW) + if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") + else() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") + endif() + add_compile_definitions(NOMINMAX=1 _USE_MATH_DEFINES=1 WIN32=1) message("-- into windows build...") message("-- CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}") diff --git a/imperative/CMakeLists.txt b/imperative/CMakeLists.txt index a07212704..a594206f2 100644 --- a/imperative/CMakeLists.txt +++ b/imperative/CMakeLists.txt @@ -57,6 +57,8 @@ if (APPLE) elseif (MSVC OR WIN32) # Windows does not support implicitly importing data members from DLL. target_link_libraries(${MODULE_NAME} PRIVATE megbrain megdnn) + message("-- CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}") + set_target_properties(${MODULE_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}") else() target_link_libraries(${MODULE_NAME} PRIVATE megengine_export -Wl,--version-script=${VERSION_SCRIPT}) endif() -- GitLab