diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 2c2d746..a09a613 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -31,10 +31,13 @@ set(ONNXRUNTIME_ROOTDIR ${CMAKE_CURRENT_LIST_DIR}/../../lib/${CMAKE_HOST_SYSTEM_ target_link_libraries(piper onnxruntime pthread - -static-libgcc -static-libstdc++ ${ESPEAK_NG_LIBRARIES} ${PCAUDIO_LIBRARIES}) +if(NOT APPLE) + target_link_libraries(-static-libgcc -static-libstdc++) +endif() + target_link_directories(piper PUBLIC ${ESPEAK_NG_LIBRARY_DIRS} ${ONNXRUNTIME_ROOTDIR}/lib) diff --git a/src/cpp/main.cpp b/src/cpp/main.cpp index f827d47..bab64e9 100644 --- a/src/cpp/main.cpp +++ b/src/cpp/main.cpp @@ -21,6 +21,10 @@ #include #endif +#ifdef __APPLE__ +#include +#endif + #include "piper.hpp" using namespace std; @@ -66,8 +70,17 @@ int main(int argc, char *argv[]) { GetModuleFileNameW(nullptr, moduleFileName, std::size(moduleFileName)); return filesystem::path(moduleFileName); }(); +#else +#ifdef __APPLE__ + auto exePath = []() { + char moduleFileName[PATH_MAX] = { 0 }; + uint32_t moduleFileNameSize = std::size(moduleFileName); + _NSGetExecutablePath(moduleFileName, &moduleFileNameSize); + return filesystem::path(moduleFileName); + }(); #else auto exePath = filesystem::canonical("/proc/self/exe"); +#endif #endif piper::initialize(exePath.parent_path());