ソースを参照

fix building with mingw (#115)

Fangjun Kuang 2 年 前
コミット
b311159aeb
5 ファイル変更62 行追加42 行削除
  1. 2 2
      CMakeLists.txt
  2. 17 12
      cmake/kaldi-native-fbank.cmake
  3. 15 10
      cmake/ncnn.cmake
  4. 14 9
      cmake/portaudio.cmake
  5. 14 9
      cmake/pybind11.cmake

+ 2 - 2
CMakeLists.txt

@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
 project(sherpa-ncnn)
 
-set(SHERPA_NCNN_VERSION "1.5.1")
+set(SHERPA_NCNN_VERSION "1.5.2")
 
 # Disable warning about
 #
@@ -73,7 +73,7 @@ if(WIN32)
   add_definitions(-DNOMINMAX) # Otherwise, std::max() and std::min() won't work
 endif()
 
-if(WIN32)
+if(WIN32 AND MSVC)
   # disable various warnings for MSVC
   # 4244: 'return': conversion from 'unsigned __int64' to 'int', possible loss of data
   # 4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data

+ 17 - 12
cmake/kaldi-native-fbank.cmake

@@ -2,20 +2,25 @@ function(download_kaldi_native_fbank)
   include(FetchContent)
 
   # Please also change ../pack-for-embedded-systems.sh
-  set(kaldi_native_fbank_URL  "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.11.tar.gz")
-  set(kaldi_native_fbank_HASH "SHA256=e69ae25ef6f30566ef31ca949dd1b0b8ec3a827caeba93a61d82bb848dac5d69")
+  set(kaldi_native_fbank_URL  "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.12.tar.gz")
+  set(kaldi_native_fbank_HASH "SHA256=8f4dfc3f6ddb1adcd9ac0ae87743ebc6cbcae147aacf9d46e76fa54134e12b44")
 
   # If you don't have access to the Internet, please download it to your
   # local drive and modify the following line according to your needs.
-  if(EXISTS "/star-fj/fangjun/download/github/kaldi-native-fbank-1.11.tar.gz")
-    set(kaldi_native_fbank_URL  "file:///star-fj/fangjun/download/github/kaldi-native-fbank-1.11.tar.gz")
-  elseif(EXISTS "/Users/fangjun/Downloads/kaldi-native-fbank-1.11.tar.gz")
-    set(kaldi_native_fbank_URL  "file:///Users/fangjun/Downloads/kaldi-native-fbank-1.11.tar.gz")
-  elseif(EXISTS "/tmp/kaldi-native-fbank-1.11.tar.gz")
-    set(kaldi_native_fbank_URL  "file:///tmp/kaldi-native-fbank-1.11.tar.gz")
-  elseif(EXISTS "$ENV{HOME}/asr/kaldi-native-fbank-1.11.tar.gz")
-    set(kaldi_native_fbank_URL  "file://$ENV{HOME}/asr/kaldi-native-fbank-1.11.tar.gz")
-  endif()
+  set(possible_file_locations
+    $ENV{HOME}/Downloads/kaldi-native-fbank-1.12.tar.gz
+    $ENV{HOME}/asr/kaldi-native-fbank-1.12.tar.gz
+    ${PROJECT_SOURCE_DIR}/kaldi-native-fbank-1.12.tar.gz
+    ${PROJECT_BINARY_DIR}/kaldi-native-fbank-1.12.tar.gz
+    /tmp/kaldi-native-fbank-1.12.tar.gz
+  )
+
+  foreach(f IN LISTS possible_file_locations)
+    if(EXISTS ${f})
+      set(kaldi_native_fbank_URL  "file://${f}")
+      break()
+    endif()
+  endforeach()
 
   set(KALDI_NATIVE_FBANK_BUILD_TESTS OFF CACHE BOOL "" FORCE)
   set(KALDI_NATIVE_FBANK_BUILD_PYTHON OFF CACHE BOOL "" FORCE)
@@ -28,7 +33,7 @@ function(download_kaldi_native_fbank)
 
   FetchContent_GetProperties(kaldi_native_fbank)
   if(NOT kaldi_native_fbank_POPULATED)
-    message(STATUS "Downloading kaldi-native-fbank ${kaldi_native_fbank_URL}")
+    message(STATUS "Downloading kaldi-native-fbank from ${kaldi_native_fbank_URL}")
     FetchContent_Populate(kaldi_native_fbank)
   endif()
   message(STATUS "kaldi-native-fbank is downloaded to ${kaldi_native_fbank_SOURCE_DIR}")

+ 15 - 10
cmake/ncnn.cmake

@@ -11,15 +11,20 @@ function(download_ncnn)
 
   # If you don't have access to the Internet, please download it to your
   # local drive and modify the following line according to your needs.
-  if(EXISTS "/star-fj/fangjun/download/github/ncnn-sherpa-0.9.tar.gz")
-    set(ncnn_URL  "file:///star-fj/fangjun/download/github/ncnn-sherpa-0.9.tar.gz")
-  elseif(EXISTS "/Users/fangjun/Downloads/ncnn-sherpa-0.9.tar.gz")
-    set(ncnn_URL  "file:///Users/fangjun/Downloads/ncnn-sherpa-0.9.tar.gz")
-  elseif(EXISTS "/tmp/ncnn-sherpa-0.9.tar.gz")
-    set(ncnn_URL  "file:///tmp/ncnn-sherpa-0.9.tar.gz")
-  elseif(EXISTS "$ENV{HOME}/asr/ncnn-sherpa-0.9.tar.gz")
-    set(ncnn_URL  "file://$ENV{HOME}/asr/ncnn-sherpa-0.9.tar.gz")
-  endif()
+  set(possible_file_locations
+    $ENV{HOME}/Downloads/ncnn-sherpa-0.9.tar.gz
+    $ENV{HOME}/asr/ncnn-sherpa-0.9.tar.gz
+    ${PROJECT_SOURCE_DIR}/ncnn-sherpa-0.9.tar.gz
+    ${PROJECT_BINARY_DIR}/ncnn-sherpa-0.9.tar.gz
+    /tmp/ncnn-sherpa-0.9.tar.gz
+  )
+
+  foreach(f IN LISTS possible_file_locations)
+    if(EXISTS ${f})
+      set(ncnn_URL  "file://${f}")
+      break()
+    endif()
+  endforeach()
 
   FetchContent_Declare(ncnn
     URL               ${ncnn_URL}
@@ -156,7 +161,7 @@ function(download_ncnn)
 
   FetchContent_GetProperties(ncnn)
   if(NOT ncnn_POPULATED)
-    message(STATUS "Downloading ncnn ${ncnn_URL}")
+    message(STATUS "Downloading ncnn from ${ncnn_URL}")
     FetchContent_Populate(ncnn)
   endif()
   message(STATUS "ncnn is downloaded to ${ncnn_SOURCE_DIR}")

+ 14 - 9
cmake/portaudio.cmake

@@ -6,15 +6,20 @@ function(download_portaudio)
 
   # If you don't have access to the Internet, please download it to your
   # local drive and modify the following line according to your needs.
-  if(EXISTS "/star-fj/fangjun/download/github/pa_stable_v190700_20210406.tgz")
-    set(portaudio_URL  "file:///star-fj/fangjun/download/github/pa_stable_v190700_20210406.tgz")
-  elseif(EXISTS "/Users/fangjun/Downloads/pa_stable_v190700_20210406.tgz")
-    set(portaudio_URL  "file:///Users/fangjun/Downloads/pa_stable_v190700_20210406.tgz")
-  elseif(EXISTS "/tmp/pa_stable_v190700_20210406.tgz")
-    set(portaudio_URL  "file:///tmp/pa_stable_v190700_20210406.tgz")
-  elseif(EXISTS "$ENV{HOME}/asr/pa_stable_v190700_20210406.tgz")
-    set(portaudio_URL  "file://$ENV{HOME}/asr/pa_stable_v190700_20210406.tgz")
-  endif()
+  set(possible_file_locations
+    $ENV{HOME}/Downloads/pa_stable_v190700_20210406.tgz
+    $ENV{HOME}/asr/pa_stable_v190700_20210406.tgz
+    ${PROJECT_SOURCE_DIR}/pa_stable_v190700_20210406.tgz
+    ${PROJECT_BINARY_DIR}/pa_stable_v190700_20210406.tgz
+    /tmp/pa_stable_v190700_20210406.tgz
+  )
+
+  foreach(f IN LISTS possible_file_locations)
+    if(EXISTS ${f})
+      set(portaudio_URL  "file://${f}")
+      break()
+    endif()
+  endforeach()
 
   if(BUILD_SHARED_LIBS)
     set(PA_BUILD_SHARED ON CACHE BOOL "" FORCE)

+ 14 - 9
cmake/pybind11.cmake

@@ -6,15 +6,20 @@ function(download_pybind11)
 
   # If you don't have access to the Internet, please download it to your
   # local drive and modify the following line according to your needs.
-  if(EXISTS "/star-fj/fangjun/download/github/pybind11-2.10.2.tar.gz")
-    set(pybind11_URL  "file:///star-fj/fangjun/download/github/pybind11-2.10.2.tar.gz")
-  elseif(EXISTS "/Users/fangjun/Downloads/pybind11-2.10.2.tar.gz")
-    set(pybind11_URL  "file:///Users/fangjun/Downloads/pybind11-2.10.2.tar.gz")
-  elseif(EXISTS "/tmp/pybind11-2.10.2.tar.gz")
-    set(pybind11_URL  "file:///tmp/pybind11-2.10.2.tar.gz")
-  elseif(EXISTS "$ENV{HOME}/asr/pybind11-2.10.2.tar.gz")
-    set(pybind11_URL  "file://$ENV{HOME}/asr/pybind11-2.10.2.tar.gz")
-  endif()
+  set(possible_file_locations
+    $ENV{HOME}/Downloads/pybind11-2.10.2.tar.gz
+    $ENV{HOME}/asr/pybind11-2.10.2.tar.gz
+    ${PROJECT_SOURCE_DIR}/pybind11-2.10.2.tar.gz
+    ${PROJECT_BINARY_DIR}/pybind11-2.10.2.tar.gz
+    /tmp/pybind11-2.10.2.tar.gz
+  )
+
+  foreach(f IN LISTS possible_file_locations)
+    if(EXISTS ${f})
+      set(pybind11_URL  "file://${f}")
+      break()
+    endif()
+  endforeach()
 
   FetchContent_Declare(pybind11
     URL               ${pybind11_URL}