Updated CMakeLists.txt file to generate folder with binary and all deps for windows; Minor bug fixes

This commit is contained in:
2025-03-09 23:55:45 +03:00
parent add225198e
commit bbbb6cd184
9 changed files with 124 additions and 24 deletions

View File

@@ -29,6 +29,7 @@ set(SOURCES
)
if(STANDALONE_SYSTEM)
set(BUILD_MODE "standalone")
add_compile_definitions(STANDALONE_SYSTEM)
list(APPEND SOURCES
@@ -42,9 +43,16 @@ if(STANDALONE_SYSTEM)
pb/hooks/utils.js
)
add_custom_target(copy_assets ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/api ${CMAKE_BINARY_DIR}/api
)
add_custom_target(copy_assets ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/api ${CMAKE_BINARY_DIR}/api
)
else()
set(BUILD_MODE "client")
endif()
if (WIN32)
set(APP_ICON_RESOURCE_FILES icon.rc)
list(APPEND SOURCES ${APP_ICON_RESOURCE_FILES})
endif()
qt_add_executable(digisto ${SOURCES})
@@ -74,3 +82,81 @@ install(TARGETS digisto
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Build Assets
# Set output directory format <platform>-<build type>
if (WIN32)
set(PLATFORM_NAME "win64")
elseif (UNIX)
set(PLATFORM_NAME "linux")
else()
set(PLATFORM_NAME "unknown")
endif()
# Add debug/release tag on folder
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(BUILD_TYPE "-debug")
else()
set(BUILD_TYPE "")
endif()
# Output directory for gathering dependencies
set(OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/digisto-${BUILD_MODE}-${PLATFORM_NAME}${BUILD_TYPE}")
set(ZIP_OUTPUT, "${CMAKE_CURRENT_SOURCE_DIR}/build")
# Ensure the output directory exists
file(MAKE_DIRECTORY ${OUTPUT_DIR})
# Copy the binary after build
add_custom_command(TARGET digisto POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:digisto> ${OUTPUT_DIR}/
COMMENT "📂 Copying binary to ${OUTPUT_DIR}/"
)
# Copy pocketbase as well for standalone systems
if(STANDALONE_SYSTEM)
add_custom_target(copy_assets_ext ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/api ${OUTPUT_DIR}/api
)
endif()
# ------------------------------------------------------------ #
# DEPLOYMENT SECTION #
# ------------------------------------------------------------ #
# Set directory that contains QML files
set(QMLDIR ${CMAKE_SOURCE_DIR}/ui)
# WINDEPLOYQT_EXECUTABLE
# CMAKE_PREFIX_PATH
# Deploy for win32
if (WIN32)
set(QT_BIN_DIR "${CMAKE_PREFIX_PATH}/bin")
set(QTPATHS "${QT_BIN_DIR}/qtpaths.exe")
set(WINDEPLOYQT_BIN "${QT_BIN_DIR}/windeployqt.exe")
# Set output directory for deployment
set(DEPLOY_DIR "${OUTPUT_DIR}")
file(MAKE_DIRECTORY ${DEPLOY_DIR})
# Copy icon assets
add_custom_command(TARGET digisto POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/assets/imgs/logo.ico" "${DEPLOY_DIR}/"
COMMENT "📂 Copying logo.ico to deploy directory"
)
# Run windeployqt to deploy dependencies
add_custom_command(TARGET digisto POST_BUILD
COMMAND ${WINDEPLOYQT_BIN} --qmldir ${QMLDIR} --qtpaths ${QTPATHS} --dir ${DEPLOY_DIR} "${DEPLOY_DIR}/digisto.exe"
COMMENT "🚀 Running windeployqt..."
)
# Run windeployqt to deploy dependencies
add_custom_command(TARGET digisto POST_BUILD
COMMAND ${CMAKE_COMMAND} -E tar "cf" ${ZIP_OUTPUT} --format=zip ${DEPLOY_DIR}
COMMENT "Zipping folder ..."
)
endif()

BIN
assets/imgs/logo.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

BIN
logo.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

View File

@@ -11,7 +11,13 @@ DsController::DsController(QObject *parent)
m_isLoggedIn(false)
{
QFile file(QStringLiteral(":/configs/app-config.json"));
Q_ASSERT(file.open(QIODevice::ReadOnly));
if (!file.exists()) {
qDebug() << "Resource file missing!";
}
auto ok = file.open(QIODevice::ReadOnly);
Q_ASSERT(ok);
QVariantMap configurations=QJsonDocument::fromJson(file.readAll()).toVariant().toMap();

View File

@@ -4,6 +4,8 @@
#include <QStandardPaths>
#include <QDateTime>
#include <QFile>
#include <QProcessEnvironment>
class Configurator {
public:
@@ -17,7 +19,6 @@ public:
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
}
static void messageHandler(QtMsgType msgType,
const QMessageLogContext &context,
const QString &msg) {

View File

@@ -21,6 +21,12 @@ int main(int argc, char *argv[])
QtWebView::initialize(); // WebEngine init
QApplication app(argc, argv); // App init
#ifdef STANDALONE_SYSTEM
qApp->setApplicationName("Digisto POS - Standalone");
#else
qApp->setApplicationName("Digisto POS - Client");
#endif
// Register message handler
qInstallMessageHandler(Configurator::messageHandler);

View File

@@ -9,7 +9,8 @@ PermissionManager::PermissionManager(DsController *dsController, QObject *parent
{
// Load permission template from the json file
QFile file(QStringLiteral(":/configs/permissions-templ.json"));
Q_ASSERT(file.open(QIODevice::ReadOnly));
auto ok = file.open(QIODevice::ReadOnly);
Q_ASSERT(ok);
// Create QVariantMap out of the template json
m_permissionTemplate =

View File

@@ -50,7 +50,7 @@ Button {
id: ico
iconType: control.iconType
iconSize: lbl.fontSize * 1.3
color: lbl.color
iconColor: lbl.color
anchors.verticalCenter: parent.verticalCenter
}

View File

@@ -213,22 +213,22 @@ DsPage {
}
// TODO REMOVE
Timer {
id: prefillTimer
interval: 500
repeat: false
triggeredOnStart: true
onTriggered: {
if(running) {
emailinput.text = 'allan@digisto.app'
passwordinput.text = '123123123'
} else {
signIn()
}
}
}
// Timer {
// id: prefillTimer
// interval: 500
// repeat: false
// triggeredOnStart: true
// onTriggered: {
// if(running) {
// emailinput.text = 'allan@digisto.app'
// passwordinput.text = '123123123'
// } else {
// signIn()
// }
// }
// }
Component.onCompleted: {
prefillTimer.restart()
}
// Component.onCompleted: {
// prefillTimer.restart()
// }
}