cross-compile Windows

This commit is contained in:
OpexHunter 2025-03-03 12:54:40 +03:00
parent ec5705d94f
commit 3852dad8c9
8 changed files with 42 additions and 20 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@
!.gitignore !.gitignore
!LICENSE !LICENSE
!README.md !README.md
!toolchain*.cmake

View File

@ -1,22 +1,14 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(PunkLauncher VERSION 1.0.0 LANGUAGES CXX) project(PunkLauncher VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/app)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(STATUS "In-source builds are not allowed. Please use a separate build directory.")
message(FATAL_ERROR "Please use a separate build directory: cd build & cmake ..")
endif()
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(LibArchive REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Widgets Network) find_package(Qt6 REQUIRED COMPONENTS Widgets Network)
qt_standard_project_setup() qt_standard_project_setup()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Linux-app)
add_subdirectory(src/app) add_subdirectory(src/app)

View File

@ -1,20 +1,24 @@
qt_add_executable(PunkLauncher qt_add_executable(PunkLauncher
main.cpp main.cpp
ui/mainwindow.cpp ui/mainwindow.cpp
launcher/launcher.cpp launcher/launcher.cpp
launcher/profile_handler/forge1_12_2.cpp launcher/profile_handler/forge1_12_2.cpp
backend/backend.cpp backend/backend.cpp
settings/settings.cpp settings/settings.cpp
../resources/resources.qrc ../resources/resources.qrc
../resources/mainwindow.ui ../resources/mainwindow.ui
) )
target_link_libraries(PunkLauncher PRIVATE target_link_libraries(PunkLauncher PRIVATE
Qt6::Widgets Qt6::Widgets
Qt6::Network Qt6::Network
LibArchive::LibArchive)
set_target_properties(PunkLauncher PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
) )
if(WIN32)
target_sources(PunkLauncher PRIVATE
../resources/app.rc
)
set_target_properties(PunkLauncher PROPERTIES
WIN32_EXECUTABLE ON
)
endif()

BIN
src/resources/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

1
src/resources/app.rc Normal file
View File

@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "app.ico"

View File

@ -31,6 +31,10 @@
<property name="windowTitle"> <property name="windowTitle">
<string>PunkLauncher</string> <string>PunkLauncher</string>
</property> </property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:/app.ico</normaloff>:/app.ico</iconset>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QFrame#border_top, QFrame#border_bottom, QFrame#border_left, QFrame#border_right { <string notr="true">QFrame#border_top, QFrame#border_bottom, QFrame#border_left, QFrame#border_right {
/*background-color: rgb(217, 78, 108);*/ /*background-color: rgb(217, 78, 108);*/

View File

@ -1,6 +1,7 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>auth/logo.png</file> <file>auth/logo.png</file>
<file>app.ico</file>
<file>main/selected_profile.png</file> <file>main/selected_profile.png</file>
<file>main/settings_pressed_32x32.png</file> <file>main/settings_pressed_32x32.png</file>
<file>main/settings_hover_32x32.png</file> <file>main/settings_hover_32x32.png</file>

19
toolchain-win.cmake Normal file
View File

@ -0,0 +1,19 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_FIND_ROOT_PATH /home/xuy/x-tools/x86_64-w64-mingw32)
# Режим поиска зависимостей
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# Библиотеки
set(CMAKE_PREFIX_PATH /opt/qt6-mingw ${CMAKE_PREFIX_PATH})
set(CMAKE_PREFIX_PATH /opt/deps/mingw ${CMAKE_PREFIX_PATH})
set(CMAKE_PREFIX_PATH /opt/deps/mingw-icu ${CMAKE_PREFIX_PATH})
# Статическая сборка
set(QT_STATIC ON)
set(DBUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++")