While not recommended over native builds or GitHub Actions, you can cross-compile from Ubuntu.
1. Install Toolchains
Install MinGW for Windows and Clang/osxcross for OS X:
# Windows toolchain
sudo apt-get install -y --no-install-recommends mingw-w64 g++-mingw-w64
# OS X toolchain
apt-get install -y --no-install-recommends clang curl
# (Follow the detailed osxcross build steps in the source to set up /usr/osxcross)
2. Build for Windows
Use the provided MinGW toolchain file:
cmake -S ./src -B ./build-win -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=src/Toolchain-mingw-w64-x86-64.cmake
cmake --build ./build-win
3. Build for OS X
Use the provided osxcross toolchain file:
cmake -S ./src -B ./build-mac -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=src/Toolchain-ubuntu-osxcross-10.11.cmake -DCMAKE_FIND_ROOT_PATH=/usr/osxcross/SDK/MacOSX10.11.sdk/
cmake --build ./build-mac
# Example: Building for Windows from Ubuntu
cmake -S ./src -B ./build-win -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=src/Toolchain-mingw-w64-x86-64.cmake
cmake --build ./build-win