Skip to content
Merged
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
167 changes: 94 additions & 73 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,25 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../build) # path/to/build_directory
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../build)

set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS}")

set(CMAKE_CXX_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${CMAKE_CXX_LINKER_FLAGS}")

set(CMAKE_SHARED_LIBRARY_PREFIX "")

list(APPEND CMAKE_PREFIX_PATH "${QT5_DIR}")
list(APPEND CMAKE_PREFIX_PATH "${OPEN_XLSX_DIR}")

set(QT_COMPONENTS Core Gui Widgets Sql PrintSupport Network)

find_package(
Qt5
COMPONENTS
${QT_COMPONENTS}
REQUIRED
Qt5
COMPONENTS
${QT_COMPONENTS}
REQUIRED
)

find_package(
OpenXLSX
REQUIRED
)

function(find_files dir type result)
Expand All @@ -71,69 +78,68 @@ find_files(${UI_DIRECTORY} "ui" UI_FILES)

include_directories(source)

add_library(
image_downloader SHARED
source/services/image-downloader/image_downloader.cpp
)

set(CONSOLE_FLAG)
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
set(CONSOLE_FLAG WIN32)
endif ()

add_executable(
${PROJECT_NAME}
${CONSOLE_FLAG}
source/main.cpp
source/interfaces/font-editor/font_editor.cpp
source/interfaces/font-editor/font_editor.h
source/interfaces/options/options.cpp
source/interfaces/options/options.h
source/interfaces/mainwindow/mainwindow.cpp
source/interfaces/mainwindow/mainwindow.h
source/interfaces/text-position-selector/text_position_selector.cpp
source/interfaces/text-position-selector/text_position_selector.h
source/interfaces/database-settings/database_settings.cpp
source/interfaces/database-settings/database_settings.h
source/interfaces/password-form/password_form.cpp
source/interfaces/password-form/password_form.h
source/interfaces/records-amount-form/records_amount_form.cpp
source/interfaces/records-amount-form/records_amount_form.h
${UI_FILES}
source/services/settings/settings_manager.cpp
source/services/text-painter/text_painter.cpp
source/services/theme-loader/theme_loader.cpp
source/services/image-printer/image_printer.cpp
source/resources/icon.rc
${PROJECT_NAME}
${CONSOLE_FLAG}
source/main.cpp
source/interfaces/font-editor/font_editor.cpp
source/interfaces/font-editor/font_editor.h
source/interfaces/options/options.cpp
source/interfaces/options/options.h
source/interfaces/mainwindow/mainwindow.cpp
source/interfaces/mainwindow/mainwindow.h
source/interfaces/text-position-selector/text_position_selector.cpp
source/interfaces/text-position-selector/text_position_selector.h
source/interfaces/database-settings/database_settings.cpp
source/interfaces/database-settings/database_settings.h
source/interfaces/password-form/password_form.cpp
source/interfaces/password-form/password_form.h
source/interfaces/records-amount-form/records_amount_form.cpp
source/interfaces/records-amount-form/records_amount_form.h
${UI_FILES}
source/services/settings/settings_manager.cpp
source/services/text-painter/text_painter.cpp
source/services/theme-loader/theme_loader.cpp
source/services/image-printer/image_printer.cpp
source/resources/icon.rc
)

target_link_libraries(
image_downloader
PUBLIC
Qt5::Network
)

target_link_libraries(
${PROJECT_NAME}
PUBLIC
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Sql
Qt5::PrintSupport
image_downloader
${PROJECT_NAME}
PUBLIC
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Sql
Qt5::PrintSupport
Qt5::Network

OpenXLSX::OpenXLSX
)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
set_target_properties(${PROJECT_NAME} PROPERTIES AUTOMOC ON AUTORCC ON AUTOUIC ON)

# Копирование содержимого папки reference в build
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/build_folder_reference/
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/build_folder_reference/
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)

add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPEN_XLSX_DIR}/bin/libOpenXLSX.dll"

${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)

# Qt autoDLL
Expand All @@ -142,7 +148,7 @@ if (WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if (MSVC AND CMAKE_BUILD_TYPE MATCHES "Debug")
set(DEBUG_SUFFIX "d")
endif ()
set(QT_INSTALL_PATH "${CMAKE_PREFIX_PATH}")
set(QT_INSTALL_PATH ${QT5_DIR})
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
Expand All @@ -151,38 +157,53 @@ if (WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
endif ()
if (EXISTS "${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
endif ()
if (EXISTS "${QT_INSTALL_PATH}/plugins/sqldrivers/qsqlpsql${DEBUG_SUFFIX}.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/sqldrivers/")
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/sqldrivers/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/sqldrivers/qsqlpsql${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/sqldrivers/")
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/sqldrivers/qsqlpsql${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/sqldrivers/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${QT_INSTALL_PATH}/plugins/printsupport"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/printsupport")
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${QT_INSTALL_PATH}/plugins/printsupport"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/printsupport")
endif ()
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/imageformats/qjpeg.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/imageformats/qjpeg.dll"
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/imageformats/qwbmp.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/imageformats/qwbmp.dll"
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/imageformats/qwebp.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/imageformats/qwebp.dll"
)
foreach (QT_LIB ${QT_COMPONENTS})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/bin/Qt5${QT_LIB}${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>")
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/bin/Qt5${QT_LIB}${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>")
endforeach (QT_LIB)
if (DEFINED DEPLOY_DEPENDENCY)
if (DEFINED DEPLOY_DEPENDENCY)
set(DEPLOY_COMMAND deployment/deploy_windows.bat ${DEPLOY_DEPENDENCY})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${DEPLOY_COMMAND}
COMMENT "Running Inno Setup Compiler"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${DEPLOY_COMMAND}
COMMENT "Running Inno Setup Compiler"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif ()
endif ()
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
1. Install Cmake
2. Download & Install **[Qt5][4]**
3. ```sh
cmake -DCMAKE_BUILD_TYPE={type} -DCMAKE_PREFIX_PATH=path/to/Qt5 -G {generator} -B ./cmake-build-{type}
cmake -DCMAKE_BUILD_TYPE={type} -QT5_DIR=path/to/Qt5 -DOPEN_XLSX_DIR=path/to/OpenXLSX -G {generator} -B ./cmake-build-{type}
cmake --build ./cmake-build-{type} --target TIP -j 14
```

Expand All @@ -32,7 +32,7 @@
2. Install **[Inno Download Plugin][6]**
3. To activate deployment mode, add the following flag to the CMake configuration:
```sh
cmake -DCMAKE_BUILD_TYPE={type} -DCMAKE_PREFIX_PATH=path/to/Qt5 "-DDEPLOY_DEPENDENCY=\"path/to/idp.iss\"" -G {generator} -B ./cmake-build-{type}
cmake -DCMAKE_BUILD_TYPE={type} -QT5_DIR=path/to/Qt5 -DOPEN_XLSX_DIR=path/to/OpenXLSX "-DDEPLOY_DEPENDENCY=\"path/to/idp.iss\"" -G {generator} -B ./cmake-build-{type}
cmake --build ./cmake-build-{type} --target TIP -j 14
```
or run [windows_deploy.bat][8] after building the project and enter `"path/to/idp.iss"` as an argument.
Expand Down
11 changes: 0 additions & 11 deletions build_folder_reference/settings/settings.ini

This file was deleted.

4 changes: 2 additions & 2 deletions deployment/database/insert_default_records.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ VALUES (DEFAULT, 'Arial', '#000000', 0, 0, 50, false),
(DEFAULT, 'Arial', '#000000', 100, 100, 50, false),
(DEFAULT, 'Arial', '#000000', 200, 200, 50, false);

INSERT INTO main.image (url, id, format)
VALUES (null, DEFAULT, null);
INSERT INTO main.image (base64, id)
VALUES (null, DEFAULT);
3 changes: 1 addition & 2 deletions deployment/database/tables_creation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ create table if not exists main.font_settings

create table if not exists main.image
(
url text,
base64 bytea,
id serial
constraint image_pk
primary key,
format text
);

create table if not exists main.advanced_settings_passwords
Expand Down
2 changes: 1 addition & 1 deletion deployment/windows_installer/tip_setup_offline.iss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
; along with this program. If not, see <https://www.gnu.org/licenses/>.

#define MyAppName "TIP"
#define MyAppVersion "8.0"
#define MyAppVersion "8.1"
#define MyAppPublisher "Pavel Remdenok"
#define MyAppURL "https://github.com/pavel-cpp"
#define MyAppExeName "TIP.exe"
Expand Down
2 changes: 1 addition & 1 deletion deployment/windows_installer/tip_setup_online.iss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
; along with this program. If not, see <https://www.gnu.org/licenses/>.

#define MyAppName "TIP"
#define MyAppVersion "8.0"
#define MyAppVersion "8.1"
#define MyAppPublisher "Pavel Remdenok"
#define MyAppURL "https://github.com/pavel-cpp"
#define MyAppExeName "TIP.exe"
Expand Down
Loading