https://github.com/rhasspy/piper-phonemize/pull/31

--- CMakeLists.txt.orig	2023-11-14 17:54:34 UTC
+++ CMakeLists.txt
@@ -17,7 +17,7 @@ elseif(NOT APPLE)
 
 elseif(NOT APPLE)
     # Linux flags
-    string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'")
+    string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra")
     string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
 endif()
 
@@ -34,100 +34,13 @@ set_target_properties(piper_phonemize PROPERTIES
     SOVERSION ${PROJECT_VERSION_MAJOR}
 )
 
-# ---- onnxruntime ---
-
-# Look for onnxruntime files in <root>/lib
-if(NOT DEFINED ONNXRUNTIME_DIR)
-    if(NOT DEFINED ONNXRUNTIME_VERSION)
-        set(ONNXRUNTIME_VERSION "1.14.1")
-    endif()
-
-    if(WIN32)
-        # Windows x86-64
-        set(ONNXRUNTIME_PREFIX "onnxruntime-win-x64-${ONNXRUNTIME_VERSION}")
-        set(ONNXRUNTIME_EXT "zip")
-    elseif (APPLE)
-        if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
-            # MacOS x86-64
-            set(ONNXRUNTIME_PREFIX "onnxruntime-osx-x86_64-${ONNXRUNTIME_VERSION}")
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
-            # MacOS Apple Silicon
-            set(ONNXRUNTIME_PREFIX "onnxruntime-osx-arm64-${ONNXRUNTIME_VERSION}")
-        else()
-            message(FATAL_ERROR "Unsupported architecture for onnxruntime")
-        endif()
-
-        set(ONNXRUNTIME_EXT "tgz")
-    else()
-        if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
-            # Linux x86-64
-            set(ONNXRUNTIME_PREFIX "onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}")
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
-            # Linux ARM 64-bit
-            set(ONNXRUNTIME_PREFIX "onnxruntime-linux-aarch64-${ONNXRUNTIME_VERSION}")
-        elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
-            # Linux ARM 32-bit
-            set(ONNXRUNTIME_PREFIX "onnxruntime-linux-arm32-${ONNXRUNTIME_VERSION}")
-            set(ONNXRUNTIME_URL "https://github.com/synesthesiam/prebuilt-apps/releases/download/v1.0/onnxruntime-linux-arm32-${ONNXRUNTIME_VERSION}.tgz")
-        else()
-            message(FATAL_ERROR "Unsupported architecture for onnxruntime")
-        endif()
-
-        set(ONNXRUNTIME_EXT "tgz")
-    endif()
-
-    if(NOT DEFINED ONNXRUNTIME_URL)
-        set(ONNXRUNTIME_URL "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_PREFIX}.${ONNXRUNTIME_EXT}")
-    endif()
-
-    set(ONNXRUNTIME_FILENAME "${ONNXRUNTIME_PREFIX}.${ONNXRUNTIME_EXT}")
-    set(ONNXRUNTIME_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/${ONNXRUNTIME_PREFIX}")
-
-    if(NOT EXISTS "${ONNXRUNTIME_DIR}")
-        if(NOT EXISTS "download/${ONNXRUNTIME_FILENAME}")
-            # Download onnxruntime release
-            message("Downloading ${ONNXRUNTIME_URL}")
-            file(DOWNLOAD "${ONNXRUNTIME_URL}" "download/${ONNXRUNTIME_FILENAME}")
-        endif()
-
-        # Extract .zip or .tgz to a directory like lib/onnxruntime-linux-x64-1.14.1/
-        file(ARCHIVE_EXTRACT INPUT "download/${ONNXRUNTIME_FILENAME}" DESTINATION "${CMAKE_CURRENT_LIST_DIR}/lib")
-    endif()
-endif()
-
-# ---- espeak-ng ---
-
-if(NOT DEFINED ESPEAK_NG_DIR)
-    set(ESPEAK_NG_DIR "${CMAKE_CURRENT_BINARY_DIR}/ei")
-
-    include(ExternalProject)
-    ExternalProject_Add(
-        espeak_ng_external
-        PREFIX "${CMAKE_CURRENT_BINARY_DIR}/e"
-        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 -DUSE_MBROLA:BOOL=OFF
-        CMAKE_ARGS -DUSE_LIBSONIC:BOOL=OFF
-        CMAKE_ARGS -DUSE_LIBPCAUDIO:BOOL=OFF
-        CMAKE_ARGS -DUSE_KLATT:BOOL=OFF
-        CMAKE_ARGS -DUSE_SPEECHPLAYER:BOOL=OFF
-        CMAKE_ARGS -DEXTRA_cmn:BOOL=ON
-        CMAKE_ARGS -DEXTRA_ru:BOOL=ON
-        CMAKE_ARGS -DCMAKE_C_FLAGS="-D_FILE_OFFSET_BITS=64"
-    )
-    add_dependencies(piper_phonemize espeak_ng_external)
-endif()
-
-
 # ---- Declare library ----
 
 target_include_directories(
     piper_phonemize PUBLIC
     "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>"
     ${ESPEAK_NG_DIR}/include
-    ${ONNXRUNTIME_DIR}/include
+    ${ONNXRUNTIME_DIR}/include/onnxruntime
 )
 
 target_link_directories(
@@ -220,16 +133,3 @@ install(
 install(
     FILES ${CMAKE_SOURCE_DIR}/etc/libtashkeel_model.ort
     TYPE DATA)
-
-# Dependencies
-install(
-    DIRECTORY ${ESPEAK_NG_DIR}/
-    DESTINATION ${CMAKE_INSTALL_PREFIX})
-
-install(
-    DIRECTORY ${ONNXRUNTIME_DIR}/include/
-    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-
-install(
-    DIRECTORY ${ONNXRUNTIME_DIR}/lib/
-    DESTINATION ${CMAKE_INSTALL_LIBDIR})
