提交 ff464bbc 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!397 [MS]support building and packaging on windows 10

Merge pull request !397 from chenjianping/building-on-windows-3
......@@ -69,6 +69,7 @@ MindSpore offers build options across multiple backends:
| GPU CUDA 9.2 | Ubuntu-x86 | ✔️ |
| GPU CUDA 10.1 | Ubuntu-x86 | ✔️ |
| CPU | Ubuntu-x86 | ✔️ |
| CPU | Windows-x86 | ✔️ |
For installation using `pip`, take `CPU` and `Ubuntu-x86` build version as an example:
......
......@@ -21,9 +21,9 @@ IF NOT %errorlevel% == 0 (
)
IF "%1%" == "" (
cmake --build . --target all -- -j6
cmake --build . --target package -- -j6
) ELSE (
cmake --build . --target all -- -j%1%
cmake --build . --target package -- -j%1%
)
IF NOT %errorlevel% == 0 (
goto run_fail
......
......@@ -8,6 +8,9 @@ else()
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
set(tiff_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \
-Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2")
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(tiff_CFLAGS "${tiff_CFLAGS} -Wno-int-to-pointer-cast -Wno-implicit-fallthrough -Wno-pointer-to-int-cast")
endif()
endif()
set(tiff_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
......
......@@ -5,6 +5,8 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-attributes -Wno-unknown-pragmas")
set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-unused-value -Wno-implicit-fallthrough")
else()
set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
......@@ -28,6 +30,7 @@ if (WIN32)
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_videoio=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
......
......@@ -30,9 +30,18 @@ include(CPack)
# set install path
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_PY_DIR ".")
set(INSTALL_LIB_DIR "lib")
set(INSTALL_BASE_DIR ".")
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(INSTALL_LIB_DIR ".")
set(onednn_LIBPATH ${onednn_LIBPATH}/../bin/)
set(glog_LIBPATH ${glog_LIBPATH}/../bin/)
set(opencv_LIBPATH ${opencv_LIBPATH}/../bin/)
set(jpeg_turbo_LIBPATH ${jpeg_turbo_LIBPATH}/../bin/)
else ()
set(INSTALL_LIB_DIR "lib")
endif ()
# set package files
install(
TARGETS _c_expression
......@@ -80,7 +89,7 @@ if (ENABLE_CPU)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.lib)
file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll)
endif ()
install(
FILES ${DNNL_LIB_LIST}
......@@ -140,6 +149,18 @@ if (NOT ENABLE_GE)
endif ()
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll)
file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll)
file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll)
install(
FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST}
DESTINATION ${INSTALL_LIB_DIR}
COMPONENT mindspore
)
endif ()
# set python files
file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py)
install(
......
......@@ -533,5 +533,13 @@ endif()
if(ENABLE_MINDDATA)
add_subdirectory(mindrecord)
add_subdirectory(dataset)
if (WIN32)
set(_md_tmp_CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O0 -Wl,--allow-shlib-undefined -DHALF_ENABLE_CPP11_USER_LITERALS=0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2")
add_subdirectory(dataset)
set(CMAKE_CXX_FLAGS_RELEASE ${_md_tmp_CMAKE_CXX_FLAGS_RELEASE})
else()
add_subdirectory(dataset)
endif()
endif()
......@@ -14,8 +14,10 @@
# ============================================================================
"""Operators info register."""
from .akg.gpu import *
from .tbe import *
import platform
from .aicpu import *
if "Windows" not in platform.system():
from .akg.gpu import *
from .tbe import *
__all__ = []
......@@ -17,6 +17,7 @@
"""setup package."""
import os
import stat
import platform
from setuptools import setup, find_packages
from setuptools.command.egg_info import egg_info
......@@ -97,6 +98,8 @@ required_package = [
package_data = {
'': [
'*.so*',
'*.pyd',
'*.dll',
'lib/*.so*',
'lib/*.a',
'.commit_id',
......@@ -111,6 +114,9 @@ def update_permissions(path):
Args:
path (str): Target directory path.
"""
if platform.system() == "Windows":
return
for dirpath, dirnames, filenames in os.walk(path):
for dirname in dirnames:
dir_fullpath = os.path.join(dirpath, dirname)
......
SET(CMAKE_BUILD_TYPE "Debug")
if (WIN32)
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer")
else()
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)='")
......@@ -8,8 +8,8 @@ SET(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -fPIC -O3 -Wall -Wno-deprecated-declarat
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#add flags
if (WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include")
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Wno-attributes")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror")
endif()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册