Skip to content

Commit

Permalink
Add support for CMake (buildsystem generator) (Chatterino#2468)
Browse files Browse the repository at this point in the history
Co-authored-by: Edgar <Edgar@AnotherFoxGuy.com>
  • Loading branch information
pajlada and AnotherFoxGuy authored Mar 28, 2021
1 parent 093a088 commit e00938d
Show file tree
Hide file tree
Showing 28 changed files with 1,340 additions and 93 deletions.
5 changes: 5 additions & 0 deletions .CI/CreateDMG.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/sh

if [ -d bin/chatterino.app ] && [ ! -d chatterino.app ]; then
>&2 echo "Moving bin/chatterino.app down one directory"
mv bin/chatterino.app chatterino.app
fi

echo "Running MACDEPLOYQT"
$Qt5_DIR/bin/macdeployqt chatterino.app
echo "Creating python3 virtual environment"
Expand Down
138 changes: 119 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,30 @@ jobs:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
qt-version: [5.15.2, 5.12.10]
build-system: [qmake, cmake]
exclude:
- os: windows-latest
qt-version: 5.12.10
build-system: cmake
include:
- os: windows-2016
qt-version: 5.12.10
build-system: cmake
fail-fast: false

steps:
- name: Set environment variables for windows-latest
if: matrix.os == 'windows-latest'
run: |
echo "vs_version=2019" >> $GITHUB_ENV
shell: bash

- name: Set environment variables for windows-2016
if: matrix.os == 'windows-2016'
run: |
echo "vs_version=2017" >> $GITHUB_ENV
shell: bash

- uses: actions/checkout@v2.3.4
with:
submodules: true
Expand All @@ -42,18 +63,12 @@ jobs:
version: ${{ matrix.qt-version }}

# WINDOWS
- name: Cache conan
if: startsWith(matrix.os, 'windows')
uses: actions/cache@v2.1.4
with:
key: ${{ runner.os }}-conan-root-${{ hashFiles('**/conanfile.txt') }}
path: ~/.conan

- name: Cache conan packages
if: startsWith(matrix.os, 'windows')
uses: actions/cache@v2.1.4
with:
key: ${{ runner.os }}-conan-pkg-${{ hashFiles('**/conanfile.txt') }}
key: ${{ runner.os }}-conan-${{ hashFiles('**/conanfile.txt') }}-20210307
path: C:/.conan/

- name: Install dependencies (Windows)
Expand All @@ -65,9 +80,9 @@ jobs:
shell: cmd

- name: Build (Windows)
if: startsWith(matrix.os, 'windows')
if: startsWith(matrix.os, 'windows') && matrix.build-system == 'qmake'
run: |
call "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
call "%programfiles(x86)%\Microsoft Visual Studio\%vs_version%\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
mkdir build
cd build
"C:\Program Files\Conan\conan\conan.exe" install ..
Expand All @@ -80,17 +95,33 @@ jobs:
7z a chatterino-windows-x86-64.zip Chatterino2/
shell: cmd

- name: Build with CMake (Windows)
if: startsWith(matrix.os, 'windows') && matrix.build-system == 'cmake'
run: |
call "%programfiles(x86)%\Microsoft Visual Studio\%vs_version%\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
mkdir build
cd build
"C:\Program Files\Conan\conan\conan.exe" install ..
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DUSE_CONAN=ON ..
set cl=/MP
nmake /S /NOLOGO
windeployqt bin/chatterino.exe --release --no-compiler-runtime --no-translations --no-opengl-sw --dir Chatterino2/
cp bin/chatterino.exe Chatterino2/
echo nightly > Chatterino2/modes
7z a chatterino-windows-x86-64.zip Chatterino2/
shell: cmd

- name: Ensure build succeeded (Windows)
if: startsWith(matrix.os, 'windows')
run: |
cd build
ls release/chatterino.exe
ls Chatterino2/chatterino.exe
- name: Upload artifact (Windows)
if: startsWith(matrix.os, 'windows')
uses: actions/upload-artifact@v2.2.2
with:
name: chatterino-windows-x86-64-${{ matrix.qt-version }}.zip
name: chatterino-windows-x86-64-${{ matrix.qt-version }}-${{ matrix.build-system }}.zip
path: build/chatterino-windows-x86-64.zip

# LINUX
Expand All @@ -99,6 +130,9 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -y install \
cmake \
virtualenv \
rapidjson-dev \
libssl-dev \
libboost-dev \
libxcb-randr0-dev \
Expand All @@ -116,14 +150,23 @@ jobs:
libxcb-xinerama0
- name: Build (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
if: startsWith(matrix.os, 'ubuntu') && matrix.build-system == 'qmake'
run: |
mkdir build
cd build
qmake PREFIX=/usr ..
make -j8
shell: bash

- name: Build with CMake (Ubuntu)
if: startsWith(matrix.os, 'ubuntu') && matrix.build-system == 'cmake'
run: |
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=appdir/usr/ -DCMAKE_BUILD_TYPE=Release -DPAJLADA_SETTINGS_USE_BOOST_FILESYSTEM=On ..
make -j8
shell: bash

- name: Package (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
Expand All @@ -135,25 +178,37 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
uses: actions/upload-artifact@v2.2.2
with:
name: Chatterino-x86_64-${{ matrix.qt-version }}.AppImage
name: Chatterino-x86_64-${{ matrix.qt-version }}-${{ matrix.build-system }}.AppImage
path: build/Chatterino-x86_64.AppImage

# MACOS
- name: Install dependencies (MacOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install boost openssl rapidjson p7zip create-dmg
brew install boost openssl rapidjson p7zip create-dmg cmake tree
shell: bash

- name: Build (MacOS)
if: startsWith(matrix.os, 'macos')
if: startsWith(matrix.os, 'macos') && matrix.build-system == 'qmake'
run: |
mkdir build
cd build
$Qt5_DIR/bin/qmake .. DEFINES+=$dateOfBuild
make -j8
shell: bash

- name: Build with CMake (MacOS)
if: startsWith(matrix.os, 'macos') && matrix.build-system == 'cmake'
run: |
mkdir build
cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl \
..
make -j8
shell: bash

- name: Package (MacOS)
if: startsWith(matrix.os, 'macos')
run: |
Expand All @@ -168,7 +223,7 @@ jobs:
if: startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v2.2.2
with:
name: chatterino-osx-${{ matrix.qt-version }}.dmg
name: chatterino-osx-${{ matrix.qt-version }}-${{ matrix.build-system }}.dmg
path: build/chatterino-osx.dmg

create-release:
Expand All @@ -192,19 +247,34 @@ jobs:

- uses: actions/download-artifact@v2.0.8
with:
name: chatterino-windows-x86-64-5.15.2.zip
name: chatterino-windows-x86-64-5.15.2-qmake.zip
path: windows/

- uses: actions/download-artifact@v2.0.8
with:
name: Chatterino-x86_64-5.15.2.AppImage
name: chatterino-windows-x86-64-5.15.2-cmake.zip
path: windows-cmake/

- uses: actions/download-artifact@v2.0.8
with:
name: Chatterino-x86_64-5.15.2-qmake.AppImage
path: linux/

- uses: actions/download-artifact@v2.0.8
with:
name: chatterino-osx-5.15.2.dmg
name: Chatterino-x86_64-5.15.2-cmake.AppImage
path: linux-cmake/

- uses: actions/download-artifact@v2.0.8
with:
name: chatterino-osx-5.15.2-qmake.dmg
path: macos/

- uses: actions/download-artifact@v2.0.8
with:
name: chatterino-osx-5.15.2-cmake.dmg
path: macos-cmake/

# TODO: Extract dmg and appimage

# - name: Read upload URL into output
Expand All @@ -222,6 +292,16 @@ jobs:
asset_name: chatterino-windows-x86-64.zip
asset_content_type: application/zip

- name: Upload release asset (Windows) CMake
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows-cmake/chatterino-windows-x86-64.zip
asset_name: test-cmake-chatterino-windows-x86-64.zip
asset_content_type: application/zip

- name: Upload release asset (Ubuntu)
uses: actions/upload-release-asset@v1.0.2
env:
Expand All @@ -232,6 +312,16 @@ jobs:
asset_name: Chatterino-x86_64.AppImage
asset_content_type: application/x-executable

- name: Upload release asset (Ubuntu) CMake
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux-cmake/Chatterino-x86_64.AppImage
asset_name: test-cmake-Chatterino-x86_64.AppImage
asset_content_type: application/x-executable

- name: Upload release asset (MacOS)
uses: actions/upload-release-asset@v1.0.2
env:
Expand All @@ -241,3 +331,13 @@ jobs:
asset_path: ./macos/chatterino-osx.dmg
asset_name: chatterino-osx.dmg
asset_content_type: application/x-bzip2

- name: Upload release asset (MacOS) CMake
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./macos-cmake/chatterino-osx.dmg
asset_name: test-cmake-chatterino-osx.dmg
asset_content_type: application/x-bzip2
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ jobs:
- name: Build (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
cmake -DBUILD_TESTS=On -DCMAKE_BUILD_TYPE=Release ..
cmake -DBUILD_TESTS=On -DBUILD_APP=OFF ..
cmake --build . --config Release
working-directory: build-test
shell: bash

- name: Test (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
./chatterino-test --platform minimal
./bin/chatterino-test --platform minimal
working-directory: build-test
shell: bash
27 changes: 26 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ qrc_*.cpp
ui_*.h
Makefile*
*build-*/
/build/
[bB]uild
/_build/

# QtCreator

Expand Down Expand Up @@ -78,3 +79,27 @@ Thumbs.db

# Other editors/IDEs
.vscode
.idea
dependencies

### CMake ###
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json

### CMake Patch ###
# External projects
*-prefix/
Stamp
tmp
Source
Dependencies_*
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "lib/libcommuni"]
path = lib/libcommuni
url = https://github.com/communi/libcommuni
url = https://github.com/Chatterino/libcommuni
[submodule "lib/qBreakpad"]
path = lib/qBreakpad
url = https://github.com/jiakuan/qBreakpad.git
Expand Down
Loading

0 comments on commit e00938d

Please sign in to comment.