@@ -47,18 +47,25 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../build) # path/to/build_directory
4747set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ../build )
4848
4949set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS} " )
50-
5150set (CMAKE_CXX_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${CMAKE_CXX_LINKER_FLAGS} " )
5251
5352set (CMAKE_SHARED_LIBRARY_PREFIX "" )
5453
54+ list (APPEND CMAKE_PREFIX_PATH "${QT5_DIR} " )
55+ list (APPEND CMAKE_PREFIX_PATH "${OPEN_XLSX_DIR} " )
56+
5557set (QT_COMPONENTS Core Gui Widgets Sql PrintSupport Network)
5658
5759find_package (
58- Qt5
59- COMPONENTS
60- ${QT_COMPONENTS}
61- REQUIRED
60+ Qt5
61+ COMPONENTS
62+ ${QT_COMPONENTS}
63+ REQUIRED
64+ )
65+
66+ find_package (
67+ OpenXLSX
68+ REQUIRED
6269)
6370
6471function (find_files dir type result)
@@ -71,69 +78,68 @@ find_files(${UI_DIRECTORY} "ui" UI_FILES)
7178
7279include_directories (source )
7380
74- add_library (
75- image_downloader SHARED
76- source /services/image-downloader/image_downloader.cpp
77- )
78-
7981set (CONSOLE_FLAG)
8082if (${CMAKE_BUILD_TYPE} MATCHES "Release" )
8183 set (CONSOLE_FLAG WIN32 )
8284endif ()
8385
8486add_executable (
85- ${PROJECT_NAME}
86- ${CONSOLE_FLAG}
87- source /main.cpp
88- source /interfaces/font-editor/font_editor.cpp
89- source /interfaces/font-editor/font_editor.h
90- source /interfaces/options /options .cpp
91- source /interfaces/options /options .h
92- source /interfaces/mainwindow/mainwindow.cpp
93- source /interfaces/mainwindow/mainwindow.h
94- source /interfaces/text-position-selector/text_position_selector.cpp
95- source /interfaces/text-position-selector/text_position_selector.h
96- source /interfaces/database-settings/database_settings.cpp
97- source /interfaces/database-settings/database_settings.h
98- source /interfaces/password-form/password_form.cpp
99- source /interfaces/password-form/password_form.h
100- source /interfaces/records-amount-form/records_amount_form.cpp
101- source /interfaces/records-amount-form/records_amount_form.h
102- ${UI_FILES}
103- source /services/settings/settings_manager.cpp
104- source /services/text-painter/text_painter.cpp
105- source /services/theme-loader/theme_loader.cpp
106- source /services/image-printer/image_printer.cpp
107- source /resources/icon.rc
87+ ${PROJECT_NAME}
88+ ${CONSOLE_FLAG}
89+ source /main.cpp
90+ source /interfaces/font-editor/font_editor.cpp
91+ source /interfaces/font-editor/font_editor.h
92+ source /interfaces/options /options .cpp
93+ source /interfaces/options /options .h
94+ source /interfaces/mainwindow/mainwindow.cpp
95+ source /interfaces/mainwindow/mainwindow.h
96+ source /interfaces/text-position-selector/text_position_selector.cpp
97+ source /interfaces/text-position-selector/text_position_selector.h
98+ source /interfaces/database-settings/database_settings.cpp
99+ source /interfaces/database-settings/database_settings.h
100+ source /interfaces/password-form/password_form.cpp
101+ source /interfaces/password-form/password_form.h
102+ source /interfaces/records-amount-form/records_amount_form.cpp
103+ source /interfaces/records-amount-form/records_amount_form.h
104+ ${UI_FILES}
105+ source /services/settings/settings_manager.cpp
106+ source /services/text-painter/text_painter.cpp
107+ source /services/theme-loader/theme_loader.cpp
108+ source /services/image-printer/image_printer.cpp
109+ source /resources/icon.rc
108110)
109111
110112target_link_libraries (
111- image_downloader
112- PUBLIC
113- Qt5::Network
114- )
115-
116- target_link_libraries (
117- ${PROJECT_NAME}
118- PUBLIC
119- Qt5::Core
120- Qt5::Gui
121- Qt5::Widgets
122- Qt5::Sql
123- Qt5::PrintSupport
124- image_downloader
113+ ${PROJECT_NAME}
114+ PUBLIC
115+ Qt5::Core
116+ Qt5::Gui
117+ Qt5::Widgets
118+ Qt5::Sql
119+ Qt5::PrintSupport
120+ Qt5::Network
121+
122+ OpenXLSX::OpenXLSX
125123)
126124
127125target_compile_features (${PROJECT_NAME} PRIVATE cxx_std_17)
128126set_target_properties (${PROJECT_NAME} PROPERTIES AUTOMOC ON AUTORCC ON AUTOUIC ON )
129127
130128# Копирование содержимого папки reference в build
131129add_custom_command (
132- TARGET ${PROJECT_NAME}
133- POST_BUILD
134- COMMAND ${CMAKE_COMMAND} -E copy_directory
135- ${CMAKE_SOURCE_DIR} /build_folder_reference/
136- ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
130+ TARGET ${PROJECT_NAME}
131+ POST_BUILD
132+ COMMAND ${CMAKE_COMMAND} -E copy_directory
133+ ${CMAKE_SOURCE_DIR} /build_folder_reference/
134+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
135+ )
136+
137+ add_custom_command (
138+ TARGET ${PROJECT_NAME}
139+ POST_BUILD
140+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPEN_XLSX_DIR} /bin/libOpenXLSX.dll"
141+
142+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
137143)
138144
139145# Qt autoDLL
@@ -142,7 +148,7 @@ if (WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
142148 if (MSVC AND CMAKE_BUILD_TYPE MATCHES "Debug" )
143149 set (DEBUG_SUFFIX "d" )
144150 endif ()
145- set (QT_INSTALL_PATH " ${CMAKE_PREFIX_PATH} " )
151+ set (QT_INSTALL_PATH ${QT5_DIR} )
146152 if (NOT EXISTS "${QT_INSTALL_PATH} /bin" )
147153 set (QT_INSTALL_PATH "${QT_INSTALL_PATH} /.." )
148154 if (NOT EXISTS "${QT_INSTALL_PATH} /bin" )
@@ -151,38 +157,53 @@ if (WIN32 AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
151157 endif ()
152158 if (EXISTS "${QT_INSTALL_PATH} /plugins/platforms/qwindows${DEBUG_SUFFIX} .dll" )
153159 add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
154- COMMAND ${CMAKE_COMMAND} -E make_directory
155- "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/platforms/" )
160+ COMMAND ${CMAKE_COMMAND} -E make_directory
161+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/platforms/" )
156162 add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
157- COMMAND ${CMAKE_COMMAND} -E copy
158- "${QT_INSTALL_PATH} /plugins/platforms/qwindows${DEBUG_SUFFIX} .dll"
159- "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/platforms/" )
163+ COMMAND ${CMAKE_COMMAND} -E copy
164+ "${QT_INSTALL_PATH} /plugins/platforms/qwindows${DEBUG_SUFFIX} .dll"
165+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/platforms/" )
160166 endif ()
161167 if (EXISTS "${QT_INSTALL_PATH} /plugins/sqldrivers/qsqlpsql${DEBUG_SUFFIX} .dll" )
162168 add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
163- COMMAND ${CMAKE_COMMAND} -E make_directory
164- "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/sqldrivers/" )
169+ COMMAND ${CMAKE_COMMAND} -E make_directory
170+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/sqldrivers/" )
165171 add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
166- COMMAND ${CMAKE_COMMAND} -E copy
167- "${QT_INSTALL_PATH} /plugins/sqldrivers/qsqlpsql${DEBUG_SUFFIX} .dll"
168- "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/sqldrivers/" )
172+ COMMAND ${CMAKE_COMMAND} -E copy
173+ "${QT_INSTALL_PATH} /plugins/sqldrivers/qsqlpsql${DEBUG_SUFFIX} .dll"
174+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/sqldrivers/" )
169175 add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
170- COMMAND ${CMAKE_COMMAND} -E copy_directory
171- "${QT_INSTALL_PATH} /plugins/printsupport"
172- "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/printsupport" )
176+ COMMAND ${CMAKE_COMMAND} -E copy_directory
177+ "${QT_INSTALL_PATH} /plugins/printsupport"
178+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/printsupport" )
173179 endif ()
180+ add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
181+ COMMAND ${CMAKE_COMMAND} -E copy
182+ "${QT_INSTALL_PATH} /plugins/imageformats/qjpeg.dll"
183+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/imageformats/qjpeg.dll"
184+ )
185+ add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
186+ COMMAND ${CMAKE_COMMAND} -E copy
187+ "${QT_INSTALL_PATH} /plugins/imageformats/qwbmp.dll"
188+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/imageformats/qwbmp.dll"
189+ )
190+ add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
191+ COMMAND ${CMAKE_COMMAND} -E copy
192+ "${QT_INSTALL_PATH} /plugins/imageformats/qwebp.dll"
193+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >/plugins/imageformats/qwebp.dll"
194+ )
174195 foreach (QT_LIB ${QT_COMPONENTS} )
175196 add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
176- COMMAND ${CMAKE_COMMAND} -E copy
177- "${QT_INSTALL_PATH} /bin/Qt5${QT_LIB}${DEBUG_SUFFIX} .dll"
178- "$<TARGET_FILE_DIR:${PROJECT_NAME} >" )
197+ COMMAND ${CMAKE_COMMAND} -E copy
198+ "${QT_INSTALL_PATH} /bin/Qt5${QT_LIB}${DEBUG_SUFFIX} .dll"
199+ "$<TARGET_FILE_DIR:${PROJECT_NAME} >" )
179200 endforeach (QT_LIB)
180- if (DEFINED DEPLOY_DEPENDENCY)
201+ if (DEFINED DEPLOY_DEPENDENCY)
181202 set (DEPLOY_COMMAND deployment/deploy_windows.bat ${DEPLOY_DEPENDENCY} )
182203 add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
183- COMMAND ${DEPLOY_COMMAND}
184- COMMENT "Running Inno Setup Compiler"
185- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
204+ COMMAND ${DEPLOY_COMMAND}
205+ COMMENT "Running Inno Setup Compiler"
206+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
186207 )
187208 endif ()
188209endif ()
0 commit comments