diff --git a/lite/CMakeLists.txt b/lite/CMakeLists.txt index 69b54eb3..127b15ec 100644 --- a/lite/CMakeLists.txt +++ b/lite/CMakeLists.txt @@ -99,26 +99,32 @@ endif() # MegEngine/megbrain ROOT_DIR/CMakeLists.txt, just depends lite_static or lite_shared # TODO: need refine lite_static_all_in_one depend objects, but now cmake do not support # define a add_library which OBJECTS args is a set or list or string -if(MGE_ENABLE_CPUINFO AND MGE_WITH_OPENCL) - add_library( - lite_static_all_in_one STATIC - $ $ $ - $ $) -elseif(MGE_ENABLE_CPUINFO AND NOT MGE_WITH_OPENCL) - add_library( - lite_static_all_in_one STATIC - $ $ $ - $) -elseif(NOT MGE_ENABLE_CPUINFO AND MGE_WITH_OPENCL) - add_library( - lite_static_all_in_one STATIC - $ $ - $) +if(NOT WIN32) + if(MGE_ENABLE_CPUINFO AND MGE_WITH_OPENCL) + add_library( + lite_static_all_in_one STATIC + $ $ $ + $ $) + elseif(MGE_ENABLE_CPUINFO AND NOT MGE_WITH_OPENCL) + add_library( + lite_static_all_in_one STATIC + $ $ $ + $) + elseif(NOT MGE_ENABLE_CPUINFO AND MGE_WITH_OPENCL) + add_library( + lite_static_all_in_one STATIC + $ $ + $) + else() + add_library(lite_static_all_in_one STATIC $ + $) + endif() else() - add_library(lite_static_all_in_one STATIC $ - $) + message( + WARNING "do not support lite_static_all_in_one on Windows, please use lite_shared") endif() -if(LITE_BUILD_WITH_MGE) + +if(LITE_BUILD_WITH_MGE AND NOT WIN32) target_link_libraries(lite_static_all_in_one PRIVATE megbrain megdnn ${MGE_CUDA_LIBS}) endif() @@ -157,15 +163,19 @@ install( install( TARGETS lite_shared + RUNTIME DESTINATION lite/lib/${MGE_ARCH} LIBRARY DESTINATION lite/lib/${MGE_ARCH} FRAMEWORK DESTINATION lite/lib/${MGE_ARCH} ARCHIVE DESTINATION lite/lib/${MGE_ARCH}) -install( - TARGETS lite_static_all_in_one - LIBRARY DESTINATION lite/lib/${MGE_ARCH} - FRAMEWORK DESTINATION lite/lib/${MGE_ARCH} - ARCHIVE DESTINATION lite/lib/${MGE_ARCH}) +if(NOT WIN32) + install( + TARGETS lite_static_all_in_one + LIBRARY DESTINATION lite/lib/${MGE_ARCH} + FRAMEWORK DESTINATION lite/lib/${MGE_ARCH} + ARCHIVE DESTINATION lite/lib/${MGE_ARCH}) +endif() + install(FILES ${PROJECT_SOURCE_DIR}/lite/include/lite/common_enum_c.h DESTINATION ${CMAKE_INSTALL_PREFIX}/lite/include/lite-c) diff --git a/lite/example/cpp_example/main.cpp b/lite/example/cpp_example/main.cpp index ff566ccb..f7f10953 100644 --- a/lite/example/cpp_example/main.cpp +++ b/lite/example/cpp_example/main.cpp @@ -109,7 +109,7 @@ std::shared_ptr lite::example::parse_npy( } void lite::example::set_cpu_affinity(const std::vector& cpuset) { -#if defined(__APPLE__) || defined(WIN32) +#if defined(__APPLE__) || defined(WIN32) || defined(_WIN32) #pragma message("set_cpu_affinity not enabled on apple and windows platform") #else cpu_set_t mask; diff --git a/lite/example/cpp_example/mge/user_allocator.cpp b/lite/example/cpp_example/mge/user_allocator.cpp index 7f547435..ecbb0f4e 100644 --- a/lite/example/cpp_example/mge/user_allocator.cpp +++ b/lite/example/cpp_example/mge/user_allocator.cpp @@ -19,7 +19,7 @@ class CheckAllocator : public lite::Allocator { public: //! allocate memory of size in the given device with the given align void* allocate(LiteDeviceType, int, size_t size, size_t align) override { -#ifdef WIN32 +#if defined(WIN32) || defined(_WIN32) return _aligned_malloc(size, align); #elif defined(__ANDROID__) || defined(ANDROID) return memalign(align, size); @@ -35,7 +35,7 @@ public: //! free the memory pointed by ptr in the given device void free(LiteDeviceType, int, void* ptr) override { -#ifdef WIN32 +#if defined(WIN32) || defined(_WIN32) _aligned_free(ptr); #else ::free(ptr);