Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
149 changes: 149 additions & 0 deletions .github/workflows/build-dmg-qt6-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Build macOS DMG (Qt6, Universal)

on:
push:
tags:
- "*"
workflow_dispatch:
inputs:
branch:
description: 'Checkout branch'
required: false
default: 'dev'
tag:
description: 'Checkout tag'
required: false

permissions:
contents: write

jobs:
build-omodsim:
name: Build OpenModSim macOS DMG version '${{ github.event.inputs.tag || github.event.inputs.branch || github.ref_name }}' with Qt6
runs-on: macos-latest

env:
QT_VERSION: "6.9.3"
QT_HOST: "mac"
QT_TARGET: "desktop"
QT_ARCH: "clang_64"
QT_INSTALL_DIR: "${{ github.workspace }}/Qt"
CMAKE_GENERATOR: "Ninja"
BUILD_TYPE: "Release"
DMG_PACKAGE_NAME: "qt6-omodsim"

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.event.inputs.branch || github.ref_name }}

- name: Determine ref_type and ref_name
run: |
if [ "${{ github.ref_type }}" = "tag" ] || [ -n "${{ github.event.inputs.tag }}" ]; then
REF_TYPE="tags"
if [ -n "${{ github.event.inputs.tag }}" ]; then
REF_NAME="${{ github.event.inputs.tag }}"
else
REF_NAME="${{ github.ref_name }}"
fi
else
REF_TYPE="heads"
REF_NAME="${{ github.ref_name }}"
fi
echo "REF_TYPE=$REF_TYPE" >> $GITHUB_ENV
echo "REF_NAME=$REF_NAME" >> $GITHUB_ENV

- name: Extract version from CMakeLists.txt
run: |
FULL_VERSION=$(grep -oE 'VERSION\s+[0-9]+\.[0-9]+\.[0-9]+' src/CMakeLists.txt | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')

if [ "${GITHUB_REF_NAME}" = "dev" ] || [ "${{ github.event.inputs.branch }}" = "dev" ]; then
MAJOR_MINOR=$(echo "$FULL_VERSION" | cut -d. -f1,2)
APP_VERSION="${MAJOR_MINOR}~dev"
else
APP_VERSION="$FULL_VERSION"
fi

echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
echo "Extracted version: $APP_VERSION"

- name: Install dependencies
run: |
brew install ninja cmake

- name: Install Python (for aqtinstall)
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install aqtinstall
run: python -m pip install aqtinstall

- name: Download Qt
run: |
mkdir -p ${{ env.QT_INSTALL_DIR }}
aqt install-qt \
${{ env.QT_HOST }} \
${{ env.QT_TARGET }} \
${{ env.QT_VERSION }} \
${{ env.QT_ARCH }} \
-m qt5compat qtpdf qtserialport qtserialbus \
-O ${{ env.QT_INSTALL_DIR }}

- name: Add Qt to PATH
run: echo "${{ env.QT_INSTALL_DIR }}/${{ env.QT_VERSION }}/macos/bin" >> $GITHUB_PATH

- name: Set BUILD_DIR
run: echo "BUILD_DIR=build-omodsim-Qt_${{ env.QT_VERSION }}_clang_64-${{ env.BUILD_TYPE }}" >> $GITHUB_ENV

- name: Configure project
run: |
cmake src -B ${{ env.BUILD_DIR }} \
-G "${{ env.CMAKE_GENERATOR }}" \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_PREFIX_PATH=${{ env.QT_INSTALL_DIR }}/${{ env.QT_VERSION }}/macos \
-DUSE_QT6=ON

- name: Build
run: cmake --build ${{ env.BUILD_DIR }} --config ${{ env.BUILD_TYPE }} --parallel

- name: Deploy Qt dependencies using macdeployqt
run: |
"${{ env.QT_INSTALL_DIR }}/${{ env.QT_VERSION }}/macos/bin/macdeployqt" \
"${{ env.BUILD_DIR }}/omodsim.app" \
-always-overwrite

- name: Copy docs into app bundle
run: |
mkdir -p "${{ env.BUILD_DIR }}/omodsim.app/Contents/Resources/docs"
cp -R "${{ env.BUILD_DIR }}/docs/"* "${{ env.BUILD_DIR }}/omodsim.app/Contents/Resources/docs/"

- name: Create DMG
run: |
DMG_NAME="${{ env.DMG_PACKAGE_NAME }}_${{ env.APP_VERSION }}_macos.dmg"
echo "DMG_NAME=$DMG_NAME" >> $GITHUB_ENV

hdiutil create -volname "Open ModSim ${{ env.APP_VERSION }}" \
-srcfolder "${{ env.BUILD_DIR }}/omodsim.app" \
-ov -format UDZO \
"$DMG_NAME"

- name: Upload DMG
uses: actions/upload-artifact@v4
if: success()
with:
name: ${{ env.DMG_NAME }}
path: ${{ env.DMG_NAME }}

- name: Create or update GitHub Release and upload DMG
if: success() && github.event_name == 'push' && github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: ${{ github.ref_name }}
name: Open ModSim ${{ env.APP_VERSION }}
files: |
${{ env.DMG_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Script.onInit(init);
```

# Building
Building is available via cmake (with installed Qt version 5.15 and above) or Qt Creator. Supports both OS Microsoft Windows and Linux.
Building is available via cmake (with installed Qt version 5.15 and above) or Qt Creator. Supports Microsoft Windows, Linux and macOS.

## Microsoft Windows Building

Expand Down Expand Up @@ -176,10 +176,41 @@ cd OpenModSim
If you need to specify Qt framework major version (5 or 6), you can do it in the parameters
- `./build.sh -qt5` or `./build.sh -qt6`

## macOS Building

The minimum supported version of macOS for building OpenModSim from sources is macOS 11 (Big Sur).

1. Install [Homebrew](https://brew.sh) if not already installed
2. Install required dependencies:
```bash
brew install qt@6 cmake ninja
```
3. Clone OpenModSim sources from github repository:
```bash
git clone https://github.com/sanny32/OpenModSim.git
```
4. Go to OpenModSim folder:
```bash
cd OpenModSim
```
5. Run the build script:
```bash
./build-macos.sh
```

If you need to specify Qt framework major version (5 or 6), you can do it in the parameters
- `./build-macos.sh -qt5` or `./build-macos.sh -qt6`

The build script generates a macOS application bundle (`omodsim.app`). To run the application:
```bash
open build-omodsim-Qt_*/omodsim.app
```

# About supported operating systems

The following minimum operating system versions are supported for OpenModSim:

- <img src="docs/icons/logo_apple.svg" width="16" height="16" /> **macOS 11 (Big Sur)** and later (Intel and Apple Silicon)
- <img src="docs/icons/logo_windows7.svg" width="16" height="16" /> **Microsoft Windows 7**
- <img src="docs/icons/logo_debian.svg" width="16" height="16" /> **Debian Linux 11**
- <img src="docs/icons/logo_ubuntu.svg" width="16" height="16" /> **Ubuntu Linux 22.04**
Expand Down
165 changes: 165 additions & 0 deletions build-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#!/usr/bin/env bash
set -e

echo "=================================="
echo " OpenModSim build script (macOS) "
echo "=================================="
echo ""

# ==========================
# Check macOS
# ==========================
if [[ "$(uname)" != "Darwin" ]]; then
echo "Error: This script is for macOS only."
exit 1
fi

# ==========================
# Parse script arguments
# ==========================
QT_CHOICE=""
for arg in "$@"; do
case "$arg" in
-qt5|qt5)
QT_CHOICE="qt5"
;;
-qt6|qt6)
QT_CHOICE="qt6"
;;
*)
;;
esac
done

if [ -z "$QT_CHOICE" ]; then
QT_CHOICE="qt6"
fi

# ==========================
# Check Xcode Command Line Tools
# ==========================
echo "Checking for Xcode Command Line Tools..."
if ! xcode-select -p >/dev/null 2>&1; then
echo "Error: Xcode Command Line Tools not found."
echo "Install with: xcode-select --install"
exit 1
fi
echo " Found: $(xcode-select -p)"

# ==========================
# Check Homebrew
# ==========================
echo "Checking for Homebrew..."
if ! command -v brew >/dev/null 2>&1; then
echo "Error: Homebrew not found."
echo "Install from: https://brew.sh"
exit 1
fi
echo " Found: $(brew --prefix)"

# ==========================
# Check CMake and Ninja
# ==========================
echo "Checking for CMake..."
if ! command -v cmake >/dev/null 2>&1; then
echo "CMake not found. Installing..."
brew install cmake
fi
echo " Found: $(cmake --version | head -1)"

echo "Checking for Ninja..."
if ! command -v ninja >/dev/null 2>&1; then
echo "Ninja not found. Installing..."
brew install ninja
fi
echo " Found: ninja $(ninja --version)"

# ==========================
# Check Qt
# ==========================
echo "Checking for Qt..."

QT_PREFIX=""
QT_VERSION=""

if [ "$QT_CHOICE" = "qt6" ]; then
QT_PREFIX="$(brew --prefix qt@6 2>/dev/null || brew --prefix qt 2>/dev/null || true)"
if [ -z "$QT_PREFIX" ] || [ ! -d "$QT_PREFIX" ]; then
echo "Qt6 not found. Installing..."
brew install qt@6
QT_PREFIX="$(brew --prefix qt@6 2>/dev/null || brew --prefix qt 2>/dev/null)"
fi
QT_VERSION=$("${QT_PREFIX}/bin/qmake" -query QT_VERSION 2>/dev/null || true)
elif [ "$QT_CHOICE" = "qt5" ]; then
QT_PREFIX="$(brew --prefix qt@5 2>/dev/null || true)"
if [ -z "$QT_PREFIX" ] || [ ! -d "$QT_PREFIX" ]; then
echo "Qt5 not found. Installing..."
brew install qt@5
QT_PREFIX="$(brew --prefix qt@5 2>/dev/null)"
fi
QT_VERSION=$("${QT_PREFIX}/bin/qmake" -query QT_VERSION 2>/dev/null || true)
fi

if [ -z "$QT_VERSION" ]; then
echo "Error: Cannot detect Qt version from ${QT_PREFIX}"
exit 1
fi

echo " Found: Qt ${QT_VERSION} at ${QT_PREFIX}"

# ==========================
# Check minimum Qt version
# ==========================
MIN_QT_VERSION="5.15.0"
verlte() {
[ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | head -n1)" ]
}
verlt() {
[ "$1" != "$2" ] && verlte "$1" "$2"
}

if verlt "$QT_VERSION" "$MIN_QT_VERSION"; then
echo "Error: Qt >= $MIN_QT_VERSION is required, but found $QT_VERSION"
exit 1
fi

# ==========================
# Setup cmake options
# ==========================
CMAKE_QT_OPTION="-DUSE_QT5=OFF -DUSE_QT6=OFF"
if [ "$QT_CHOICE" = "qt5" ]; then
CMAKE_QT_OPTION="-DUSE_QT5=ON"
elif [ "$QT_CHOICE" = "qt6" ]; then
CMAKE_QT_OPTION="-DUSE_QT6=ON"
fi

# ==========================
# Detect architecture
# ==========================
ARCH=$(uname -m)
BUILD_TYPE=Release

# ==========================
# Build project
# ==========================
SANITIZED_QT_VERSION=$(echo "$QT_VERSION" | tr '.' '_')
BUILD_DIR="build-omodsim-Qt_${SANITIZED_QT_VERSION}_clang_${ARCH}-${BUILD_TYPE}"
echo ""
echo "Starting build in: ${BUILD_DIR}"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

cmake ../src -GNinja \
-DCMAKE_PREFIX_PATH="${QT_PREFIX}" \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
${CMAKE_QT_OPTION}

ninja

echo ""
echo "Build finished successfully!"
echo "Application bundle: ${BUILD_DIR}/omodsim.app"
echo ""
echo "To run:"
echo " open ${BUILD_DIR}/omodsim.app"
echo ""
3 changes: 3 additions & 0 deletions docs/icons/logo_apple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading