Skip to content

Commit

Permalink
Merge pull request #33 from StephanKa/feature/add-qt
Browse files Browse the repository at this point in the history
Added example for QT and conan
  • Loading branch information
StephanKa authored Mar 4, 2024
2 parents 276ec16 + 2b2135f commit 8cf8a67
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 13 deletions.
117 changes: 109 additions & 8 deletions .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ jobs:
compiler: [ {name: 'GCC 10', preset: gcc-10, pkgs: 'gcc-10 g++-10 lib32gcc-10-dev gcc-multilib'},
{name: 'GCC 11', preset: gcc-11, pkgs: 'gcc-11 g++-11 lib32gcc-11-dev gcc-multilib'},
{name: 'GCC 12', preset: gcc-12, pkgs: 'gcc-12 g++-12 lib32gcc-12-dev gcc-multilib'},
{name: 'Clang 12', preset: clang-12, pkgs: 'clang-12 llvm-12'},
{name: 'Clang 13', preset: clang-13, pkgs: 'clang-13 llvm-13'},
{name: 'Clang 14', preset: clang-14, pkgs: 'clang-14 llvm-14'},
{name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15'}
]
cxx: [17, 20]
Expand Down Expand Up @@ -86,6 +83,60 @@ jobs:
shell: bash
run: ctest --preset test-unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}

# because of an bug in github actions: https://github.com/actions/runner-images/issues/8659
# we use clang 12, clang 13, clang 14 only in C++17 mode
linux-clang-smaller-15:
name: ${{ matrix.os }}, ${{ matrix.compiler.name }}, C++${{ matrix.cxx }}, ${{ matrix.buildtype }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix entry fails.
matrix:
os: [ubuntu-22.04]
buildtype: [debug]
compiler: [ {name: 'Clang 12', preset: clang-12, pkgs: 'clang-12 llvm-12'},
{name: 'Clang 13', preset: clang-13, pkgs: 'clang-13 llvm-13'},
{name: 'Clang 14', preset: clang-14, pkgs: 'clang-14 llvm-14'}
]
cxx: [17]

steps:
- uses: actions/checkout@v3

- name: Cache
uses: actions/cache@v3
env:
cache-name: cache-conan-modules
with:
path: |
${{ env.CONAN_USER_HOME }}
~/.cache/pip
key: ${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('cmake/Conan.cmake') }}

- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools conan
source ~/.profile
- name: Install dependencies
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt update
sudo apt install ninja-build ${{ matrix.compiler.pkgs }}
shell: bash

- name: Configure via CMake
shell: bash
run: cmake --preset unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }} -DCXX_STANDARD=${{ matrix.cxx }}

- name: Build
shell: bash
run: cmake --build --preset build-unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}

- name: Test
shell: bash
run: ctest --preset test-unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}

linux-static_analysis:
name: Static Analysis, ${{ matrix.os }}, ${{ matrix.compiler.name }}, ${{ matrix.buildtype }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -200,11 +251,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
buildtype: [debug]
compiler: [ {name: 'Clang 12', preset: clang-12, pkgs: 'clang-12 llvm-12'},
{name: 'Clang 13', preset: clang-13, pkgs: 'clang-13 llvm-13'},
{name: 'Clang 14', preset: clang-14, pkgs: 'clang-14 llvm-14'},
{name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15'}
]
compiler: [ {name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15'} ]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -239,3 +286,57 @@ jobs:
- name: Build
shell: bash
run: cmake --build --preset build-unixlike-${{ matrix.compiler.preset }}-${{ matrix.buildtype }}

linux-qt:
name: ${{ matrix.os }}, QT ${{ matrix.compiler.name }}, C++${{ matrix.cxx }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix entry fails.
matrix:
os: [ubuntu-22.04]
compiler: [ {name: 'Clang 15', preset: clang-15, pkgs: 'clang-15 llvm-15'} ]
cxx: [20]

steps:
- uses: actions/checkout@v3

- name: Cache
uses: actions/cache@v3
env:
cache-name: cache-conan-modules
with:
path: |
${{ env.CONAN_USER_HOME }}
~/.cache/pip
key: ${{ runner.os }}-${{ env.BUILD_TYPE }}-${{ hashFiles('CMakeLists.txt') }}-${{ hashFiles('cmake/Conan.cmake') }}

- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools conan
source ~/.profile
- name: Install dependencies
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt update
sudo apt install ninja-build ${{ matrix.compiler.pkgs }} libx11-xcb-dev libfontenc-dev libice-dev \
libsm-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev libxi-dev \
libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev \
libxss-dev libxt-dev libxtst-dev libxv-dev libxxf86vm-dev libxcb-render0-dev libxcb-render-util0-dev \
libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev \
libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-dri3-dev uuid-dev libxcb-cursor-dev \
libxcb-util-dev libxcb-util0-dev libx11-xcb1 libx11-dev libgl-dev libgl1-mesa-dev
shell: bash

- name: Configure via CMake
shell: bash
run: cmake --preset ${{ matrix.compiler.preset }}-qt -DCXX_STANDARD=${{ matrix.cxx }}

- name: Build
shell: bash
run: cmake --build --preset build-${{ matrix.compiler.preset }}-qt

- name: Test
shell: bash
run: ctest --preset test-${{ matrix.compiler.preset }}-qt
32 changes: 32 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"hidden": true,
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"environment": {
"CONFIGURE_QT": "0"
},
"cacheVariables": {
"CPP_STARTER_USE_SML": "ON",
"CPP_STARTER_USE_BOOST_BEAST": "ON",
Expand Down Expand Up @@ -404,6 +407,24 @@
"CMAKE_C_COMPILER": "clang-15",
"CMAKE_CXX_COMPILER": "clang++-15"
}
},
{
"name": "clang-15-qt",
"displayName": "Clang 15 QT",
"inherits": "conf-unixlike-common",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-15",
"CMAKE_CXX_COMPILER": "clang++-15",
"CPP_STARTER_USE_SML": "OFF",
"CPP_STARTER_USE_BOOST_BEAST": "OFF",
"CPP_STARTER_USE_CROW": "OFF",
"CPP_STARTER_USE_CPPZMQ_PROTO": "OFF",
"CPP_STARTER_USE_QT": "ON"
},
"environment": {
"NOT_ON_C3I": "1",
"CONFIGURE_QT": "1"
}
}
],
"buildPresets": [
Expand Down Expand Up @@ -541,6 +562,11 @@
"name": "build-clang-15-fuzzing",
"displayName": "Linux Clang 15 Fuzzing",
"configurePreset": "clang-15-fuzzing"
},
{
"name": "build-clang-15-qt",
"displayName": "Linux Clang 15 QT",
"configurePreset": "clang-15-qt"
}
],
"testPresets": [
Expand Down Expand Up @@ -713,6 +739,12 @@
"displayName": "Linux Clang 15 Fuzzing",
"inherits": "test-common",
"configurePreset": "clang-15-fuzzing"
},
{
"name": "test-clang-15-qt",
"displayName": "Linux Clang 15 QT",
"inherits": "test-common",
"configurePreset": "clang-15-qt"
}
]
}
1 change: 1 addition & 0 deletions cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ OPTION(CPP_STARTER_USE_BOOST_BEAST "Enable compilation of boost beast sample" OF
OPTION(CPP_STARTER_USE_CROW "Enable compilation of crow sample" OFF)
OPTION(CPP_STARTER_USE_CPPZMQ_PROTO "Enable compilation of protobuf and cppzmq sample" OFF)
OPTION(CPP_STARTER_USE_EMBEDDED_TOOLCHAIN "Enable compilation of an example cortex m4 project" OFF)
OPTION(CPP_STARTER_USE_QT "Enable compilation of an example QT project" OFF)
18 changes: 13 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import conans.model.requires
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain
Expand All @@ -6,18 +8,24 @@
class HelloConan(ConanFile):
settings = 'os', 'compiler', 'build_type', 'arch'
generators = 'CMakeDeps', 'CMakeToolchain'
default_options = {'fmt/*:header_only': True, 'spdlog/*:header_only': True}
default_options = {'fmt/*:header_only': True, 'spdlog/*:header_only': True, 'qt/*:with_fontconfig': False}

def configure(self):
cmake = CMakeToolchain(self)
cmake.user_presets_path = None
if self.settings.get_safe('arch') == 'armv7':
self.requires = conans.model.requires.Requirements(['fmt/10.0.0', 'sml/1.1.6'])
return

if os.getenv("CONFIGURE_QT") == '1':
self.requires = conans.model.requires.Requirements(['catch2/3.4.0', 'docopt.cpp/0.6.3', 'gtest/1.14.0',
'qt/6.6.1', 'spdlog/1.12.0'])
else:
self.requires = conans.model.requires.Requirements(['catch2/3.4.0', 'gtest/1.14.0', 'docopt.cpp/0.6.3',
'spdlog/1.12.0', 'sml/1.1.8', 'nlohmann_json/3.11.2',
'boost/1.83.0', 'crowcpp-crow/1.0+5', 'cppzmq/4.9.0',
'protobuf/3.21.12'])
requirement = ['catch2/3.4.0', 'gtest/1.14.0', 'docopt.cpp/0.6.3',
'spdlog/1.12.0', 'sml/1.1.8', 'nlohmann_json/3.11.2',
'boost/1.83.0', 'crowcpp-crow/1.0+5', 'cppzmq/4.9.0',
'protobuf/3.21.12']
self.requires = conans.model.requires.Requirements(requirement)

def build(self):
cmake = CMakeToolchain(self)
Expand Down
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ IF(CPP_STARTER_USE_CPPZMQ_PROTO)
ADD_SUBDIRECTORY(protobuf.cppzmq)
ENDIF()

# QT example
IF(CPP_STARTER_USE_QT)
MESSAGE("Using QT")
ADD_SUBDIRECTORY(qt)
ENDIF()


FIND_PACKAGE(docopt REQUIRED)
FIND_PACKAGE(spdlog REQUIRED)
Expand Down
4 changes: 4 additions & 0 deletions src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FIND_PACKAGE(Qt6 REQUIRED)

ADD_EXECUTABLE(test_qt main.cpp)
TARGET_LINK_LIBRARIES(test_qt PRIVATE ${CMAKE_THREAD_LIBS_INIT} qt::qt)
6 changes: 6 additions & 0 deletions src/qt/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


int main()
{
return 0;
}

0 comments on commit 8cf8a67

Please sign in to comment.