support vc runtime static linkage (#472)

* support vc runtime static linkage

* typo

* add unit test

* Update ci.yml
This commit is contained in:
Wenbing Li 2023-06-20 16:40:29 -07:00 коммит произвёл GitHub
Родитель b399dd6b38
Коммит a6012b383e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -271,6 +271,17 @@ jobs:
ctest -C RelWithDebInfo --output-on-failure ctest -C RelWithDebInfo --output-on-failure
displayName: Run C++ native tests displayName: Run C++ native tests
- job: WindowsStaticVC
pool:
vmImage: 'windows-latest'
steps:
- script: |
call .\build.bat -DOCOS_ENABLE_CTEST=ON -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"
cd out/Windows
ctest -C RelWithDebInfo --output-on-failure
displayName: build and test ort-extensions with VC static runtime.
################ ################
# Windows Python # Windows Python
################ ################

6
cmake/externals/sentencepieceproject.cmake поставляемый
Просмотреть файл

@ -19,7 +19,11 @@ if(NOT _ONNXRUNTIME_EMBEDDED)
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "") set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "")
endif() endif()
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "") set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "")
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "") if("${CMAKE_MSVC_RUNTIME_LIBRARY}" STREQUAL "" OR "${CMAKE_MSVC_RUNTIME_LIBRARY}" MATCHES "DLL$")
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "")
else()
set(protobuf_MSVC_STATIC_RUNTIME ON CACHE BOOL "")
endif()
set(protobuf_DISABLE_RTTI ON CACHE BOOL "Disable RTTI") set(protobuf_DISABLE_RTTI ON CACHE BOOL "Disable RTTI")
FetchContent_GetProperties(protobuf) FetchContent_GetProperties(protobuf)
if(NOT protobuf_POPULATED) if(NOT protobuf_POPULATED)

Просмотреть файл

@ -28,8 +28,12 @@ Use `./tools/ios/build_xcframework.py` to build an iOS xcframework package.
## Web-Assembly ## Web-Assembly
ONNXRuntime-Extensions will be built as a static library and linked with ONNXRuntime due to the lack of a good dynamic linking mechanism in WASM. Here are two additional arguments [–-use_extensions and --extensions_overridden_path](https://github.com/microsoft/onnxruntime/blob/860ba8820b72d13a61f0d08b915cd433b738ffdc/tools/ci_build/build.py#L416) on building onnxruntime to include ONNXRuntime-Extensions footprint in the ONNXRuntime package. ONNXRuntime-Extensions will be built as a static library and linked with ONNXRuntime due to the lack of a good dynamic linking mechanism in WASM. Here are two additional arguments [–-use_extensions and --extensions_overridden_path](https://github.com/microsoft/onnxruntime/blob/860ba8820b72d13a61f0d08b915cd433b738ffdc/tools/ci_build/build.py#L416) on building onnxruntime to include ONNXRuntime-Extensions footprint in the ONNXRuntime package.
## The C++ share library ## The C++ shared library
for any other cases, please run `build.bat` or `bash ./build.sh` to build the library. By default, the DLL or the library will be generated in the directory `out/<OS>/<FLAVOR>`. There is a unit test to help verify the build. for any other cases, please run `build.bat` or `bash ./build.sh` to build the library. By default, the DLL or the library will be generated in the directory `out/<OS>/<FLAVOR>`. There is a unit test to help verify the build.
**VC Runtime static linkage**
If you want to build the binary with VC Runtime static linkage, please add a parameter _-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>"_ on running build.bat
## Copyright guidance ## Copyright guidance
check this link https://docs.opensource.microsoft.com/releasing/general-guidance/copyright-headers/ for source file copyright header. check this link https://docs.opensource.microsoft.com/releasing/general-guidance/copyright-headers/ for source file copyright header.