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

Windows Qt6 builds based on vcpkg #57413

Closed
wants to merge 25 commits into from
Closed
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
28 changes: 28 additions & 0 deletions .github/actions/setup-vcpkg/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Setup Vcpkg
description: Initialize vcpkg tool, does not checkout the registry
# TODO, set VCPKG_BASE_VERSION based on this
# inputs:
# vcpkg-version:
# description: Enter vcpkg version tag or stable or latest
# required: false
# default: latest
# type: string

runs:
using: composite
steps:
- name: Setup vcpkg
if: runner.os != 'Windows'
shell: bash
run: |
. <(curl https://aka.ms/vcpkg-init.sh -L)
echo "PATH=$VCPKG_ROOT;$PATH" >> $GITHUB_ENV

- name: Setup vcpkg
if: runner.os == 'Windows'
shell: powershell
run: |
$env:VCPKG_ROOT = "C:/.vcpkg"
iex (iwr -useb https://aka.ms/vcpkg-init.ps1)
echo "VCPKG_ROOT=$env:VCPKG_ROOT" >> $env:GITHUB_ENV
echo "PATH=$env:VCPKG_ROOT;$env:PATH" >> $env:GITHUB_ENV
112 changes: 112 additions & 0 deletions .github/workflows/windows-qt6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
name: 🪟 Windows Qt6
on:
push:
branches:
- master
- release-**
pull_request:
release:
types: ['published']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
packages: write

jobs:
build:
name: build (windows)
runs-on: windows-2022

steps:
- name: 🐣 Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: 🐩 Install CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.29.2

- name: 🧽 Developer Command Prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1
with:
# See https://github.com/actions/runner-images/issues/9398
toolset: 14.39

- name: Setup vcpkg
uses: ./.github/actions/setup-vcpkg

- name: Setup flex/bison
uses: robinraju/[email protected]
with:
repository: 'lexxmark/winflexbison'
fileName: '*.zip'
tag: 'v2.5.24'
m-kuhn marked this conversation as resolved.
Show resolved Hide resolved
extract: true

- name: ccache
uses: hendrikmuhs/[email protected]
with:
max-size: 1G

- name: 🌱 Install dependencies and generate project files
shell: bash
run: |
BUILD_DIR=$( cygpath "${{ github.workspace }}/build" )
SOURCE_DIR=$( cygpath "${{ github.workspace }}" )

cmake -S "${SOURCE_DIR}" \
-B "${BUILD_DIR}" \
-G Ninja \
-D CMAKE_BUILD_TYPE=Release \
-D WITH_VCPKG=ON \
-D CREATE_ZIP=ON \
-D VCPKG_TARGET_TRIPLET=x64-windows-release \
-D VCPKG_HOST_TRIPLET=x64-windows-release \
-D WITH_DESKTOP=ON \
-D WITH_3D=ON \
-D WITH_BINDINGS=ON \
-D ENABLE_TESTS=OFF \
-D BUILD_WITH_QT6=ON \
-D USE_CCACHE=ON \
-D FLEX_EXECUTABLE="${SOURCE_DIR}/win_flex.exe" \
-D BISON_EXECUTABLE="${SOURCE_DIR}/win_bison.exe" \
-D SIP_BUILD_EXECUTABLE="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\Scripts\sip-build.exe" \
-D PYUIC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\pyuic5.bat" \
-D PYRCC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\pyrcc5.bat" \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D WITH_QTWEBKIT=OFF \
-D VCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/src" \
-D NUGET_USERNAME=${{ github.actor }} \
-D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }}

- name: 🌋 Build
shell: bash
run: |
cmake --build "${{ github.workspace }}/build" --config Release

- name: 📦 Package
shell: bash
run: |
cmake --build "${{ github.workspace }}/build" --target bundle --config Release

- name: 📑 Upload dep build logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-logs-x64-windows
path: |
C:/src/**/*.log

- name: 📤 Upload bundle
uses: actions/upload-artifact@v4
with:
name: qgis-windows-qt6
path: |
build/*-win64.zip
50 changes: 12 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ endif()
# don't relink it only the shared object changes
set(CMAKE_LINK_DEPENDS_NO_SHARED ON)

set (WITH_BINDINGS TRUE CACHE BOOL "Determines whether Python bindings should be built")
set (WITH_3D TRUE CACHE BOOL "Determines whether QGIS 3D library should be built")
set (WITH_QGIS_PROCESS TRUE CACHE BOOL "Determines whether the standalone \"qgis_process\" tool should be built")
set (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built")
set (WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library should be built")
set(WITH_VCPKG FALSE CACHE BOOL "Use the vcpkg submodule for dependency management.")

if(WITH_VCPKG)
include(VcpkgToolchain)
endif()
#############################################################
# Project and version
set(CPACK_PACKAGE_VERSION_MAJOR "3")
Expand Down Expand Up @@ -140,7 +150,6 @@ if(WITH_CORE)
endif()
endforeach (GRASS_SEARCH_VERSION)

set (WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library (and everything built on top of it) should be built")

set (WITH_OAUTH2_PLUGIN TRUE CACHE BOOL "Determines whether OAuth2 authentication method plugin should be built")
if(WITH_OAUTH2_PLUGIN)
Expand All @@ -151,7 +160,6 @@ if(WITH_CORE)

set (WITH_ANALYSIS TRUE CACHE BOOL "Determines whether QGIS analysis library should be built")

set (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built")

if(WITH_DESKTOP)
if((WIN32 AND NOT MINGW) OR (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS))
Expand All @@ -171,17 +179,14 @@ if(WITH_CORE)
endif()
endif()

set (WITH_3D TRUE CACHE BOOL "Determines whether QGIS 3D library should be built")

set (WITH_QUICK FALSE CACHE BOOL "Determines whether QGIS Quick library should be built")

set (WITH_QGIS_PROCESS TRUE CACHE BOOL "Determines whether the standalone \"qgis_process\" tool should be built")

set (NATIVE_CRSSYNC_BIN "" CACHE PATH "Path to a natively compiled synccrsdb binary. If set, crssync will not build but use provided bin instead.")
mark_as_advanced (NATIVE_CRSSYNC_BIN)

# try to configure and build python bindings by default
set (WITH_BINDINGS TRUE CACHE BOOL "Determines whether Python bindings should be built")
if (WITH_BINDINGS)
# By default bindings will be installed only to QGIS directory
# Someone might want to install it to python site-packages directory
Expand Down Expand Up @@ -1218,39 +1223,8 @@ endif()
#############################################################
# Enable packaging
if (WITH_CORE)
# Do not warn about runtime libs when building using VS Express
if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
endif()

if(QGIS_INSTALL_SYS_LIBS)
include(InstallRequiredSystemLibraries)
endif()

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QGIS")
set(CPACK_PACKAGE_VENDOR "Open Source Geospatial Foundation")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "QGIS ${COMPLETE_VERSION}")
if(WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backslashes.
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/win_build\\\\sidebar.bmp")
set(CPACK_NSIS_INSTALLED_ICON_NAME "\\\\qgis.exe")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} QGIS")
set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\qgis.org")
set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\qgis.org")
set(CPACK_NSIS_CONTACT "[email protected]")
set(CPACK_NSIS_MODIFY_PATH ON)

# set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " !include \\\"${CMAKE_SOURCE_DIR}\\\\win_build\\\\extra.nsh\\\"")
else()
#set(CPACK_STRIP_FILES "QGIS")
#set(CPACK_SOURCE_STRIP_FILES "")
endif()
set(CPACK_PACKAGE_EXECUTABLES "qgis" "QGIS")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
include(CPack)
include(Bundle)
include(VcpkgInstallDeps)
endif()

if (UNIX AND NOT APPLE)
Expand Down
8 changes: 8 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Building QGIS from source - step by step
* [4.2.1.2. Building the dependencies](#4212-building-the-dependencies)
* [4.2.1.3. Cross-Building QGIS](#4213-cross-building-qgis)
* [4.2.2. Testing QGIS](#422-testing-qgis)
* [4.3 Building for Qt 6 with VCPKG / Microsoft Visual Studio](#41-building-with-qt6)
* [5. Building on MacOS X](#5-building-on-macos-x)
* [5.1. Install Developer Tools](#51-install-developer-tools)
* [5.2. Install CMake and other build tools](#52-install-cmake-and-other-build-tools)
Expand Down Expand Up @@ -708,6 +709,13 @@ can also change the build and release directories.
Copy and unzip on the Windows machine package produced by the build and launch the qgis binary: no installation
is required.

# 4.3 Building with XXX

- Install Microsoft Visual Studio Community Edition as explained in ...
- Get all dependencies
- Download an SDK
- Build all dependencies yourself

# 5. Building on MacOS X

If you want to test QGIS, easiest option is to download and install all-in-one self-containing bundle directly from
Expand Down
47 changes: 47 additions & 0 deletions cmake/Bundle.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
set(CPACK_GENERATOR)
set(CPACK_OUTPUT_CONFIG_FILE "${CMAKE_BINARY_DIR}/BundleConfig.cmake")

add_custom_target(bundle
COMMAND ${CMAKE_CPACK_COMMAND} "--config" "${CMAKE_BINARY_DIR}/BundleConfig.cmake"
COMMENT "Running CPACK. Please wait..."
DEPENDS qgis)

if(WIN32 AND NOT UNIX)
set (CREATE_NSIS FALSE CACHE BOOL "Create an installer using NSIS")
endif()
set (CREATE_ZIP FALSE CACHE BOOL "Create a ZIP package")

# Do not warn about runtime libs when building using VS Express
if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
endif()

if(QGIS_INSTALL_SYS_LIBS)
include(InstallRequiredSystemLibraries)
endif()

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QGIS")
set(CPACK_PACKAGE_VENDOR "Open Source Geospatial Foundation")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "QGIS ${COMPLETE_VERSION}")
set(CPACK_PACKAGE_EXECUTABLES "qgis" "QGIS")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")

if(CREATE_NSIS)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backslashes.
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/win_build\\\\sidebar.bmp")
set(CPACK_NSIS_INSTALLED_ICON_NAME "\\\\qgis.exe")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} QGIS")
set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\qgis.org")
set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\qgis.org")
set(CPACK_NSIS_CONTACT "[email protected]")
set(CPACK_NSIS_MODIFY_PATH ON)
endif()

if(CREATE_ZIP)
list(APPEND CPACK_GENERATOR "ZIP")
endif()

include(CPack)
18 changes: 18 additions & 0 deletions cmake/NuGet.Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="defaultPushSource" value="@NUGET_SOURCE@" />
</config>
<activePackageSource>
<add key="vcpkg" value="@NUGET_SOURCE@" />
</activePackageSource>
<packageSources>
<add key="vcpkg" value="@NUGET_SOURCE@" />
</packageSources>
<packageSourceCredentials>
<vcpkg>
<add key="Username" value="@NUGET_USERNAME@" />
<add key="ClearTextPassword" value="@NUGET_TOKEN@" />
</vcpkg>
</packageSourceCredentials>
</configuration>
28 changes: 28 additions & 0 deletions cmake/VcpkgInstallDeps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
if(NOT WITH_VCPKG)
return()
endif()

set(VCPKG_BASE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}")

if(MSVC)
# At least python3.dll, qgis_analysis.dll and gsl.dll are missing
# Copy everything
file(GLOB ALL_LIBS
"${VCPKG_BASE_DIR}/bin/*.dll"
)
install(FILES ${ALL_LIBS} DESTINATION "bin")
endif()

set(PROJ_DATA_PATH "${VCPKG_BASE_DIR}/share/proj")

if(NOT EXISTS "${PROJ_DATA_PATH}/proj.db")
message(FATAL_ERROR "proj.db not found at ${PROJ_DATA_PATH}/proj.db")
endif()

install(DIRECTORY "${PROJ_DATA_PATH}/" DESTINATION "${CMAKE_INSTALL_DATADIR}/proj")
install(DIRECTORY "${VCPKG_BASE_DIR}/share/gdal/" DESTINATION "${CMAKE_INSTALL_DATADIR}/gdal")
install(DIRECTORY "${VCPKG_BASE_DIR}/bin/Qca/" DESTINATION "bin/Qca") # QCA plugins
install(DIRECTORY "${VCPKG_BASE_DIR}/Qt6/" DESTINATION "bin/Qt6") # qt plugins (qml and others)
install(DIRECTORY "${VCPKG_BASE_DIR}/tools/python3/"
DESTINATION "bin"
PATTERN "*.sip" EXCLUDE)
Loading
Loading