diff --git a/CMakeLists.txt b/CMakeLists.txt index 0179b0b43733ebc42da850df8364edba73924d6d..83a48da4d270ad03515e13d9c78450c162719c0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,9 +53,11 @@ option(MGE_WITH_DISTRIBUTED "Build with distributed support" ON) option(MGE_BUILD_IMPERATIVE_RT "Build _imperative_rt Python Module " ON) option(MGE_BUILD_SDK "Build load_and_run" ON) option(MGE_INFERENCE_ONLY "Build inference only library." OFF) +option(MGE_WITH_PYTHON_MODULE "Build MegEngine legacy Python Module." OFF) option(MGE_WITH_MKLDNN "Enable Intel MKL_DNN support," ON) option(MGE_WITH_ROCM "Enable ROCM support" OFF) + if(NOT ${MGE_BIN_REDUCE} STREQUAL "") message("build with BIN REDUCE") if(MGE_WITH_MINIMUM_SIZE) diff --git a/imperative/CMakeLists.txt b/imperative/CMakeLists.txt index a594206f28a8bc19ed37a4bab0de14400eabf20a..910f5bb4254256a5ffa886c0f43a08378553e2af 100644 --- a/imperative/CMakeLists.txt +++ b/imperative/CMakeLists.txt @@ -60,7 +60,18 @@ elseif (MSVC OR WIN32) 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}) + if (MGE_WITH_PYTHON_MODULE) + # use to fix runtime crash when build both mgb(MGE_WITH_PYTHON_MODULE) and imperative(MGE_BUILD_IMPERATIVE_RT) + target_link_libraries(${MODULE_NAME} PRIVATE megengine_export -Wl,--version-script=${VERSION_SCRIPT}) + else() + # use to reduce whl size by depend on megbrain/dnn directly, caused by cmake create two cuda fatbin + # elf section on both megengine_export and target which depend on megengine_export + target_link_libraries(${MODULE_NAME} PRIVATE megbrain megdnn -Wl,--version-script=${VERSION_SCRIPT}) + if (MGE_WITH_DISTRIBUTED) + message("-- Imperative configured to link megray") + target_link_libraries(${MODULE_NAME} PRIVATE megray) + endif() + endif() endif() target_include_directories(${MODULE_NAME} PUBLIC src/include PRIVATE ${PYTHON_INCLUDE_DIRS} ${NUMPY_INCLUDE_DIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d380d389eab3940b316f470e83ecad6068b25215..ef96423eba581dcdc4a88171c93a47f0542883ea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -189,7 +189,7 @@ if(MGE_BUILD_IMPERATIVE_RT add_library(megengine_export SHARED) target_link_libraries(megengine_export PUBLIC megbrain megdnn) if (MGE_WITH_DISTRIBUTED) - message("megengine_export configured to link megray") + message("-- megengine_export configured to link megray") target_link_libraries(megengine_export PUBLIC megray) endif() endif()