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
94 changes: 94 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CMake

on:
push:
branches:
pull_request:
branches:
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
os-name: windows
qt-version: '5.12.12'
mingw-short-version: 73

- os: ubuntu-latest
os-name: linux
qt-version: '5.12.12'

- os: macos-latest
os-name: mac
qt-version: '5.15.2'

- os: ubuntu-latest
os-name: linux
qt-version: '6.2.*'
modules: 'qtmultimedia'

defaults:
run:
shell: bash

steps:
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
host: ${{ matrix.os-name }}
arch: ${{ startsWith(matrix.os-name, 'win') && format('win32_mingw{0}', matrix.mingw-short-version) || ''}}
tools: ${{ startsWith(matrix.os-name, 'win') && format('tools_mingw,qt.tools.win32_mingw{0}0', matrix.mingw-short-version) || '' }}
modules: ${{ matrix.modules }}

- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-plugins-base

- name: Update PATH
if: ${{ startsWith(matrix.os-name, 'win') }}
run: |
set -xue
cygpath -w /usr/bin >> $GITHUB_PATH
cygpath -w "${IQTA_TOOLS}/mingw${{matrix.mingw-short-version}}0_32/bin" >> $GITHUB_PATH
cygpath -w "${Qt5_Dir}/bin" >> $GITHUB_PATH

- name: Check available tools
run: |
set -xueo pipefail
echo $PATH
uname -a
qmake --version
make --version
g++ --version
git --version

- name: Configure git
run: |
git config --global core.symlinks true
git config --global core.autocrlf true

- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0

- name: Create build directory
run: mkdir ../build

- name: CMake configuration and generation
run: |
if ${{ startsWith(matrix.os-name, 'win') }}; then
cmake -G "MinGW Makefiles" -S . -B ../build
else
cmake -S . -B ../build
fi

- name: CMake build
timeout-minutes: 10
run: cmake --build ../build
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "thirdparty/SingleApplication"]
path = thirdparty/SingleApplication
[submodule "dependencies/singleapplication"]
path = dependencies/singleapplication
url = https://github.com/itay-grudev/SingleApplication.git
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Preamble
cmake_minimum_required(VERSION 3.20)
project(trik-desktop-gamepad VERSION 1.0.0 LANGUAGES CXX)

# Project wide setup
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# Prevent from build in source dir
include(NoInSourceBuilds)

# Externally provided content
include(QtHelper)
add_subdirectory(dependencies)

# Main targets built by this project
add_subdirectory(src)

# Process fonts, images, translations
add_subdirectory(share)

# TO DO:
# add_subdirectory(tests)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_subdirectory(packaging)
endif()
11 changes: 11 additions & 0 deletions cmake/NoInSourceBuilds.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR
"\n"
"In-source builds are not allowed.\n"
"Instead, provide a path to build tree like so:\n"
"cmake -B <destination>\n"
"\n"
"To remove files you accidentally created execute:\n"
"rm -rf CMakeFiles CMakeCache.txt\n"
)
endif()
27 changes: 27 additions & 0 deletions cmake/QtHelper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set(QT_COMPONENTS
Core
Gui
Network
Widgets
Multimedia
MultimediaWidgets
LinguistTools)

#find_package(Qt6 COMPONENTS ${QT_COMPONENTS})
#if (NOT Qt6_FOUND)
# find_package(Qt5 5.15 REQUIRED ${QT_COMPONENTS})
#endif()

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS ${QT_COMPONENTS})
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${QT_COMPONENTS})

message("FOUND QT (default): ${QT_DEFAULT_MAJOR_VERSION}")
message("FOUND QT: ${QT_VERSION_MAJOR}")

set(QT_LIBRARIES
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Multimedia
Qt${QT_VERSION_MAJOR}::MultimediaWidgets)
12 changes: 12 additions & 0 deletions cmake/TranslationUtils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function(ADD_TRANSLATIONS_RESOURCE res_file)
set(QM_FILES ${ARGN})
set(RES_FILE ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)

file(WRITE ${RES_FILE} "<!DOCTYPE RCC><RCC version=\"1.0\">\n <qresource prefix=\"/\">\n")
foreach(LANG ${QM_FILES})
get_filename_component(FILENAME ${LANG} NAME)
file(APPEND ${RES_FILE} " <file alias=\"i18n/${FILENAME}\">${FILENAME}</file>\n")
endforeach()
file(APPEND ${RES_FILE} " </qresource>\n</RCC>\n")
set(${res_file} ${RES_FILE} PARENT_SCOPE)
endfunction()
Binary file removed connections.png
Binary file not shown.
3 changes: 3 additions & 0 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SingleApplication
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
add_subdirectory(singleapplication)
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
TEMPLATE = subdirs

SUBDIRS = \
SingleApplication/singleapplication.pri
singleapplication/singleapplication.pri
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

DEFINES += QAPPLICATION_CLASS=QApplication

include (SingleApplication/singleapplication.pri)
include (singleapplication/singleapplication.pri)
QMAKE_CXXFLAGS -= -Wold-style-cast
File renamed without changes
36 changes: 36 additions & 0 deletions packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})

# Generate file name in deb format:
# <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"A remote control for controlling TRIK programmable educational robots")
set(CPACK_PACKAGE_VENDOR "TRIK")

set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/${PROJECT_NAME}")

set(CPACK_PACKAGE_CONTACT $ENV{DEBMAIL})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER $ENV{DEBFULLNAME})

set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")

# Values of variables prefixed with CPACK_ will be escaped before being written to the configuration files,
# so that the cpack program receives them exactly as they were specified
set(CPACK_VERBATIM_VARIABLES YES)

# Generate defined format of packages in case running cpack without arguments
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CPACK_GENERATOR DEB)
else()
set(CPACK_GENERATOR TGZ)
endif()

include(CPack)
7 changes: 7 additions & 0 deletions share/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include(GNUInstallDirs)
install(
DIRECTORY fonts images
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}
)

add_subdirectory(translations)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
20 changes: 20 additions & 0 deletions share/translations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(TS_FILES
trikDesktopGamepad_de.ts
trikDesktopGamepad_en.ts
trikDesktopGamepad_ru.ts
trikDesktopGamepad_fr.ts)

if(Qt6_FOUND)
qt_add_translations(${PROJECT_NAME} TS_FILES ${TS_FILES})
else()
qt5_add_translation(QM_FILES ${TS_FILES})
include(TranslationUtils)
add_translations_resource(QRC_FILE ${QM_FILES})
add_custom_target(create_qm ALL DEPENDS ${QM_FILES})
add_custom_target(create_qrc ALL DEPENDS ${QRC_FILE})
add_dependencies(create_qrc create_qm)
add_dependencies(${PROJECT_NAME} create_qrc)
target_sources(${PROJECT_NAME} PRIVATE ${QRC_FILE})
endif()

install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/translations)
29 changes: 29 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
set(SOURCES
accelerateStrategy.cpp
connectForm.cpp
connectionManager.cpp
gamepadForm.cpp
main.cpp
standardStrategy.cpp
strategy.cpp
../share/fonts.qrc
../share/images.qrc)

add_executable(${PROJECT_NAME} ${SOURCES})

target_link_libraries(${PROJECT_NAME}
PRIVATE
${QT_LIBRARIES}
SingleApplication
)

if(Qt6_FOUND)
target_compile_definitions(${PROJECT_NAME} PRIVATE TRIK_USE_QT6)
endif()

set_target_properties(${PROJECT_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BIN})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion main.cpp → src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* "pad 1 0 -100\n", excluding quotes.
* */

#include "thirdparty/SingleApplication/singleapplication.h"
#include "../dependencies/singleapplication/singleapplication.h"

#include "gamepadForm.h"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 22 additions & 22 deletions trikDesktopGamepad.pri
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ CONFIG += c++14
DEFINES += QT_NO_ACCESSIBILITY

SOURCES += \
$$PWD/main.cpp \
$$PWD/gamepadForm.cpp \
$$PWD/connectForm.cpp \
$$PWD/connectionManager.cpp \
$$PWD/standardStrategy.cpp \
$$PWD/accelerateStrategy.cpp \
$$PWD/strategy.cpp
$$PWD/src/main.cpp \
$$PWD/src/gamepadForm.cpp \
$$PWD/src/connectForm.cpp \
$$PWD/src/connectionManager.cpp \
$$PWD/src/standardStrategy.cpp \
$$PWD/src/accelerateStrategy.cpp \
$$PWD/src/strategy.cpp

TRANSLATIONS += \
$$PWD/languages/trikDesktopGamepad_ru.ts \
$$PWD/languages/trikDesktopGamepad_en.ts \
$$PWD/languages/trikDesktopGamepad_fr.ts \
$$PWD/languages/trikDesktopGamepad_de.ts
$$PWD/share/translations/trikDesktopGamepad_ru.ts \
$$PWD/share/translations/trikDesktopGamepad_en.ts \
$$PWD/share/translations/trikDesktopGamepad_fr.ts \
$$PWD/share/translations/trikDesktopGamepad_de.ts

HEADERS += \
$$PWD/gamepadForm.h \
$$PWD/connectForm.h \
$$PWD/connectionManager.h \
$$PWD/standardStrategy.h \
$$PWD/accelerateStrategy.h \
$$PWD/strategy.h
$$PWD/src/gamepadForm.h \
$$PWD/src/connectForm.h \
$$PWD/src/connectionManager.h \
$$PWD/src/standardStrategy.h \
$$PWD/src/accelerateStrategy.h \
$$PWD/src/strategy.h

FORMS += \
$$PWD/gamepadForm.ui \
$$PWD/connectForm.ui
$$PWD/src/gamepadForm.ui \
$$PWD/src/connectForm.ui

RESOURCES += \
$$PWD/images.qrc \
$$PWD/fonts.qrc
$$PWD/share/images.qrc \
$$PWD/share/fonts.qrc

# Single Application implementation
include(thirdparty/singleApplication.pro)
include(dependencies/singleapplication.pro)