Skip to content

Commit

Permalink
Merge pull request #58993 from qgis/winvcpkg
Browse files Browse the repository at this point in the history
Windows Qt6 builds based on vcpkg
  • Loading branch information
m-kuhn authored Oct 8, 2024
2 parents 464f7e7 + 2c89431 commit 1aa9a9a
Show file tree
Hide file tree
Showing 18 changed files with 720 additions and 137 deletions.
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
1 change: 1 addition & 0 deletions .github/workflows/build_artifact_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_run:
workflows:
- 🪟 MingW64 Windows 64bit Build
- 🪟 Windows Qt6
types:
- completed

Expand Down
93 changes: 0 additions & 93 deletions .github/workflows/mingw-w64-msys2.yml

This file was deleted.

137 changes: 137 additions & 0 deletions .github/workflows/windows-qt6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
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.6

- name: 🧽 Developer Command Prompt for Microsoft Visual C++
uses: ilammy/msvc-dev-cmd@v1

- 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'
extract: true

- name: 🛍️ Setup 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
# - uses: m-kuhn/action-tmate@patch-1
# if: failure()

- name: 📦 Package
shell: bash
run: |
cmake --build "${{ github.workspace }}/build" --target bundle --config Release
- name: 📦 Create SDK
# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release'
run: |
vcpkg.exe export --zip --output-dir=./sdk --x-install-root=./build/vcpkg_installed --x-manifest-root=vcpkg
- name: 📤 Upload sdk
# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release'
uses: actions/upload-artifact@v4
with:
name: qgis-sdk-x64-windows
path: |
sdk/vcpkg-export-*.zip
- 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
id: artifact-win64-qt6
with:
name: qgis-windows-qt6
path: |
build/*-win64.zip
- name: Schedule download comment
uses: ./.github/actions/post_sticky_comment
with:
marker: mingw64-qt6
body: |
### 🪟 Windows Qt6 builds
Download [Windows Qt6builds of this PR for testing](${{ steps.artifact-win64-qt6.outputs.artifact-url }}).
*(Built from commit ${{ github.event.pull_request.head.sha }})*
pr: ${{ github.event.number }}
71 changes: 30 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ 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.")

set(WITH_VCPKG TRUE CACHE BOOL "Use the vcpkg submodule for dependency management.")
set(SDK_PATH "" CACHE STRING "Build with VCPKG SDK")

if(NOT SDK_PATH STREQUAL "")
message(STATUS "Building with SDK -- ${SDK_PATH}")
set(CMAKE_TOOLCHAIN_FILE "${SDK_PATH}/scripts/buildsystems/vcpkg.cmake")
if(APPLE AND NOT VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "x64-osx-dynamic")
endif()
set(WITH_VCPKG ON)
elseif(WITH_VCPKG)
message(STATUS "Building local dependencies with VCPKG --")
include(VcpkgToolchain)
else()
message(STATUS "Building with system libraries --")
endif()

if(WITH_VCPKG)
list(APPEND CMAKE_PROGRAM_PATH "${VCPKG_INSTALL_PREFIX}/${VCPKG_TARGET_TRIPLET}/")
endif()

#############################################################
# Project and version
set(CPACK_PACKAGE_VERSION_MAJOR "3")
Expand Down Expand Up @@ -138,7 +166,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 @@ -149,8 +176,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))
set (CRASH_HANDLER_AVAILABLE TRUE)
Expand All @@ -169,17 +194,12 @@ 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 +1238,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
Loading

0 comments on commit 1aa9a9a

Please sign in to comment.