-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b658190
commit 33b11ec
Showing
10 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters