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

Feat/build with cmake #32

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

thewh1teagle
Copy link

@thewh1teagle thewh1teagle commented Jan 24, 2025

Add CMake configuration and CI
It's best to squash the commits when merging (in the merge button in Github UI there's option)

CI (Success): https://github.com/thewh1teagle/pcaudiolib/actions/runs/12961423582

Build successfully on macOS (arm/amd64), Linux(arm,amd64), Windows (amd64)
Backends: Alsa, PulseAudio, CoreAudio, OSS
Linking with espeak: Linux (dynamic), macOS (static,dynamic), Windows (static,dynamic)

Related:

Build instructions with espeak-ng for all platforms

macOS

# Build shared pcaudiolib
git clone https://github.com/thewh1teagle/pcaudiolib -b feat/build-with-cmake
cd pcaudiolib
cmake -B build -DCMAKE_INSTALL_PREFIX=_install -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cmake --install build
ls -R _install
export PCAUDIO_PATH=$(pwd)/_install

# Dynamic link pcaudiolib
git clone https://github.com/espeak-ng/espeak-ng -b 1.52.0
cd espeak-ng
cmake -B build -DCMAKE_INSTALL_PREFIX=_install -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PCAUDIO_PATH
cmake --build build --config Release
cmake --install build
ls -R _install
cp $PCAUDIO_PATH/lib/*.dylib _install/lib     
./_install/bin/espeak-ng hello # speaking works

Windows

git clone https://github.com/thewh1teagle/pcaudiolib -b feat/build-with-cmake
cd pcaudiolib
cmake -B build -DCMAKE_INSTALL_PREFIX=_install -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
cmake --build build --config Release
cmake --install build
ls -R _install
$env:PCAUDIO_PATH="$pwd\_install"

# Static link pcaudiolib
git clone https://github.com/espeak-ng/espeak-ng -b 1.52.0
cd espeak-ng
ls $env:PCAUDIO_PATH
cmake -B build -DCMAKE_INSTALL_PREFIX=_install -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$env:PCAUDIO_PATH" # Or absolute path
cmake --build build --config Release
cmake --install build
./_install/bin/espeak-ng hello # speaking works

Linux

# Build shared pcaudiolib
sudo apt-get install libpulse-dev -y
git clone https://github.com/thewh1teagle/pcaudiolib -b feat/build-with-cmake
cd pcaudiolib
rm -rf build _install
cmake -B build -DCMAKE_INSTALL_PREFIX=_install -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
cmake --install build
ldd _install/lib/*.so
ls -R _install
export PCAUDIO_PATH=$(pwd)/_install

# Dynamic link pcaudiolib
git clone https://github.com/espeak-ng/espeak-ng -b 1.52.0
cd espeak-ng
rm -rf build _install
cmake -B build -DCMAKE_INSTALL_PREFIX=_install -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$PCAUDIO_PATH"
cmake --build build --config Release
cmake --install build
ls -R _install
cp $PCAUDIO_PATH/lib/*.so _install/lib     
./_install/bin/espeak-ng hello # speaking works

Notes:

To build espeak-ng on macOS and link it statically, these changes are required in espeak-ng near each add_executable call:

target_link_libraries(espeak-ng-bin PRIVATE "-framework CoreAudio" "-framework AudioToolbox" "-framework AudioUnit") # src/CMakeLists.txt
target_link_libraries(test_${_test_name} PRIVATE "-framework CoreAudio" "-framework AudioToolbox" "-framework AudioUnit") # ...

Optional improvements in espeak:

thewh1teagle and others added 30 commits January 24, 2025 00:12
GitHub Action to build the code using cmake
Avoid cross compiling when GitHub Actions provides the native platform.
Build x86 on Intel and build Arm on Arm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants