diff --git a/.github/workflows/windows-x64-debug.yaml b/.github/workflows/windows-x64-debug.yaml index 7bcb5287..fd4e1dd1 100644 --- a/.github/workflows/windows-x64-debug.yaml +++ b/.github/workflows/windows-x64-debug.yaml @@ -40,13 +40,14 @@ concurrency: jobs: windows_x64_debug: - name: Windows x64 debug + name: Windows x64 ${{ matrix.build_type }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [windows-latest] shared_lib: [OFF] + build_type: [Debug, MinSizeRel, RelWithDebInfo] steps: - uses: actions/checkout@v4 @@ -58,21 +59,21 @@ jobs: run: | mkdir build cd build - cmake -A x64 -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install .. + cmake -A x64 -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -DCMAKE_INSTALL_PREFIX=./install .. - name: Build sherpa-onnx for windows shell: bash run: | cd build - cmake --build . --config Debug -- -m:2 - cmake --build . --config Debug --target install -- -m:2 + cmake --build . --config ${{ matrix.build_type }} -- -m:2 + cmake --build . --config ${{ matrix.build_type }} --target install -- -m:2 - ls -lh ./bin/Debug/sherpa-onnx.exe + ls -lh ./bin/${{ matrix.build_type }}/sherpa-onnx.exe - name: Test online CTC shell: bash run: | - export PATH=$PWD/build/bin/Debug:$PATH + export PATH=$PWD/build/bin/${{ matrix.build_type }}:$PATH export EXE=sherpa-onnx.exe .github/scripts/test-online-ctc.sh diff --git a/.github/workflows/windows-x86-debug.yaml b/.github/workflows/windows-x86-debug.yaml index 540db7d4..0b56e157 100644 --- a/.github/workflows/windows-x86-debug.yaml +++ b/.github/workflows/windows-x86-debug.yaml @@ -40,13 +40,14 @@ concurrency: jobs: windows_x86_debug: - name: Windows x86 debug + name: Windows x86 ${{ matrix.build_type }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [windows-latest] shared_lib: [OFF] + build_type: [Debug, MinSizeRel, RelWithDebInfo] steps: - uses: actions/checkout@v4 @@ -58,21 +59,21 @@ jobs: run: | mkdir build cd build - cmake -A Win32 -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -D CMAKE_INSTALL_PREFIX=./install .. + cmake -A Win32 -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} -D BUILD_SHARED_LIBS=${{ matrix.shared_lib }} -D CMAKE_INSTALL_PREFIX=./install .. - name: Build sherpa-onnx for windows shell: bash run: | cd build - cmake --build . --config Debug -- -m:2 - cmake --build . --config Debug --target install -- -m:2 + cmake --build . --config ${{ matrix.build_type }} -- -m:2 + cmake --build . --config ${{ matrix.build_type }} --target install -- -m:2 - ls -lh ./bin/Debug/sherpa-onnx.exe + ls -lh ./bin/${{ matrix.build_type }}/sherpa-onnx.exe - name: Test online CTC shell: bash run: | - export PATH=$PWD/build/bin/Debug:$PATH + export PATH=$PWD/build/bin/${{ matrix.build_type }}:$PATH export EXE=sherpa-onnx.exe .github/scripts/test-online-ctc.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index c1430127..21535f4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,8 @@ if(NOT BUILD_SHARED_LIBS AND MSVC) $<$:/MT> #---------| $<$:/MTd> #---|-- Statically link the runtime libraries $<$:/MT> #--| + $<$:/MT> + $<$:/MT> ) endif() endif() diff --git a/cmake/onnxruntime-win-x64-static-debug.cmake b/cmake/onnxruntime-win-x64-static-debug.cmake index c2b7314b..9871796f 100644 --- a/cmake/onnxruntime-win-x64-static-debug.cmake +++ b/cmake/onnxruntime-win-x64-static-debug.cmake @@ -15,22 +15,26 @@ if(BUILD_SHARED_LIBS) message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") endif() -if(NOT CMAKE_BUILD_TYPE STREQUAL Debug) - message(FATAL_ERROR "This file is for building a debug version on Windows x64") +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2") +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2") +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set(onnxruntime_HASH "SHA256=daef674f160044cf9f4c27d615eaa032f93c4ed6b8d2753bb91b4b37ba40349f") +elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) + set(onnxruntime_HASH "SHA256=3b580429702e6f471b0899f4f1eede68c0c394aa01cd00376562c2a2e8224d72") +elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRel) + set(onnxruntime_HASH "SHA256=2777b1a01355b94760388eb48dbf9900f5decf2a0bd358418806138a687db6f0") +else() + message(FATAL_ERROR "This file is for building a debug version on Windows x64. Given ${CMAKE_BUILD_TYPE}") endif() -set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2") -set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2") -set(onnxruntime_HASH "SHA256=6010bbab913cee3f11c421aeff9d173980623da6e72e88078396839a26d65c98") - # If you don't have access to the Internet, # please download onnxruntime to one of the following locations. # You can add more if you want. set(possible_file_locations - $ENV{HOME}/Downloads/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2 - ${CMAKE_SOURCE_DIR}/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2 - ${CMAKE_BINARY_DIR}/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2 - /tmp/onnxruntime-win-x64-static_lib-debug-1.17.0.tar.bz2 + $ENV{HOME}/Downloads/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2 + ${CMAKE_SOURCE_DIR}/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2 + ${CMAKE_BINARY_DIR}/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2 + /tmp/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2 ) foreach(f IN LISTS possible_file_locations) diff --git a/cmake/onnxruntime-win-x86-static-debug.cmake b/cmake/onnxruntime-win-x86-static-debug.cmake index 7498a69a..6a10f275 100644 --- a/cmake/onnxruntime-win-x86-static-debug.cmake +++ b/cmake/onnxruntime-win-x86-static-debug.cmake @@ -15,22 +15,27 @@ if(BUILD_SHARED_LIBS) message(FATAL_ERROR "This file is for building static libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") endif() -if(NOT CMAKE_BUILD_TYPE STREQUAL Debug) - message(FATAL_ERROR "This file is for building a debug version on Windows x86") -endif() -set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2") -set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2") -set(onnxruntime_HASH "SHA256=aa18677dd45338a90fc1bc14c86fe1e8a21f63913d40b3644924f5b24654218e") +set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2") +set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2") +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set(onnxruntime_HASH "SHA256=7ebf676b4cae50ae4c203ca54ae2341d7c7aeae66a965a85610b254d24effee3") +elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) + set(onnxruntime_HASH "SHA256=bcb1dd68643baf011dc519f938c61b90556f354c6e6ce801e3f08a350d51b689") +elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRel) + set(onnxruntime_HASH "SHA256=a73a42cbff851b1ee2ec037dd3f4254978516252bc353a7ce86d12030ba73dec") +else() + message(FATAL_ERROR "This file is for building a debug version on Windows x86. Given ${CMAKE_BUILD_TYPE}") +endif() # If you don't have access to the Internet, # please download onnxruntime to one of the following locations. # You can add more if you want. set(possible_file_locations - $ENV{HOME}/Downloads/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2 - ${CMAKE_SOURCE_DIR}/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2 - ${CMAKE_BINARY_DIR}/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2 - /tmp/onnxruntime-win-x86-static_lib-debug-1.17.0.tar.bz2 + $ENV{HOME}/Downloads/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2 + ${CMAKE_SOURCE_DIR}/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2 + ${CMAKE_BINARY_DIR}/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2 + /tmp/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.0.tar.bz2 ) foreach(f IN LISTS possible_file_locations) diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index 59a62c7f..a92ffa4e 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -71,10 +71,10 @@ function(download_onnxruntime) else() if(CMAKE_BUILD_TYPE STREQUAL Release) include(onnxruntime-win-x86-static) - elseif(CMAKE_BUILD_TYPE STREQUAL Debug) + elseif(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo OR CMAKE_BUILD_TYPE STREQUAL MinSizeRel) include(onnxruntime-win-x86-static-debug) else() - message(STATUS "Support only CMAKE_BUILD_TYPE Release or Debug. Given: ${CMAKE_BUILD_TYPE}") + message(FATAL_ERROR "Support only CMAKE_BUILD_TYPE being Release, Debug, RelWithDebInfo, or MinSizeRel. Given: ${CMAKE_BUILD_TYPE}") endif() endif() @@ -85,6 +85,7 @@ function(download_onnxruntime) # for 64-bit windows if(BUILD_SHARED_LIBS) + message(STATUS "Use dynamic onnxruntime libraries") if(SHERPA_ONNX_ENABLE_GPU) include(onnxruntime-win-x64-gpu) else() @@ -95,10 +96,10 @@ function(download_onnxruntime) message(STATUS "Use static onnxruntime libraries") if(CMAKE_BUILD_TYPE STREQUAL Release) include(onnxruntime-win-x64-static) - elseif(CMAKE_BUILD_TYPE STREQUAL Debug) + elseif(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo OR CMAKE_BUILD_TYPE STREQUAL MinSizeRel) include(onnxruntime-win-x64-static-debug) else() - message(STATUS "Support only CMAKE_BUILD_TYPE Release or Debug. Given: ${CMAKE_BUILD_TYPE}") + message(FATAL_ERROR "Support only CMAKE_BUILD_TYPE being Release, Debug, RelWithDebInfo, or MinSizeRel. Given: ${CMAKE_BUILD_TYPE}") endif() endif() endif()