Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support building static libraries #21

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
support building static libraries
csukuangfj committed Nov 26, 2023
commit 6595b2e5b1a29837302eb22a220ebc7be371b35f
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -21,8 +21,10 @@ elseif(NOT APPLE)
string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
endif()

option(BUILD_SHARED_LIBS "Whether to build shared libraries" ON)

add_library(
piper_phonemize SHARED
piper_phonemize
src/phonemize.cpp
src/phoneme_ids.cpp
src/tashkeel.cpp
@@ -107,7 +109,7 @@ if(NOT DEFINED ESPEAK_NG_DIR)
URL "https://github.com/rhasspy/espeak-ng/archive/refs/heads/master.zip"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ESPEAK_NG_DIR}
CMAKE_ARGS -DUSE_ASYNC:BOOL=OFF
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=ON
CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
CMAKE_ARGS -DUSE_MBROLA:BOOL=OFF
CMAKE_ARGS -DUSE_LIBSONIC:BOOL=OFF
CMAKE_ARGS -DUSE_LIBPCAUDIO:BOOL=OFF
@@ -142,6 +144,10 @@ target_link_libraries(
onnxruntime
)

if(NOT BUILD_SHARED_LIBS)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to fix the following link errors:

[ 45%] Built target piper_phonemize
[ 54%] Linking CXX executable piper_phonemize
Undefined symbols for architecture x86_64:
  "_ucd_isalnum", referenced from:
      _TranslateClauseWithTerminator in libespeak-ng.a(translate.c.o)
      _ReadClause in libespeak-ng.a(readclause.c.o)
  "_ucd_isalpha", referenced from:
      _TranslateChar in libespeak-ng.a(translate.c.o)
      _CombineFlag in libespeak-ng.a(translate.c.o)
      _GetTranslatedPhonemeString in libespeak-ng.a(dictionary.c.o)
      _TranslateRules in libespeak-ng.a(dictionary.c.o)
      _MatchRule in libespeak-ng.a(dictionary.c.o)
      _ReadClause in libespeak-ng.a(readclause.c.o)
      _IsAlpha in libespeak-ng.a(common.c.o)
      ...
  "_ucd_isdigit", referenced from:
      _TranslateClauseWithTerminator in libespeak-ng.a(translate.c.o)
      _ReadClause in libespeak-ng.a(readclause.c.o)

target_link_libraries(piper_phonemize ucd)
endif()

target_compile_features(piper_phonemize PUBLIC cxx_std_17)

# ---- Declare executable ----