diff --git a/imperative/CMakeLists.txt b/imperative/CMakeLists.txt index 8561187d53963f3e0da8cceb81f4754b6fb2c087..cf1a8c354511646351722dc61ac22d4143f4264e 100644 --- a/imperative/CMakeLists.txt +++ b/imperative/CMakeLists.txt @@ -29,7 +29,6 @@ if (APPLE) target_link_libraries(${MODULE_NAME} PRIVATE megengine_shared) elseif (MSVC OR WIN32) 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}") set_target_properties(${MODULE_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}") else() diff --git a/lite/CMakeLists.txt b/lite/CMakeLists.txt index da465388387d19522edad0f02007def1ad131ac3..b0966ea892761226d81288b398418410ec5ecc17 100644 --- a/lite/CMakeLists.txt +++ b/lite/CMakeLists.txt @@ -46,9 +46,6 @@ include_directories($) if(LITE_BUILD_WITH_MGE) target_link_libraries(lite_static PRIVATE megbrain megdnn ${MGE_CUDA_LIBS}) 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.") else() target_link_libraries(lite_static PUBLIC flatbuffers) @@ -83,9 +80,6 @@ if(LITE_BUILD_WITH_MGE) else() target_link_libraries(lite_shared_whl PRIVATE megengine_shared) endif() - if(WIN32 OR MSVC) - target_compile_definitions(lite_shared_whl PRIVATE MGE_DLL_IMPORT_DATA) - endif() endif() if(ANDROID) target_link_libraries(lite_shared_whl PRIVATE log) diff --git a/lite/load_and_run/CMakeLists.txt b/lite/load_and_run/CMakeLists.txt index ad50c715e58793d40bb849ae3969caa430f53167..d7b5b9d9159e30cef189a50c40f2265f09acbf61 100644 --- a/lite/load_and_run/CMakeLists.txt +++ b/lite/load_and_run/CMakeLists.txt @@ -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 megengine) - if(WIN32 OR MSVC) - target_compile_definitions(load_and_run_depends_shared PRIVATE MGE_DLL_IMPORT_DATA) - endif() - if(LITE_BUILD_WITH_RKNPU) #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") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a834015218f215dc60bffa9e44b70fed9a5ea3b..57664c7472b5ba8782d594f84ade1fb2ba80fb6d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -224,10 +224,6 @@ if(WIN32 OR MSVC) target_compile_definitions(megdnn PRIVATE MGE_DLL_EXPORT) target_compile_definitions(megengine 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 #set_target_properties(megengine PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #set_target_properties(megengine_shared PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) diff --git a/src/megbrain_build_config.h.in b/src/megbrain_build_config.h.in index 3be29df3f211eaaedb69dc0490d684e5601dc84b..d0e31de29d0b22f660f2621f23bf9ef3cf42253a 100644 --- a/src/megbrain_build_config.h.in +++ b/src/megbrain_build_config.h.in @@ -253,22 +253,16 @@ #ifdef WIN32 #ifdef MGE_DLL_EXPORT #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 -#endif +#define MGE_WIN_DECLSPEC_DATA #else #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) -#else -#define MGE_WIN_DECLSPEC_DATA #endif #else +#define MGE_WIN_DECLSPEC_FUC #define MGE_WIN_DECLSPEC_DATA #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2b13c9b45c91528802847586075f6b81ccb7ca19..dd4b2c7e3e9957ad75adf2b24daf07c5bbaf1a48 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,6 +16,9 @@ if (MGE_WITH_CUDA AND MGE_WITH_TRT) endif() 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 megbrain megdnn ${MGE_CUDA_LIBS}) if (MGE_WITH_CUDA)