提交 46d4bd8a 编写于 作者: M Megvii Engine Team

feat(windows): let sdk do not care about more macro on win

GitOrigin-RevId: c522c2fd632b8b908e1c5641fad43f231c597d3a
上级 c90e0b54
...@@ -29,7 +29,6 @@ if (APPLE) ...@@ -29,7 +29,6 @@ if (APPLE)
target_link_libraries(${MODULE_NAME} PRIVATE megengine_shared) target_link_libraries(${MODULE_NAME} PRIVATE megengine_shared)
elseif (MSVC OR WIN32) elseif (MSVC OR WIN32)
target_link_libraries(${MODULE_NAME} PRIVATE megengine_shared) target_link_libraries(${MODULE_NAME} PRIVATE megengine_shared)
target_compile_definitions(${MODULE_NAME} PRIVATE MGE_DLL_IMPORT_DATA)
message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}") message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}")
set_target_properties(${MODULE_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}") set_target_properties(${MODULE_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}")
else() else()
......
...@@ -46,9 +46,6 @@ include_directories($<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/genfiles>) ...@@ -46,9 +46,6 @@ include_directories($<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/genfiles>)
if(LITE_BUILD_WITH_MGE) if(LITE_BUILD_WITH_MGE)
target_link_libraries(lite_static PRIVATE megbrain megdnn ${MGE_CUDA_LIBS}) target_link_libraries(lite_static PRIVATE megbrain megdnn ${MGE_CUDA_LIBS})
add_compile_definitions(LITE_BUILD_WITH_MGE=1) add_compile_definitions(LITE_BUILD_WITH_MGE=1)
if(WIN32 OR MSVC)
target_compile_definitions(lite_static PRIVATE MGE_DLL_IMPORT_DATA)
endif()
message(STATUS "build lite with MegEngine.") message(STATUS "build lite with MegEngine.")
else() else()
target_link_libraries(lite_static PUBLIC flatbuffers) target_link_libraries(lite_static PUBLIC flatbuffers)
...@@ -83,9 +80,6 @@ if(LITE_BUILD_WITH_MGE) ...@@ -83,9 +80,6 @@ if(LITE_BUILD_WITH_MGE)
else() else()
target_link_libraries(lite_shared_whl PRIVATE megengine_shared) target_link_libraries(lite_shared_whl PRIVATE megengine_shared)
endif() endif()
if(WIN32 OR MSVC)
target_compile_definitions(lite_shared_whl PRIVATE MGE_DLL_IMPORT_DATA)
endif()
endif() endif()
if(ANDROID) if(ANDROID)
target_link_libraries(lite_shared_whl PRIVATE log) target_link_libraries(lite_shared_whl PRIVATE log)
......
...@@ -33,10 +33,6 @@ if(BUILD_SHARED_LIBS) ...@@ -33,10 +33,6 @@ if(BUILD_SHARED_LIBS)
target_link_libraries(load_and_run_depends_shared gflags) target_link_libraries(load_and_run_depends_shared gflags)
target_link_libraries(load_and_run_depends_shared megengine) target_link_libraries(load_and_run_depends_shared megengine)
if(WIN32 OR MSVC)
target_compile_definitions(load_and_run_depends_shared PRIVATE MGE_DLL_IMPORT_DATA)
endif()
if(LITE_BUILD_WITH_RKNPU) if(LITE_BUILD_WITH_RKNPU)
#rknn sdk1.0.0 depend on libc++_shared, use gold to remove NEEDED so symbol check #rknn sdk1.0.0 depend on libc++_shared, use gold to remove NEEDED so symbol check
target_link_options(load_and_run_depends_shared PRIVATE "-fuse-ld=gold") target_link_options(load_and_run_depends_shared PRIVATE "-fuse-ld=gold")
......
...@@ -224,10 +224,6 @@ if(WIN32 OR MSVC) ...@@ -224,10 +224,6 @@ if(WIN32 OR MSVC)
target_compile_definitions(megdnn PRIVATE MGE_DLL_EXPORT) target_compile_definitions(megdnn PRIVATE MGE_DLL_EXPORT)
target_compile_definitions(megengine PRIVATE MGE_DLL_EXPORT) target_compile_definitions(megengine PRIVATE MGE_DLL_EXPORT)
target_compile_definitions(megengine_shared PRIVATE MGE_DLL_EXPORT) target_compile_definitions(megengine_shared PRIVATE MGE_DLL_EXPORT)
target_compile_definitions(megbrain PRIVATE MGE_DLL_EXPORT_DATA)
target_compile_definitions(megdnn PRIVATE MGE_DLL_EXPORT_DATA)
target_compile_definitions(megengine PRIVATE MGE_DLL_EXPORT_DATA)
target_compile_definitions(megengine_shared PRIVATE MGE_DLL_EXPORT_DATA)
# please do not use WINDOWS_EXPORT_ALL_SYMBOLS, as symbols max than 65535 when build with CUDA # please do not use WINDOWS_EXPORT_ALL_SYMBOLS, as symbols max than 65535 when build with CUDA
#set_target_properties(megengine PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #set_target_properties(megengine PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
#set_target_properties(megengine_shared PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #set_target_properties(megengine_shared PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
......
...@@ -253,22 +253,16 @@ ...@@ -253,22 +253,16 @@
#ifdef WIN32 #ifdef WIN32
#ifdef MGE_DLL_EXPORT #ifdef MGE_DLL_EXPORT
#define MGE_WIN_DECLSPEC_FUC __declspec(dllexport) #define MGE_WIN_DECLSPEC_FUC __declspec(dllexport)
#else #define MGE_WIN_DECLSPEC_DATA __declspec(dllexport)
#elif defined(MGE_WINDOWS_STATIC_LINK)
#define MGE_WIN_DECLSPEC_FUC #define MGE_WIN_DECLSPEC_FUC
#endif #define MGE_WIN_DECLSPEC_DATA
#else #else
#define MGE_WIN_DECLSPEC_FUC #define MGE_WIN_DECLSPEC_FUC
#endif
#ifdef WIN32
#if defined(MGE_DLL_EXPORT_DATA)
#define MGE_WIN_DECLSPEC_DATA __declspec(dllexport)
#elif defined(MGE_DLL_IMPORT_DATA)
#define MGE_WIN_DECLSPEC_DATA __declspec(dllimport) #define MGE_WIN_DECLSPEC_DATA __declspec(dllimport)
#else
#define MGE_WIN_DECLSPEC_DATA
#endif #endif
#else #else
#define MGE_WIN_DECLSPEC_FUC
#define MGE_WIN_DECLSPEC_DATA #define MGE_WIN_DECLSPEC_DATA
#endif #endif
......
...@@ -16,6 +16,9 @@ if (MGE_WITH_CUDA AND MGE_WITH_TRT) ...@@ -16,6 +16,9 @@ if (MGE_WITH_CUDA AND MGE_WITH_TRT)
endif() endif()
add_executable(megbrain_test ${SOURCES}) add_executable(megbrain_test ${SOURCES})
if(WIN32 OR MSVC)
target_compile_definitions(megbrain_test PRIVATE MGE_WINDOWS_STATIC_LINK)
endif()
target_link_libraries(megbrain_test gtest gmock) target_link_libraries(megbrain_test gtest gmock)
target_link_libraries(megbrain_test megbrain megdnn ${MGE_CUDA_LIBS}) target_link_libraries(megbrain_test megbrain megdnn ${MGE_CUDA_LIBS})
if (MGE_WITH_CUDA) if (MGE_WITH_CUDA)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册