Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full Windows and Linux support #4

Merged
merged 10 commits into from
Sep 17, 2024
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
26 changes: 15 additions & 11 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
fail-fast: false
matrix:
config:
# - {
# name: "Windows Latest MinGW", artifact: "Windows-Ninja.tar.xz",
# os: windows-latest,
# build_type: "Release", cc: "gcc", cxx: "g++",
# }
# - {
# name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz",
# os: ubuntu-latest,
# build_type: "Release", cc: "gcc", cxx: "g++"
# }
- {
name: "Windows Latest MinGW", artifact: "Windows-Ninja.tar.xz",
os: windows-latest,
build_type: "Release", cc: "gcc", cxx: "g++",
}
- {
name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz",
os: ubuntu-latest,
build_type: "Release", cc: "gcc", cxx: "g++"
}
- {
name: "macOS Latest Clang", artifact: "macOS.tar.xz",
os: macos-latest,
Expand All @@ -29,9 +29,13 @@ jobs:
steps:
- uses: actions/checkout@v4


- uses: seanmiddleditch/gha-setup-ninja@master

- name: Install Qt dependencies for Linux
if: ${{ matrix.config.os == 'ubuntu-latest' }}
run: |
sudo apt install libgl1-mesa-dev libglu1-mesa-dev

- name: Create CMake cache
shell: bash
run: |
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)

project(
QtCMake
VERSION 0.9.0
VERSION 1.0.0
DESCRIPTION "CMake project for easy Qt connection to other CMake projects"
LANGUAGES CXX
)
Expand All @@ -15,6 +15,8 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

if (WIN32)
set(USER_HOME_DIRECTORY $ENV{USERPROFILE})
else ()
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ The resulting app is an executable that can be run on a system without Qt.

The main Qt6 configuration is found in the [correspondent](lib/qt/CMakeLists.txt) CMakeLists.txt file.

> Note: Although the project has CI compilation tests, they somehow only succeed on macOS.
> I don't know why.
> I tested manually on Windows and Linux, and it works perfectly.

> Note that statically compiled Qt6 weights more than 5 GB.
> The good thing is that user does not need whole compiled Qt6 with this configuration.

Expand All @@ -17,7 +13,8 @@ The main Qt6 configuration is found in the [correspondent](lib/qt/CMakeLists.txt
* Ninja
* Git

On Linux: most of the libraries that match `*xcb*` and `*xkb*` are required.
On Linux: `libgl1-mesa-dev libglu1-mesa-dev` and all dependencies are required.
> Note that most of the libraries that match `*xcb*` and `*xkb*` may be required on Linux.

## How to build and run

Expand Down
21 changes: 11 additions & 10 deletions lib/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (NOT Qt6_FOUND)
# Set Ninja for compilation
set(CMAKE_GENERATOR "Ninja" CACHE STRING "CMake generator" FORCE)
# Initial message
message(STATUS "Qt 6.7.2 not found. Downloading and configuring Qt...")
message(STATUS "Qt 6 not found. Downloading and configuring Qt...")

# Download and extract archive of Qt 6.7.2
set(QT_VERSION "6.7.2")
Expand All @@ -43,26 +43,27 @@ if (NOT Qt6_FOUND)
OUTPUT_QUIET
)

if (WIN32)
set(CONFIG_SCRIPT_EXT ".bat")
else ()
set(CONFIG_SCRIPT_EXT "")
endif ()

# Configure Qt (skip building of useless modules)
set(QT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/qt-build")
file(MAKE_DIRECTORY ${QT_BUILD_DIR})
message(STATUS "Configuring...")
execute_process(COMMAND "${QT_SOURCE_DIR}/configure${CONFIG_SCRIPT_EXT}" -static -prefix ${QT_BUILD_DIR}
WORKING_DIRECTORY ${QT_BUILD_DIR})
set(QT_CONFIGURE_OPTIONS -static -c++std c++20 -static-runtime -release -nomake examples -nomake tests -prefix ${QT_BUILD_DIR})

if (WIN32)
execute_process(COMMAND "${QT_SOURCE_DIR}/configure.bat" ${QT_CONFIGURE_OPTIONS}
WORKING_DIRECTORY ${QT_BUILD_DIR})
else ()
execute_process(COMMAND "${QT_SOURCE_DIR}/configure" ${QT_CONFIGURE_OPTIONS}
WORKING_DIRECTORY ${QT_BUILD_DIR})
endif ()

# Build Qt
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${QT_BUILD_DIR})

find_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
else ()
message(STATUS "Qt 6.7.2 found in the system.")
message(STATUS "Qt 6 found in the system.")
endif ()

qt_standard_project_setup()
Expand Down