Skip to content

Commit

Permalink
PR408: Migrate from qmake to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
zjeffer committed Dec 27, 2022
1 parent 7f71dae commit 0a5521b
Show file tree
Hide file tree
Showing 7 changed files with 238 additions and 277 deletions.
46 changes: 32 additions & 14 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ jobs:
# - A new build of linuxdeployqt allows us to build on Ubuntu 20.04, without having to use -unsupported-allow-new-glibc.
container: ubuntu:18.04
qt-version-major: 5
qt-version: 5.15.2
build-type: debug

- os: ubuntu-latest
qt-version-major: 5
qt-version: 5.15.2
build-type: debug

- os: ubuntu-22.04
qt-version-major: 6
qt-version: 6.3.2
build-type: debug
steps:
- name: Install git PPA in docker container
Expand All @@ -42,6 +45,12 @@ jobs:
echo 'deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu bionic main' > /etc/apt/sources.list.d/git.list
apt update
- if: ${{ env.ACT }}
name: Hack container for local development
run: |
curl -fsSL https://deb.nodesource.com/setup_16.x | bash
apt-get install -y nodejs
- name: Install other dependencies in docker container
# - sudo: Used by most GitHub actions to install things.
if: matrix.container != ''
Expand All @@ -59,22 +68,25 @@ jobs:
QT_PKGS: ${{ matrix.qt-version-major == '6' && 'qt6-base-private-dev libgl-dev' || 'qtbase5-private-dev' }}
run: |
sudo apt update
sudo apt install -y build-essential qtchooser ${{ env.QT_PKGS }}
sudo apt install -y build-essential qtchooser ${{ env.QT_PKGS }} cmake
- name: Install Qt 6 system dependencies
if: startsWith(matrix.qt-version, '6.')
run: |
sudo apt update
sudo apt install -y libxkbcommon-dev
- name: Setup GCC problem matcher
if: matrix.build-type == 'debug'
uses: ammaraskar/gcc-problem-matcher@0.2.0

- name: Build (${{ matrix.build-type }})
shell: bash
env:
CMAKE_PREFIX_PATH: ${{ matrix.qt-version-major == '6' && env.Qt6_DIR || env.Qt5_DIR }}
run: |
mkdir build
cd build
# Workaround for qtchooser not supporting Qt 6: https://bugs.launchpad.net/ubuntu/+source/qtchooser/+bug/1964763
echo -e '/usr/lib/qt6/bin\n/usr/lib/x86_64-linux-gnu' | sudo tee /usr/lib/x86_64-linux-gnu/qtchooser/qt6.conf
export QT_SELECT=qt${{ matrix.qt-version-major }}
qmake -config ${{ matrix.build-type }} ../src/Notes.pro
make -j$(nproc)
cmake . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DCMAKE_PREFIX_PATH=${{ env.CMAKE_PREFIX_PATH }}
make -j$(nproc) -C build
# Build the AppImage using official Qt releases, downloaded by aqtinstall.
# This is also done for macOS and Windows, just to make sure we use the exact same Qt version across all three OSes.
Expand Down Expand Up @@ -127,6 +139,13 @@ jobs:
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
echo UTC > /etc/timezone
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v1.13
with:
cmake-version: '3.16.x'
- name: Use cmake
run: cmake --version

- name: Checkout code
uses: actions/checkout@v3
with:
Expand All @@ -135,12 +154,12 @@ jobs:
- name: Update version
shell: bash
run: |
sed -i.bak "/^VERSION *=/ s/$/-g${GITHUB_SHA::7}/" src/Notes.pro
sed -i.bak "s/PROJECT_VERSION *[^)]\+/&-g${GITHUB_SHA::7}/" CMakeLists.txt
- name: Setup variables
id: vars
run: |
version=$(grep -m 1 VERSION src/Notes.pro | sed 's/^VERSION *= *//')
version=$(grep -m 1 'PROJECT_VERSION' CMakeLists.txt | sed 's/.*PROJECT_VERSION *//' | sed 's/).*//')
artifact_name="Notes_${version}-x86_64-Qt${{ matrix.qt-version }}"
file_name="$artifact_name${{ matrix.build-type == 'debug' && '-debug.' || '.' }}AppImage"
echo "version=$version" >> $GITHUB_OUTPUT
Expand All @@ -164,10 +183,9 @@ jobs:
- name: Build (${{ matrix.build-type }})
run: |
mkdir build
cd build
qmake -config ${{ matrix.build-type }} ../src/Notes.pro
make -j$(nproc)
cmake . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)
cmake --build build
- name: Setup linuxdeploy
run: |
Expand Down
31 changes: 16 additions & 15 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-11
- os: macos-12
qt-version-major: 5
build-type: debug

- os: macos-11
- os: macos-12
qt-version-major: 6
build-type: debug
steps:
Expand All @@ -27,6 +27,9 @@ jobs:
submodules: recursive

- name: Install Qt ${{ matrix.qt-version-major }} (homebrew)
env:
# TODO: remove once https://github.com/actions/setup-python/issues/577 gets fixed.
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
run: |
brew update
brew install qt@${{ matrix.qt-version-major }}
Expand All @@ -47,10 +50,9 @@ jobs:

- name: Build (${{ matrix.build-type }})
run: |
mkdir build
cd build
qmake -config ${{ matrix.build-type }} ../src/Notes.pro
make -j$(sysctl -n hw.logicalcpu)
export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)
cmake . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DCMAKE_PREFIX_PATH="$(brew --prefix qt@${{ matrix.qt-version-major }})"
cmake --build build
# Build the dmg disk image using the official Qt 5 release downloaded by aqtinstall.
# This is also done for Linux and Windows, just to make sure we use the exact same Qt version across all three OSes.
Expand Down Expand Up @@ -78,12 +80,12 @@ jobs:

- name: Update version
run: |
sed -i.bak "/^VERSION *=/ s/$/-g${GITHUB_SHA::7}/" src/Notes.pro
sed -i.bak "s/PROJECT_VERSION *[^)]\+/&-g${GITHUB_SHA::7}/" CMakeLists.txt
- name: Setup variables
id: vars
run: |
version=$(grep -m 1 VERSION src/Notes.pro | sed 's/^VERSION *= *//')
version=$(grep -m 1 'PROJECT_VERSION' CMakeLists.txt | sed 's/.*PROJECT_VERSION *//' | sed 's/).*//')
artifact_name="Notes_${version}-x86_64-Qt${{ matrix.qt-version }}"
file_name="$artifact_name${{ matrix.build-type == 'debug' && '-debug.' || '.' }}dmg"
echo "version=$version" >> $GITHUB_OUTPUT
Expand All @@ -98,21 +100,20 @@ jobs:

- name: Build (${{ matrix.build-type }})
run: |
mkdir build
cd build
qmake -config ${{ matrix.build-type }} ../src/Notes.pro
make -j$(sysctl -n hw.logicalcpu)
export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)
cmake . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
cmake --build build
- name: Build dmg (${{ matrix.build-type }})
run: |
cd bin
cd build
plutil -insert NSRequiresAquaSystemAppearance -bool true Notes.app/Contents/Info.plist
plutil -insert CFBundleName -string Notes Notes.app/Contents/Info.plist
plutil -replace CFBundleName -string Notes Notes.app/Contents/Info.plist
macdeployqt Notes.app -dmg
mv Notes.dmg '${{ steps.vars.outputs.file_name }}'
- name: Upload dmg artifact (${{ matrix.build-type }})
uses: actions/upload-artifact@v3
with:
name: ${{ steps.vars.outputs.artifact_name }}-${{ runner.os }}-${{ matrix.build-type }}
path: bin/${{ steps.vars.outputs.file_name }}
path: build/${{ steps.vars.outputs.file_name }}
16 changes: 7 additions & 9 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:

- name: Update version
run: |
(Get-Content src\Notes.pro) -Replace '^VERSION *= *(.+)$',"`$0-g$($env:GITHUB_SHA.Substring(0,7))" | Set-Content src\Notes.pro
(Get-Content CMakeLists.txt) -Replace ("PROJECT_VERSION *[^)]+", "`$0-g$($env:GITHUB_SHA.Substring(0,7))") | Set-Content CMakeLists.txt
- name: Setup variables
id: vars
run: |
$version = Select-String -Path src\Notes.pro -Pattern '^VERSION *= *(.+)$' | %{$_.Matches.Groups[1].value}
$version = Select-String -Path CMakeLists.txt -Pattern 'PROJECT_VERSION *([^)]+)' | %{$_.Matches.Groups[1].value}
$artifact_name = "Notes_$version-${{ matrix.arch }}-Qt${{ matrix.qt-version }}"
Write-Output "version=$version" >> $env:GITHUB_OUTPUT
Write-Output "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT
Expand All @@ -64,18 +64,16 @@ jobs:

- name: Build (${{ matrix.build-type }}, ${{ matrix.arch }})
run: |
New-Item build -ItemType Directory
Set-Location build
qmake -config ${{ matrix.build-type }} ..\src\Notes.pro
nmake
cmake . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
cmake --build .
- name: Deploy (${{ matrix.build-type }}, ${{ matrix.arch }})
run: |
windeployqt bin
windeployqt build
- name: Include required runtime libraries (${{ matrix.build-type }}, ${{ matrix.arch }})
run: |
Set-Location bin
Set-Location build
if ('${{ matrix.arch }}' -ieq 'x64') {
$openssl_lib_suffix = '-x64'
Expand Down Expand Up @@ -114,7 +112,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{ steps.vars.outputs.artifact_name }}-${{ runner.os }}-${{ matrix.build-type }}
path: bin
path: build

unified-installer:
name: Unified x64-x86 Installer (Qt 5 only)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bin*
######################
.DS_Store*
.vscode/
.cache/
ehthumbs.db
Thumbs.db
Makefile
Expand Down
Loading

0 comments on commit 0a5521b

Please sign in to comment.