From 2ce2c217e61819317c6c38ca85e51c8ca3c0259e Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 2 May 2024 13:58:35 +0200 Subject: [PATCH 01/43] Add vcpkg for windows --- .github/actions/setup-vcpkg/action.yml | 28 ++ .github/workflows/windows-qt6.yml | 81 +++++ CMakeLists.txt | 15 +- INSTALL.md | 8 + cmake/NuGet.Config.in | 18 + cmake/VcpkgToolchain.cmake | 64 ++++ vcpkg/ports/gdal/cmake-project-include.cmake | 13 + vcpkg/ports/gdal/find-link-libraries.patch | 109 ++++++ .../gdal/fix-gdal-target-interfaces.patch | 15 + vcpkg/ports/gdal/libkml.patch | 46 +++ vcpkg/ports/gdal/portfile.cmake | 195 ++++++++++ vcpkg/ports/gdal/target-is-valid.patch | 21 ++ vcpkg/ports/gdal/usage | 4 + vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake | 23 ++ vcpkg/ports/gdal/vcpkg.json | 334 ++++++++++++++++++ vcpkg/ports/py-qscintilla/fix-static.patch | 29 ++ vcpkg/ports/py-qscintilla/portfile.cmake | 62 ++++ vcpkg/ports/py-qscintilla/vcpkg.json | 22 ++ vcpkg/ports/swig/portfile.cmake | 30 ++ vcpkg/ports/swig/vcpkg.json | 19 + vcpkg/triplets/x64-windows-release.cmake | 5 + vcpkg/vcpkg.json | 133 +++++++ 22 files changed, 1269 insertions(+), 5 deletions(-) create mode 100644 .github/actions/setup-vcpkg/action.yml create mode 100644 .github/workflows/windows-qt6.yml create mode 100644 cmake/NuGet.Config.in create mode 100644 cmake/VcpkgToolchain.cmake create mode 100644 vcpkg/ports/gdal/cmake-project-include.cmake create mode 100644 vcpkg/ports/gdal/find-link-libraries.patch create mode 100644 vcpkg/ports/gdal/fix-gdal-target-interfaces.patch create mode 100644 vcpkg/ports/gdal/libkml.patch create mode 100644 vcpkg/ports/gdal/portfile.cmake create mode 100644 vcpkg/ports/gdal/target-is-valid.patch create mode 100644 vcpkg/ports/gdal/usage create mode 100644 vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake create mode 100644 vcpkg/ports/gdal/vcpkg.json create mode 100644 vcpkg/ports/py-qscintilla/fix-static.patch create mode 100644 vcpkg/ports/py-qscintilla/portfile.cmake create mode 100644 vcpkg/ports/py-qscintilla/vcpkg.json create mode 100644 vcpkg/ports/swig/portfile.cmake create mode 100644 vcpkg/ports/swig/vcpkg.json create mode 100644 vcpkg/triplets/x64-windows-release.cmake create mode 100644 vcpkg/vcpkg.json diff --git a/.github/actions/setup-vcpkg/action.yml b/.github/actions/setup-vcpkg/action.yml new file mode 100644 index 000000000000..b42086db5c39 --- /dev/null +++ b/.github/actions/setup-vcpkg/action.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml new file mode 100644 index 000000000000..c5fcd9101bdd --- /dev/null +++ b/.github/workflows/windows-qt6.yml @@ -0,0 +1,81 @@ +--- +name: 🪟 Windows Qt6 +on: + push: + branches: + - windows-qt6 + - release-** + pull_request: + release: + types: ['published'] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +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: 🌱 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 VCPKG_TARGET_TRIPLET=x64-windows-release \ + -D VCPKG_HOST_TRIPLET=x64-windows-release \ + -D WITH_3D=ON \ + -D WITH_BINDINGS=ON \ + -D ENABLE_TESTS=OFF \ + -D BUILD_WITH_QT6=ON \ + -D USE_CCACHE=ON \ + -D FLEX_EXECUTABLE="${VCPKG_ROOT}\downloads\tools\win_bison\2.5.25\win_flex.exe" \ + -D BISON_EXECUTABLE="${VCPKG_ROOT}\downloads\tools\win_bison\2.5.25\win_bison.exe" \ + -D WITH_QTWEBKIT=OFF \ + -D VCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/src" \ + -D NUGET_USERNAME=m-kuhn \ + -D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} + + - name: 🌋 Build + run: | + cmake --build "${{ github.workspace }}/build" --config Release + + - name: 📦 Package + run: | + cmake --install "${{ github.workspace }}/build" --config Release + + - name: 📑 Upload dep build logs + uses: actions/upload-artifact@v4 + if: failure() + with: + name: build-logs-x64-windows + path: | + C:/src/**/*.log + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c0c02a97f25d..88df603d44f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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) @@ -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)) @@ -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 diff --git a/INSTALL.md b/INSTALL.md index b7432de79e78..0c877ef7e6ec 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -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) @@ -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 diff --git a/cmake/NuGet.Config.in b/cmake/NuGet.Config.in new file mode 100644 index 000000000000..8b912c3be1e3 --- /dev/null +++ b/cmake/NuGet.Config.in @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/cmake/VcpkgToolchain.cmake b/cmake/VcpkgToolchain.cmake new file mode 100644 index 000000000000..e31d207b8e8d --- /dev/null +++ b/cmake/VcpkgToolchain.cmake @@ -0,0 +1,64 @@ +set(NUGET_SOURCE "https://nuget.pkg.github.com/m-kuhn/index.json") +set(NUGET_USERNAME "m-kuhn" CACHE STRING "Nuget user") + +# Setup features (dependencies) based on cmake configuration +if(WITH_BINDINGS) + list(APPEND VCPKG_MANIFEST_FEATURES "bindings") +endif() +if(WITH_3D) + list(APPEND VCPKG_MANIFEST_FEATURES "3d") +endif() +if(WITH_QGIS_PROCESS) + list(APPEND VCPKG_MANIFEST_FEATURES "process") +endif() +if(WITH_GUI) + list(APPEND VCPKG_MANIFEST_FEATURES "gui") +endif() +if(WITH_DESKTOP) + list(APPEND VCPKG_MANIFEST_FEATURES "desktop") +endif() + +# Setup binary cache +if(NOT "${NUGET_TOKEN}" STREQUAL "" AND WIN32) + set(_VCPKG_EXECUTABLE "vcpkg.exe") + + execute_process( + COMMAND ${_VCPKG_EXECUTABLE} fetch nuget + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE _FETCH_NUGET_OUTPUT) + + STRING(REGEX REPLACE "\n" ";" _FETCH_NUGET_OUTPUT "${_FETCH_NUGET_OUTPUT}") + list(GET _FETCH_NUGET_OUTPUT -1 _NUGET_PATH) + + set(_NUGET_EXE ${_NUGET_PATH}) + + set(_CONFIG_PATH "${CMAKE_BINARY_DIR}/github-NuGet.Config") + + configure_file( + "${CMAKE_SOURCE_DIR}/cmake/NuGet.Config.in" + "${_CONFIG_PATH}" + @ONLY) + execute_process( + COMMAND ${_NUGET_EXE} setapikey "${NUGET_TOKEN}" -src "https://nuget.pkg.github.com/m-kuhn/index.json" -configfile ${_CONFIG_PATH} + OUTPUT_VARIABLE _OUTPUT + ERROR_VARIABLE _ERROR + RESULT_VARIABLE _RESULT) + if(_RESULT EQUAL 0) + message(STATUS "Setup nuget api key - done") + else() + message(STATUS "Setup nuget api key - failed") + message(STATUS "Output:") + message(STATUS ${_OUTPUT}) + message(STATUS "Error:") + message(STATUS ${_ERROR}) + endif() + + file(TO_NATIVE_PATH "${_CONFIG_PATH}" _CONFIG_PATH_NATIVE) + set(ENV{VCPKG_BINARY_SOURCES} "$ENV{VCPKG_BINARY_SOURCES};nugetconfig,${_CONFIG_PATH_NATIVE},readwrite") +endif() + +set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") +set(VCPKG_MANIFEST_DIR "${CMAKE_SOURCE_DIR}/vcpkg") +# Copies DLLs built by vcpkg when an install() command is run. +# Only works on Windows and even there not reliably ... +set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON CACHE BOOL "Copy dependency DLLs on install") diff --git a/vcpkg/ports/gdal/cmake-project-include.cmake b/vcpkg/ports/gdal/cmake-project-include.cmake new file mode 100644 index 000000000000..409b7b1a6436 --- /dev/null +++ b/vcpkg/ports/gdal/cmake-project-include.cmake @@ -0,0 +1,13 @@ +if(GDAL_USE_KEA) + find_package(Kealib CONFIG REQUIRED) + add_library(KEA::KEA ALIAS Kealib::Kealib) + set(GDAL_CHECK_PACKAGE_KEA_NAMES Kealib CACHE INTERNAL "vcpkg") + set(GDAL_CHECK_PACKAGE_KEA_TARGETS Kealib::Kealib CACHE INTERNAL "vcpkg") +endif() + +if(GDAL_USE_WEBP) + find_package(WebP CONFIG REQUIRED) + add_library(WEBP::WebP ALIAS WebP::webp) + set(GDAL_CHECK_PACKAGE_WebP_NAMES WebP CACHE INTERNAL "vcpkg") + set(GDAL_CHECK_PACKAGE_WebP_TARGETS WebP::webp CACHE INTERNAL "vcpkg") +endif() diff --git a/vcpkg/ports/gdal/find-link-libraries.patch b/vcpkg/ports/gdal/find-link-libraries.patch new file mode 100644 index 000000000000..8e9c163ef7b4 --- /dev/null +++ b/vcpkg/ports/gdal/find-link-libraries.patch @@ -0,0 +1,109 @@ +diff --git a/cmake/modules/packages/FindFreeXL.cmake b/cmake/modules/packages/FindFreeXL.cmake +index 6c86fb8..0634412 100644 +--- a/cmake/modules/packages/FindFreeXL.cmake ++++ b/cmake/modules/packages/FindFreeXL.cmake +@@ -37,7 +37,15 @@ include(SelectLibraryConfigurations) + + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) +- pkg_check_modules(PC_FREEXL QUIET freexl) ++ pkg_check_modules(PC_FREEXL QUIET IMPORTED_TARGET freexl) ++endif() ++if(PC_FREEXL_FOUND) ++ set(FREEXL_INCLUDE_DIR "${PC_FREEXL_INCLUDE_DIRS}" CACHE STRING "") ++ set(FREEXL_LIBRARY "${PC_FREEXL_LIBRARIES}" CACHE STRING "") ++ if(NOT TARGET FREEXL::freexl) ++ add_library(FREEXL::freexl INTERFACE IMPORTED) ++ set_target_properties(FREEXL::freexl PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_FREEXL) ++ endif() + endif() + + find_path(FREEXL_INCLUDE_DIR +diff --git a/cmake/modules/packages/FindOpenJPEG.cmake b/cmake/modules/packages/FindOpenJPEG.cmake +index c697484..6e83222 100644 +--- a/cmake/modules/packages/FindOpenJPEG.cmake ++++ b/cmake/modules/packages/FindOpenJPEG.cmake +@@ -32,9 +32,18 @@ endfunction() + + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) +- pkg_check_modules(PC_OPENJPEG QUIET libopenjp2) ++ pkg_check_modules(PC_OPENJPEG QUIET IMPORTED_TARGET libopenjp2) + set(OPENJPEG_VERSION_STRING ${PC_OPENJPEG_VERSION}) + endif() ++if(PC_OPENJPEG_FOUND) ++ set(OPENJPEG_INCLUDE_DIR "${PC_OPENJPEG_INCLUDE_DIRS}" CACHE STRING "") ++ set(OPENJPEG_LIBRARY "${PC_OPENJPEG_LIBRARIES}" CACHE STRING "") ++ if(NOT TARGET OPENJPEG::OpenJPEG) ++ add_library(OPENJPEG::OpenJPEG INTERFACE IMPORTED) ++ set_target_properties(OPENJPEG::OpenJPEG PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PC_OPENJPEG_INCLUDE_DIRS}") ++ set_target_properties(OPENJPEG::OpenJPEG PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_OPENJPEG) ++ endif() ++endif() + + + find_path(OPENJPEG_INCLUDE_DIR opj_config.h +diff --git a/cmake/modules/packages/FindPoppler.cmake b/cmake/modules/packages/FindPoppler.cmake +index 3807ec0..8059eb4 100644 +--- a/cmake/modules/packages/FindPoppler.cmake ++++ b/cmake/modules/packages/FindPoppler.cmake +@@ -42,11 +42,19 @@ This module defines the following variables: + + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) +- pkg_check_modules(PC_Poppler QUIET poppler) ++ pkg_check_modules(PC_Poppler QUIET IMPORTED_TARGET poppler) + if(PC_Poppler_VERSION) + set(Poppler_VERSION_STRING ${PC_Poppler_VERSION}) + endif() + endif() ++if(PC_Poppler_FOUND) ++ find_path(Poppler_INCLUDE_DIR NAMES Object.h PATHS ${PC_Poppler_INCLUDE_DIRS} NO_DEFAULT_PATH) ++ set(Poppler_LIBRARY "${PC_Poppler_LIBRARIES}" CACHE STRING "") ++ if(NOT TARGET Poppler::Poppler) ++ add_library(Poppler::Poppler INTERFACE IMPORTED) ++ set_target_properties(Poppler::Poppler PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Poppler) ++ endif() ++endif() + find_path(Poppler_INCLUDE_DIR NAMES "poppler-config.h" "cpp/poppler-version.h" "qt5/poppler-qt5.h" "qt4/poppler-qt4.h" + "glib/poppler.h" + HINTS ${PC_Poppler_INCLUDE_DIRS} +@@ -77,6 +85,15 @@ endforeach() + foreach(_comp IN LISTS Poppler_known_components) + list(FIND Poppler_FIND_COMPONENTS "${_comp}" _nextcomp) + if(_nextcomp GREATER -1) ++ pkg_check_modules(PC_Poppler_${_comp} QUIET IMPORTED_TARGET ${Poppler_${_comp}_pkg_config}) ++ if(PC_Poppler_${_comp}_FOUND) ++ set(Poppler_${_comp}_INCLUDE_DIR "${PC_Poppler_${_comp}_INCLUDE_DIRS}" CACHE STRING "") ++ set(Poppler_${_comp}_LIBRARY "${PC_Poppler_${_comp}_LIBRARIES}" CACHE STRING "") ++ if(NOT TARGET Poppler::Poppler_${_comp}) ++ add_library(Poppler::${_comp} INTERFACE IMPORTED) ++ set_target_properties(Poppler::${_comp} PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Poppler_${_comp}) ++ endif() ++ endif() + find_path(Poppler_${_comp}_INCLUDE_DIR + NAMES ${Poppler_${_comp}_header} + PATH_SUFFIXES poppler +diff --git a/cmake/modules/packages/FindSPATIALITE.cmake b/cmake/modules/packages/FindSPATIALITE.cmake +index 00612b0..6388719 100644 +--- a/cmake/modules/packages/FindSPATIALITE.cmake ++++ b/cmake/modules/packages/FindSPATIALITE.cmake +@@ -38,9 +38,17 @@ endif() + + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) +- pkg_check_modules(PC_SPATIALITE QUIET spatialite) ++ pkg_check_modules(PC_SPATIALITE QUIET IMPORTED_TARGET spatialite) + set(SPATIALITE_VERSION_STRING ${PC_SPATIALITE_VERSION}) + endif() ++if(PC_SPATIALITE_FOUND) ++ set(SPATIALITE_INCLUDE_DIR "${PC_SPATIALITE_INCLUDE_DIRS}" CACHE STRING "") ++ set(SPATIALITE_LIBRARY "${PC_SPATIALITE_LIBRARIES}" CACHE STRING "") ++ if(NOT TARGET SPATIALITE::SPATIALITE) ++ add_library(SPATIALITE::SPATIALITE INTERFACE IMPORTED) ++ set_target_properties(SPATIALITE::SPATIALITE PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_SPATIALITE) ++ endif() ++endif() + + find_path(SPATIALITE_INCLUDE_DIR + NAMES spatialite.h diff --git a/vcpkg/ports/gdal/fix-gdal-target-interfaces.patch b/vcpkg/ports/gdal/fix-gdal-target-interfaces.patch new file mode 100644 index 000000000000..bf159fce593a --- /dev/null +++ b/vcpkg/ports/gdal/fix-gdal-target-interfaces.patch @@ -0,0 +1,15 @@ +diff --git a/cmake/helpers/GdalDriverHelper.cmake b/cmake/helpers/GdalDriverHelper.cmake +index 838f0fd..380e20d 100644 +--- a/cmake/helpers/GdalDriverHelper.cmake ++++ b/cmake/helpers/GdalDriverHelper.cmake +@@ -248,6 +248,10 @@ function(gdal_target_interfaces _TARGET) + if (_res) + target_compile_options(${_TARGET} PRIVATE ${_res}) + endif () ++ get_property(_res TARGET ${_LIB} PROPERTY INTERFACE_LINK_LIBRARIES) ++ if (_res) ++ gdal_target_interfaces(${_TARGET} ${_res}) ++ endif () + endif () + endforeach () + endfunction() diff --git a/vcpkg/ports/gdal/libkml.patch b/vcpkg/ports/gdal/libkml.patch new file mode 100644 index 000000000000..ef25d06de525 --- /dev/null +++ b/vcpkg/ports/gdal/libkml.patch @@ -0,0 +1,46 @@ +diff --git a/cmake/modules/packages/FindLibKML.cmake b/cmake/modules/packages/FindLibKML.cmake +index 9418247..589b83d 100644 +--- a/cmake/modules/packages/FindLibKML.cmake ++++ b/cmake/modules/packages/FindLibKML.cmake +@@ -56,6 +56,8 @@ find_library(LIBKML_BASE_LIBRARY + HINTS ${PC_LIBKML_LIBRARY_DIRS} ) + mark_as_advanced(LIBKML_BASE_LIBRARY) + ++cmake_policy(PUSH) ++cmake_policy(SET CMP0057 NEW) + set(libkml_known_components DOM CONVENIENCE ENGINE REGIONATOR) + foreach(_comp IN LISTS libkml_known_components) + if(${_comp} IN_LIST LibKML_FIND_COMPONENTS) +@@ -99,21 +101,20 @@ find_package_handle_standard_args(LibKML + if(LIBKML_FOUND) + set(LIBKML_INCLUDE_DIRS "${LIBKML_INCLUDE_DIR}") + set(LIBKML_LIBRARIES "${LIBKML_BASE_LIBRARY}") ++ find_package(LibKML CONFIG REQUIRED) + if(NOT TARGET LIBKML::LibKML) +- add_library(LIBKML::LibKML UNKNOWN IMPORTED) ++ add_library(LIBKML::LibKML INTERFACE IMPORTED) + set_target_properties(LIBKML::LibKML PROPERTIES +- INTERFACE_INCLUDE_DIRECTORIES "${LIBKML_INCLUDE_DIR}" +- IMPORTED_LINK_INTERFACE_LANGUAGES "C++" +- IMPORTED_LOCATION "${LIBKML_BASE_LIBRARY}") ++ INTERFACE_LINK_LIBRARIES kmlbase) + endif() + foreach(_comp IN LISTS libkml_known_components) + if(${_comp} IN_LIST LibKML_FIND_COMPONENTS) ++ string(TOLOWER ${_comp} _name) + list(APPEND LIBKML_LIBRARIES "${LIBKML_${_comp}_LIBRARY}") + if(NOT TARGET LIBKML::${_comp}) +- add_library(LIBKML::${_comp} UNKNOWN IMPORTED) ++ add_library(LIBKML::${_comp} INTERFACE IMPORTED) + set_target_properties(LIBKML::${_comp} PROPERTIES +- IMPORTED_LINK_INTERFACE_LANGUAGES "C++" +- IMPORTED_LOCATION "${LIBKML_${_comp}_LIBRARY}") ++ INTERFACE_LINK_LIBRARIES kml${_name}) + endif() + endif() + endforeach() +@@ -129,3 +130,4 @@ if(LIBKML_FOUND) + endif() + endforeach() + endif() ++cmake_policy(POP) diff --git a/vcpkg/ports/gdal/portfile.cmake b/vcpkg/ports/gdal/portfile.cmake new file mode 100644 index 000000000000..30e653a04a92 --- /dev/null +++ b/vcpkg/ports/gdal/portfile.cmake @@ -0,0 +1,195 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO OSGeo/gdal + REF "v${VERSION}" + SHA512 764490362968b05c0edc1c73c3b51b9a517689f95f0e3e3af141da8ef81614111859bbbf2a1571f047acfbd6ba50a16320ba15ed238cbd73732a960c718d5d50 + HEAD_REF master + PATCHES + find-link-libraries.patch + fix-gdal-target-interfaces.patch + libkml.patch + target-is-valid.patch +) +# `vcpkg clean` stumbles over one subdir +file(REMOVE_RECURSE "${SOURCE_PATH}/autotest") + +# Avoid abseil, no matter if vcpkg or system +vcpkg_replace_string("${SOURCE_PATH}/ogr/ogrsf_frmts/flatgeobuf/flatbuffers/base.h" [[__has_include("absl/strings/string_view.h")]] "(0)") + +# Cf. cmake/helpers/CheckDependentLibraries.cmake +# The default for all `GDAL_USE_` dependencies is `OFF`. +# Here, we explicitly control dependencies provided via vpcpkg. +# "core" is used for a dependency which must be enabled to avoid vendored lib. +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + cfitsio GDAL_USE_CFITSIO + curl GDAL_USE_CURL + expat GDAL_USE_EXPAT + freexl GDAL_USE_FREEXL + geos GDAL_USE_GEOS + core GDAL_USE_GEOTIFF + gif GDAL_USE_GIF + hdf5 GDAL_USE_HDF5 + iconv GDAL_USE_ICONV + jpeg GDAL_USE_JPEG + core GDAL_USE_JSONC + kea GDAL_USE_KEA + lerc GDAL_USE_LERC + libkml GDAL_USE_LIBKML + lzma GDAL_USE_LIBLZMA + libxml2 GDAL_USE_LIBXML2 + mysql-libmariadb GDAL_USE_MYSQL + netcdf GDAL_USE_NETCDF + odbc GDAL_USE_ODBC + openjpeg GDAL_USE_OPENJPEG + openssl GDAL_USE_OPENSSL + pcre2 GDAL_USE_PCRE2 + png GDAL_USE_PNG + poppler GDAL_USE_POPPLER + postgresql GDAL_USE_POSTGRESQL + qhull GDAL_USE_QHULL + #core GDAL_USE_SHAPELIB # https://github.com/OSGeo/gdal/issues/5711, https://github.com/microsoft/vcpkg/issues/16041 + core GDAL_USE_SHAPELIB_INTERNAL + libspatialite GDAL_USE_SPATIALITE + sqlite3 GDAL_USE_SQLITE3 + core GDAL_USE_TIFF + webp GDAL_USE_WEBP + core GDAL_USE_ZLIB + zstd GDAL_USE_ZSTD + python BUILD_PYTHON_BINDINGS + tools BUILD_APPS + INVERTED_FEATURES + libspatialite CMAKE_DISABLE_FIND_PACKAGE_SPATIALITE +) +if(GDAL_USE_ICONV AND VCPKG_TARGET_IS_WINDOWS) + list(APPEND FEATURE_OPTIONS -D_ICONV_SECOND_ARGUMENT_IS_NOT_CONST=ON) +endif() + +if("python" IN_LIST FEATURES) + list(APPEND OPTION_RELEASE + "-DSWIG_DIR=${CURRENT_HOST_INSTALLED_DIR}/tools/swig" + "-DSWIG_EXECUTABLE=${CURRENT_HOST_INSTALLED_DIR}/tools/swig/swig${VCPKG_HOST_EXECUTABLE_SUFFIX}" + ) +else() + list(APPEND FEATURE_OPTIONS + "-DCMAKE_DISABLE_FIND_PACKAGE_SWIG=ON" + ) +endif() + +# Compatibility with older Android versions https://github.com/OSGeo/gdal/pull/5941 +if(VCPKG_TARGET_IS_ANDROID AND ANRDOID_PLATFORM VERSION_LESS 24 AND (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")) + list(APPEND FEATURE_OPTIONS -DBUILD_WITHOUT_64BIT_OFFSET=ON) +endif() + +string(REPLACE "dynamic" "" qhull_target "Qhull::qhull${VCPKG_LIBRARY_LINKAGE}_r") + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DVCPKG_HOST_TRIPLET=${HOST_TRIPLET} # for host pkgconf in PATH + ${FEATURE_OPTIONS} + -DBUILD_DOCS=OFF + -DBUILD_TESTING=OFF + -DCMAKE_DISABLE_FIND_PACKAGE_CSharp=ON + -DCMAKE_DISABLE_FIND_PACKAGE_Java=ON + -DCMAKE_DISABLE_FIND_PACKAGE_JNI=ON + -DCMAKE_DISABLE_FIND_PACKAGE_Arrow=ON + -DGDAL_USE_INTERNAL_LIBS=OFF + -DGDAL_USE_EXTERNAL_LIBS=OFF + -DGDAL_BUILD_OPTIONAL_DRIVERS=ON + -DOGR_BUILD_OPTIONAL_DRIVERS=ON + -DFIND_PACKAGE2_KEA_ENABLED=OFF + -DGDAL_CHECK_PACKAGE_MySQL_NAMES=unofficial-libmariadb + -DGDAL_CHECK_PACKAGE_MySQL_TARGETS=unofficial::libmariadb + -DMYSQL_LIBRARIES=unofficial::libmariadb + -DGDAL_CHECK_PACKAGE_NetCDF_NAMES=netCDF + -DGDAL_CHECK_PACKAGE_NetCDF_TARGETS=netCDF::netcdf + -DGDAL_CHECK_PACKAGE_QHULL_NAMES=Qhull + "-DGDAL_CHECK_PACKAGE_QHULL_TARGETS=${qhull_target}" + "-DQHULL_LIBRARY=${qhull_target}" + "-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake" + OPTIONS_DEBUG + -DBUILD_APPS=OFF + -DCMAKE_DISABLE_FIND_PACKAGE_SWIG=ON + OPTIONS_RELEASE + ${OPTIONS_RELEASE} + MAYBE_UNUSED_VARIABLES + QHULL_LIBRARY +) +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_fixup_pkgconfig() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/gdal) +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/gdal/GDALConfig.cmake" + "include(CMakeFindDependencyMacro)" + "include(CMakeFindDependencyMacro) +# gdal needs a pkg-config tool. A host dependency provides pkgconf. +get_filename_component(vcpkg_host_prefix \"\${CMAKE_CURRENT_LIST_DIR}/../../../${HOST_TRIPLET}\" ABSOLUTE) +list(APPEND CMAKE_PROGRAM_PATH \"\${vcpkg_host_prefix}/tools/pkgconf\")" +) + +if (BUILD_APPS) + vcpkg_copy_tools( + TOOL_NAMES + gdal_contour + gdal_create + gdal_footprint + gdal_grid + gdal_rasterize + gdal_translate + gdal_viewshed + gdaladdo + gdalbuildvrt + gdaldem + gdalenhance + gdalinfo + gdallocationinfo + gdalmanage + gdalmdiminfo + gdalmdimtranslate + gdalsrsinfo + gdaltindex + gdaltransform + gdalwarp + gnmanalyse + gnmmanage + nearblack + ogr2ogr + ogrinfo + ogrlineref + ogrtindex + sozip + AUTO_CLEAN + ) +endif() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/gdal-config" "${CURRENT_PACKAGES_DIR}/debug/bin/gdal-config") + +file(GLOB bin_files "${CURRENT_PACKAGES_DIR}/bin/*") +if(NOT bin_files) + file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/bin" + "${CURRENT_PACKAGES_DIR}/debug/bin" + ) +endif() + +if("python" IN_LIST FEATURES) + file(COPY "${CURRENT_PACKAGES_DIR}/Lib/site-packages/" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}") + # TODO: Generalize for non windows + file(COPY "${CURRENT_PACKAGES_DIR}/Scripts" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../Scripts") + file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/Lib/site-packages" + "${CURRENT_PACKAGES_DIR}/Scripts" + ) +endif() + +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/cpl_config.h" "#define GDAL_PREFIX \"${CURRENT_PACKAGES_DIR}\"" "") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.TXT") diff --git a/vcpkg/ports/gdal/target-is-valid.patch b/vcpkg/ports/gdal/target-is-valid.patch new file mode 100644 index 000000000000..c7acf739064a --- /dev/null +++ b/vcpkg/ports/gdal/target-is-valid.patch @@ -0,0 +1,21 @@ +diff --git a/cmake/helpers/CheckDependentLibraries.cmake b/cmake/helpers/CheckDependentLibraries.cmake +index f5c920a..53494c9 100644 +--- a/cmake/helpers/CheckDependentLibraries.cmake ++++ b/cmake/helpers/CheckDependentLibraries.cmake +@@ -41,6 +41,7 @@ endif() + # https://github.com/OSGeo/gdal/issues/5324 + function (gdal_check_target_is_valid target res_var) + get_target_property(_interface_include_directories ${target} "INTERFACE_INCLUDE_DIRECTORIES") ++ get_target_property(_type ${target} "TYPE") + if(_interface_include_directories) + foreach(_dir IN LISTS _interface_include_directories) + if(NOT EXISTS "${_dir}") +@@ -54,7 +55,7 @@ function (gdal_check_target_is_valid target res_var) + # property, but a GeoTIFF_INCLUDE_DIRS variable. + set_target_properties(${target} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GeoTIFF_INCLUDE_DIRS}") +- else() ++ elseif(NOT _type STREQUAL "INTERFACE" AND _type STREQUAL "ALIAS") + message(WARNING "Target ${target} has no INTERFACE_INCLUDE_DIRECTORIES property. Ignoring that target.") + set(${res_var} FALSE PARENT_SCOPE) + return() diff --git a/vcpkg/ports/gdal/usage b/vcpkg/ports/gdal/usage new file mode 100644 index 000000000000..59eea89c714d --- /dev/null +++ b/vcpkg/ports/gdal/usage @@ -0,0 +1,4 @@ +The package GDAL provides CMake targets: + + find_package(GDAL CONFIG REQUIRED) + target_link_libraries(main PRIVATE GDAL::GDAL) diff --git a/vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake b/vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake new file mode 100644 index 000000000000..f51e7cb8baa3 --- /dev/null +++ b/vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,23 @@ +cmake_policy(PUSH) +cmake_policy(SET CMP0012 NEW) +cmake_policy(SET CMP0054 NEW) + +list(REMOVE_ITEM ARGS "NO_MODULE" "CONFIG" "MODULE") +list(APPEND ARGS "CONFIG") +# The current port version should satisfy GDAL 3.0 ... 3.5 +list(GET ARGS 1 vcpkg_gdal_maybe_version) +if(vcpkg_gdal_maybe_version MATCHES "(^3\$|^3[.][0-5])") + list(REMOVE_AT ARGS "1") +endif() +unset(vcpkg_gdal_maybe_version) +_find_package(${ARGS} CONFIG) +if(GDAL_FOUND) + get_filename_component(vcpkg_gdal_prefix "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) + set(GDAL_INCLUDE_DIR "${vcpkg_gdal_prefix}/include" CACHE INTERNAL "") + set(GDAL_INCLUDE_DIRS "${GDAL_INCLUDE_DIR}") + set(GDAL_LIBRARY GDAL::GDAL CACHE INTERNAL "") + set(GDAL_LIBRARIES "${GDAL_LIBRARY}") + unset(vcpkg_gdal_prefix) +endif() + +cmake_policy(POP) diff --git a/vcpkg/ports/gdal/vcpkg.json b/vcpkg/ports/gdal/vcpkg.json new file mode 100644 index 000000000000..de6ffcf7b194 --- /dev/null +++ b/vcpkg/ports/gdal/vcpkg.json @@ -0,0 +1,334 @@ +{ + "name": "gdal", + "version-semver": "3.8.4", + "description": "The Geographic Data Abstraction Library for reading and writing geospatial raster and vector data", + "homepage": "https://gdal.org", + "license": null, + "supports": "!uwp", + "dependencies": [ + "json-c", + "libgeotiff", + { + "name": "pkgconf", + "host": true + }, + { + "name": "proj", + "default-features": false, + "features": [ + "tiff" + ] + }, + { + "name": "tiff", + "default-features": false + }, + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + { + "name": "vcpkg-pkgconfig-get-modules", + "host": true + }, + "zlib" + ], + "default-features": [ + "default-features" + ], + "features": { + "python": { + "description": "Build python bindings", + "dependencies": [ + "python3", + { + "name": "swig", + "host": true + }, + { + "name": "py-setuptools", + "host": true + } + ] + }, + "aws-ec2-windows": { + "description": "Optimized detection of AWS EC2 Windows hosts", + "dependencies": [ + "atlmfc" + ] + }, + "cfitsio": { + "description": "Enable cfitsio support", + "dependencies": [ + "cfitsio" + ] + }, + "curl": { + "description": "Enable CURL network support", + "dependencies": [ + { + "name": "curl", + "default-features": false + } + ] + }, + "default-features": { + "description": "Default set of features, including recommended features", + "dependencies": [ + { + "name": "gdal", + "default-features": false, + "features": [ + "gif", + "iconv", + "libkml", + "libxml2", + "lzma", + "openjpeg", + "openssl", + "pcre2", + "recommended-features", + "webp", + "zstd" + ] + }, + { + "name": "gdal", + "default-features": false, + "features": [ + "libspatialite", + "postgresql" + ], + "platform": "!uwp" + }, + { + "name": "gdal", + "default-features": false, + "features": [ + "hdf5", + "netcdf" + ], + "platform": "!uwp & !(windows & arm64) & !android & !ios" + } + ] + }, + "expat": { + "description": "Use EXPAT library", + "dependencies": [ + "expat" + ] + }, + "freexl": { + "description": "Enable FREEXL support", + "dependencies": [ + "freexl" + ] + }, + "geos": { + "description": "Enable GEOS support", + "dependencies": [ + "geos" + ] + }, + "gif": { + "description": "Enable GIF support", + "dependencies": [ + "giflib" + ] + }, + "hdf5": { + "description": "Enable HDF5 support", + "dependencies": [ + { + "name": "hdf5", + "default-features": false, + "features": [ + "cpp" + ] + } + ] + }, + "iconv": { + "description": "Use iconv library", + "dependencies": [ + "libiconv" + ] + }, + "jpeg": { + "description": "Use JPEG compression library", + "dependencies": [ + "libjpeg-turbo" + ] + }, + "kea": { + "description": "Enable KEA driver", + "dependencies": [ + { + "name": "gdal", + "default-features": false, + "features": [ + "hdf5" + ] + }, + "kealib" + ] + }, + "lerc": { + "description": "Enable LERC support", + "dependencies": [ + "lerc" + ] + }, + "libkml": { + "description": "Enable the LibKML driver", + "dependencies": [ + "libkml" + ] + }, + "libspatialite": { + "description": "Create or update SpatiaLite databases using libspatialite", + "dependencies": [ + "libspatialite" + ] + }, + "libxml2": { + "description": "Use LibXML2 library", + "dependencies": [ + "libxml2" + ] + }, + "lzma": { + "description": "Use LZMA library", + "dependencies": [ + "liblzma" + ] + }, + "mysql-libmariadb": { + "description": "Add mysql support using libmariadb", + "dependencies": [ + "libmariadb" + ] + }, + "netcdf": { + "description": "Enable NetCDF support", + "dependencies": [ + { + "name": "netcdf-c", + "default-features": false + } + ] + }, + "openjpeg": { + "description": "Use OpenJPEG library", + "dependencies": [ + "openjpeg" + ] + }, + "openssl": { + "description": "Use OpenSSL library", + "dependencies": [ + "openssl" + ] + }, + "pcre2": { + "description": "Enable PCRE2 support for sqlite3", + "dependencies": [ + "pcre2" + ] + }, + "png": { + "description": "Use PNG compression library", + "dependencies": [ + "libpng" + ] + }, + "poppler": { + "description": "Enable PDF reading support via poppler", + "dependencies": [ + { + "name": "poppler", + "default-features": false, + "features": [ + "private-api" + ] + } + ] + }, + "postgresql": { + "description": "Enable PostgreSQL support", + "dependencies": [ + "libpq" + ] + }, + "qhull": { + "description": "Use QHULL library", + "dependencies": [ + "qhull" + ] + }, + "recommended-features": { + "description": "Features that are explicity marked as recommended by GDAL.", + "dependencies": [ + { + "name": "gdal", + "default-features": false, + "features": [ + "curl", + "expat", + "geos", + "jpeg", + "lerc", + "png", + "qhull", + "sqlite3" + ] + } + ] + }, + "sqlite3": { + "description": "Enable SQLite3 support", + "dependencies": [ + { + "name": "sqlite3", + "features": [ + "rtree" + ] + } + ] + }, + "supported-default-features": { + "description": "This feature is an alias for default-features. It is retained for compatibility.", + "dependencies": [ + { + "name": "gdal", + "features": [ + "default-features" + ] + } + ] + }, + "system-libraries": { + "$supports": "!windows", + "description": "This feature does nothing. It is retained for compatibility." + }, + "tools": { + "description": "Builds gdal and ogr executables" + }, + "webp": { + "description": "Enable WEBP support", + "dependencies": [ + "libwebp" + ] + }, + "zstd": { + "description": "Use ZSTD library", + "dependencies": [ + "zstd" + ] + } + } +} diff --git a/vcpkg/ports/py-qscintilla/fix-static.patch b/vcpkg/ports/py-qscintilla/fix-static.patch new file mode 100644 index 000000000000..ab1cf546d0fc --- /dev/null +++ b/vcpkg/ports/py-qscintilla/fix-static.patch @@ -0,0 +1,29 @@ +diff --git a/src/qscintilla.pro b/src/qscintilla.pro +index 8d0acd2..2246442 100644 +--- a/src/qscintilla.pro ++++ b/src/qscintilla.pro +@@ -37,13 +37,13 @@ CONFIG(debug, debug|release) { + TARGET = qscintilla2_qt$${QT_MAJOR_VERSION} + } + +-macx:!CONFIG(staticlib) { ++macx:!CONFIG(static) { + QMAKE_POST_LINK += install_name_tool -id @rpath/$(TARGET1) $(TARGET) + } + + INCLUDEPATH += . ../scintilla/include ../scintilla/lexlib ../scintilla/src + +-!CONFIG(staticlib) { ++!CONFIG(static) { + DEFINES += QSCINTILLA_MAKE_DLL + + # Comment this in to build a dynamic library supporting multiple +@@ -86,7 +86,7 @@ qsci.files = ../qsci + INSTALLS += qsci + + features.path = $$[QT_HOST_DATA]/mkspecs/features +-CONFIG(staticlib) { ++CONFIG(static) { + features.files = $$PWD/features_staticlib/qscintilla2.prf + } else { + features.files = $$PWD/features/qscintilla2.prf diff --git a/vcpkg/ports/py-qscintilla/portfile.cmake b/vcpkg/ports/py-qscintilla/portfile.cmake new file mode 100644 index 000000000000..7c2ec76ab54b --- /dev/null +++ b/vcpkg/ports/py-qscintilla/portfile.cmake @@ -0,0 +1,62 @@ +vcpkg_download_distfile(ARCHIVE + URLS "https://www.riverbankcomputing.com/static/Downloads/QScintilla/${VERSION}/QScintilla_src-${VERSION}.tar.gz" + FILENAME "QScintilla-${VERSION}.tar.gz" + SHA512 19e2f9e0a14947501c575018df368d24eb7f8c74e74faa5246db36415bf28dc0beee507ed0e73107c02b36a99bbaf55f0ef3349f479d2332e1b92b2c4a32788a +) + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE ${ARCHIVE} + PATCHES + fix-static.patch +) + +file(RENAME "${SOURCE_PATH}/Python/pyproject-qt5.toml" "${SOURCE_PATH}/Python/pyproject.toml") + +set(SIPBUILD_ARGS + "--qmake" "${CURRENT_INSTALLED_DIR}/tools/Qt6/bin/qmake${VCPKG_HOST_EXECUTABLE_SUFFIX}" + "--api-dir" "${CURRENT_PACKAGES_DIR}/share/Qt6/qsci/api/python" + "--qsci-features-dir" "${SOURCE_PATH}/src/features" + "--qsci-include-dir" "${SITE_PACKAGES}/src" + "--qsci-library-dir" "${SOURCE_PATH}/src" + "--no-make" + "--verbose" + "--build-dir" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" + "--target-dir" "${CURRENT_INSTALLED_DIR}/tools/python3/Lib/site-packages/" +) + +# TODO: help it find sip include dirs, manually patched into sipbuild/project.py for now +# "--sip-include-dirs" "${CURRENT_INSTALLED_DIR}/tools/python3/Lib/site-packages/" + +vcpkg_backup_env_variables(VARS PATH) + +vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/tools/python3/Scripts/") + +message(STATUS "Running sipbuild...") +vcpkg_execute_required_process( + COMMAND "${PYTHON3}" "-m" "sipbuild.tools.build" ${SIPBUILD_ARGS} + WORKING_DIRECTORY "${SOURCE_PATH}/Python" + LOGNAME "sipbuild-${TARGET_TRIPLET}" +) +message(STATUS "Running sipbuild...finished.") + +# inventory.txt is consumed by the distinfo tool which is run during make and should be run against the package directory +file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR) +vcpkg_replace_string("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/inventory.txt" + "${CURRENT_INSTALLED_DIR}" + "${CURRENT_PACKAGES_DIR}") + vcpkg_replace_string("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/inventory.txt" + "${NATIVE_INSTALLED_DIR}" + "${CURRENT_PACKAGES_DIR}") + +vcpkg_qmake_build(SKIP_MAKEFILE BUILD_LOGNAME "install" TARGETS "install") + +vcpkg_restore_env_variables(VARS PATH) + +vcpkg_python_test_import(MODULE "PyQt6.Qsci") + +vcpkg_copy_pdbs() + + +# Handle copyright +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/vcpkg/ports/py-qscintilla/vcpkg.json b/vcpkg/ports/py-qscintilla/vcpkg.json new file mode 100644 index 000000000000..f83167b9637b --- /dev/null +++ b/vcpkg/ports/py-qscintilla/vcpkg.json @@ -0,0 +1,22 @@ +{ + "name": "py-qscintilla", + "version": "2.14.1", + "description": "Python bindings for QScintilla, which is a port to Qt of the Scintilla editing component. Features syntax highlighting, code-completion and much more (Barebone build without python bindings (missing dependeny PyQt) and without QtDesigner plugin)", + "homepage": "https://www.riverbankcomputing.com/software/qscintilla", + "license": "GPL-3.0-or-later", + "supports": "!xbox", + "dependencies": [ + { + "name": "qscintilla" + }, + "py-pyqt6", + { + "name": "vcpkg-python-scripts", + "host": true + }, + { + "name": "vcpkg-qmake", + "host": true + } + ] +} diff --git a/vcpkg/ports/swig/portfile.cmake b/vcpkg/ports/swig/portfile.cmake new file mode 100644 index 000000000000..d19d1a35df91 --- /dev/null +++ b/vcpkg/ports/swig/portfile.cmake @@ -0,0 +1,30 @@ +set(VCPKG_BUILD_TYPE release) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO swig/swig + REF "v${VERSION}" + SHA512 5d653333f73356d4d5ba8b615882e49f33f188bc68d8204352116bc4aca7946ec01ce2e02524c5ce805b98c2219ed05e664120485bf18095c5c0785436487074 + HEAD_REF master +) + +vcpkg_find_acquire_program(BISON) + +list(APPEND OPTIONS "-D BISON_EXECUTABLE=${BISON}") + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${OPTIONS} +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_fixup_pkgconfig() + +vcpkg_copy_tools(TOOL_NAMES swig) +file(COPY "${CURRENT_PACKAGES_DIR}/bin/" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/swig") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) \ No newline at end of file diff --git a/vcpkg/ports/swig/vcpkg.json b/vcpkg/ports/swig/vcpkg.json new file mode 100644 index 000000000000..5190cf6f8771 --- /dev/null +++ b/vcpkg/ports/swig/vcpkg.json @@ -0,0 +1,19 @@ +{ + "name": "swig", + "version": "4.2.1", + "description": "SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.", + "homepage": "http://www.swig.org/", + "dependencies": + [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + }, + "pcre2" + ] +} + \ No newline at end of file diff --git a/vcpkg/triplets/x64-windows-release.cmake b/vcpkg/triplets/x64-windows-release.cmake new file mode 100644 index 000000000000..755d34d877c9 --- /dev/null +++ b/vcpkg/triplets/x64-windows-release.cmake @@ -0,0 +1,5 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE dynamic) + +set(VCPKG_BUILD_TYPE release) \ No newline at end of file diff --git a/vcpkg/vcpkg.json b/vcpkg/vcpkg.json new file mode 100644 index 000000000000..f3baf6677e28 --- /dev/null +++ b/vcpkg/vcpkg.json @@ -0,0 +1,133 @@ +{ + "vcpkg-configuration": { + "default-registry": { + "kind": "git", + "baseline": "04b0cf2b3fd1752d3c3db969cbc10ba0a4613cee", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "git", + "baseline": "1b757963f749da01b93a3cdfee29b91a7ac3a862", + "repository": "https://github.com/open-vcpkg/python-registry", + "packages": [ + "python3", + "py-*", + "vcpkg-python-scripts" + ] + } + ], + "overlay-ports": [ + "ports" + ], + "overlay-triplets": [ + "triplets" + ] + }, + "name": "qgis", + "version-string": "current", + "description": "QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)", + "homepage": "https://qgis.org", + "dependencies": [ + { + "name": "exiv2", + "features": [ + "xmp" + ] + }, + "expat", + { + "name": "gdal", + "default-features": false, + "features": [ + "poppler" + ] + }, + "geos", + "gsl", + "jhasse-poly2tri", + "libpq", + "libspatialindex", + "libspatialite", + { + "name": "libtasn1", + "platform": "ios | osx" + }, + "libxml2", + "libzip", + "pdal", + "proj", + "protobuf", + { + "name": "qca", + "features": [ + "ossl" + ] + }, + "qtbase", + "qtkeychain-qt6", + "qtlocation", + "qtsvg", + "qttools", + "zlib" + ], + "features": { + "3d": { + "description": "Determines whether QGIS 3D library should be built", + "dependencies": [ + "qt3d" + ] + }, + "bindings": { + "description": "Determines whether Python bindings should be built", + "dependencies": [ + { + "name": "gdal", + "features": [ + "python" + ] + }, + "py-pip", + "py-pyqt6", + "py-qscintilla", + "python3" + ] + }, + "customwidgets": { + "description": "Determines whether the QGIS custom widgets for QtCreator should be built" + }, + "desktop": { + "description": "Determines whether the QGIS desktop (main app) should be built" + }, + "gui": { + "description": "Determines whether the QGIS gui should be built", + "dependencies": [ + "qscintilla", + "qtmultimedia", + "qwt" + ] + }, + "opencl": { + "description": "Should OpenCL support be added", + "dependencies": [ + "opencl" + ] + }, + "process": { + "description": "Determines whether the command line QGIS process tool should be built" + }, + "quick": { + "description": "Build the QGIS quick components for mobile interfaces", + "dependencies": [ + "qtdeclarative", + "qtquickcontrols2" + ] + }, + "server": { + "description": "Determines whether QGIS server should be built", + "dependencies": [ + "fastcgi" + ] + } + } +} From 14e67117fb696c8d3acdf88b3899bd000732a9e0 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 3 May 2024 08:56:17 +0200 Subject: [PATCH 02/43] use sip build --- .github/workflows/windows-qt6.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index c5fcd9101bdd..8555e05bfd64 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -58,6 +58,9 @@ jobs: -D USE_CCACHE=ON \ -D FLEX_EXECUTABLE="${VCPKG_ROOT}\downloads\tools\win_bison\2.5.25\win_flex.exe" \ -D BISON_EXECUTABLE="${VCPKG_ROOT}\downloads\tools\win_bison\2.5.25\win_bison.exe" \ + -D SIP_BUILD_EXECUTABLE="${BUILD_DIR}\vcpkg_installed\x64-windows\tools\python3\Scripts\sip-build.exe" \ + -D PYUIC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows\tools\python3\pyuic5.bat" \ + -D PYRCC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows\tools\python3\pyrcc5.bat" \ -D WITH_QTWEBKIT=OFF \ -D VCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/src" \ -D NUGET_USERNAME=m-kuhn \ From a60d91bbe21ea2dd809afe8223d47cb3c607113e Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 3 May 2024 10:19:06 +0200 Subject: [PATCH 03/43] Port native updates --- src/native/CMakeLists.txt | 2 +- src/native/win/qgswinnative.cpp | 24 +++++++++++++++++++++++- src/native/win/qgswinnative.h | 14 +++++++++++--- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/native/CMakeLists.txt b/src/native/CMakeLists.txt index cedc517814a1..73edb952b1ad 100644 --- a/src/native/CMakeLists.txt +++ b/src/native/CMakeLists.txt @@ -144,7 +144,7 @@ if (UNIX AND NOT APPLE AND NOT ANDROID) target_link_libraries(qgis_native ${QT_VERSION_BASE}::DBus) endif() -if (MSVC) +if (MSVC AND NOT BUILD_WITH_QT6) find_package(${QT_VERSION_BASE}WinExtras) target_link_libraries(qgis_native shell32) diff --git a/src/native/win/qgswinnative.cpp b/src/native/win/qgswinnative.cpp index 008c207a35aa..dbc83f6819b2 100644 --- a/src/native/win/qgswinnative.cpp +++ b/src/native/win/qgswinnative.cpp @@ -23,16 +23,24 @@ #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #include #include #include #include +#endif #include "wintoastlib.h" #include #include #include +#ifdef UNICODE +#define _T(x) L##x +#else +#define _T(x) x +#endif + struct LPITEMIDLISTDeleter { @@ -57,6 +65,7 @@ void QgsWinNative::initializeMainWindow( QWindow *window, const QString &version ) { mWindow = window; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if ( mTaskButton ) return; // already initialized! @@ -64,6 +73,7 @@ void QgsWinNative::initializeMainWindow( QWindow *window, mTaskButton->setWindow( window ); mTaskProgress = mTaskButton->progress(); mTaskProgress->setVisible( false ); +#endif QString appName = qgetenv( "QGIS_WIN_APP_NAME" ); if ( appName.isEmpty() ) @@ -126,7 +136,7 @@ void QgsWinNative::showFileProperties( const QString &path ) info.nShow = SW_SHOWNORMAL; info.fMask = SEE_MASK_INVOKEIDLIST; info.lpIDList = pidl.get(); - info.lpVerb = "properties"; + info.lpVerb = _T( "properties" ); ShellExecuteEx( &info ); } @@ -134,24 +144,31 @@ void QgsWinNative::showFileProperties( const QString &path ) void QgsWinNative::showUndefinedApplicationProgress() { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) mTaskProgress->setMaximum( 0 ); mTaskProgress->show(); +#endif } void QgsWinNative::setApplicationProgress( double progress ) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) mTaskProgress->setMaximum( 100 ); mTaskProgress->show(); mTaskProgress->setValue( static_cast< int >( std::round( progress ) ) ); +#endif } void QgsWinNative::hideApplicationProgress() { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) mTaskProgress->hide(); +#endif } void QgsWinNative::onRecentProjectsChanged( const std::vector &recentProjects ) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWinJumpList jumplist; jumplist.recent()->clear(); for ( const RecentProjectProperties &recentProject : recentProjects ) @@ -163,6 +180,7 @@ void QgsWinNative::onRecentProjectsChanged( const std::vectorsetArguments( QStringList( recentProject.path ) ); jumplist.recent()->addItem( newProject ); } +#endif } class NotificationHandler : public WinToastLib::IWinToastHandler @@ -228,7 +246,11 @@ bool QgsWinNative::openTerminalAtPath( const QString &path ) return process.startDetached( &pid ); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool QgsWinNativeEventFilter::nativeEventFilter( const QByteArray &eventType, void *message, long * ) +#else +bool QgsWinNativeEventFilter::nativeEventFilter( const QByteArray &eventType, void *message, qintptr * ) +#endif { static const QByteArray sWindowsGenericMSG{ "windows_generic_MSG" }; if ( !message || eventType != sWindowsGenericMSG ) diff --git a/src/native/win/qgswinnative.h b/src/native/win/qgswinnative.h index 9f0e7479d144..c67902998128 100644 --- a/src/native/win/qgswinnative.h +++ b/src/native/win/qgswinnative.h @@ -15,8 +15,8 @@ * * ***************************************************************************/ -#ifndef QGSMACNATIVE_H -#define QGSMACNATIVE_H +#ifndef QGSWINNATIVE_H +#define QGSWINNATIVE_H #include "qgsnative.h" #include @@ -25,8 +25,10 @@ #include #pragma comment(lib,"Shell32.lib") +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) class QWinTaskbarButton; class QWinTaskbarProgress; +#endif class QWindow; @@ -35,7 +37,11 @@ class QgsWinNativeEventFilter : public QObject, public QAbstractNativeEventFilte Q_OBJECT public: +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool nativeEventFilter( const QByteArray &eventType, void *message, long * ) override; +#else + bool nativeEventFilter( const QByteArray &eventType, void *message, qintptr *result ) override; +#endif signals: @@ -70,10 +76,12 @@ class NATIVE_EXPORT QgsWinNative : public QgsNative QWindow *mWindow = nullptr; Capabilities mCapabilities = NativeFilePropertiesDialog | NativeOpenTerminalAtPath; bool mWinToastInitialized = false; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWinTaskbarButton *mTaskButton = nullptr; QWinTaskbarProgress *mTaskProgress = nullptr; +#endif QgsWinNativeEventFilter *mNativeEventFilter = nullptr; }; -#endif // QGSMACNATIVE_H +#endif // QGSWINNATIVE_H From 0f3e07d63dd72e83b82e41a99bc1fedea9155399 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 3 May 2024 12:04:45 +0200 Subject: [PATCH 04/43] Install flex/bison --- .github/workflows/windows-qt6.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 8555e05bfd64..13a37d912f1e 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -37,7 +37,15 @@ jobs: - name: Setup vcpkg uses: ./.github/actions/setup-vcpkg - + + - name: Setup flex/bison + uses: robinraju/release-downloader@v1.10 + with: + repository: 'lexxmark/winflexbison' + fileName: '*.zip' + tag: 'v2.5.25' + extract: true + - name: 🌱 Install dependencies and generate project files shell: bash run: | @@ -56,8 +64,8 @@ jobs: -D ENABLE_TESTS=OFF \ -D BUILD_WITH_QT6=ON \ -D USE_CCACHE=ON \ - -D FLEX_EXECUTABLE="${VCPKG_ROOT}\downloads\tools\win_bison\2.5.25\win_flex.exe" \ - -D BISON_EXECUTABLE="${VCPKG_ROOT}\downloads\tools\win_bison\2.5.25\win_bison.exe" \ + -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\tools\python3\Scripts\sip-build.exe" \ -D PYUIC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows\tools\python3\pyuic5.bat" \ -D PYRCC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows\tools\python3\pyrcc5.bat" \ From ea0712fd9caf2af87cfa465be13d5ef2f00719cf Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 3 May 2024 12:50:40 +0200 Subject: [PATCH 05/43] Wchar --- src/app/CMakeLists.txt | 6 +- src/app/mainwin.cpp | 86 ++++++++--------- src/app/mainwinqt5.cpp | 215 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 263 insertions(+), 44 deletions(-) create mode 100644 src/app/mainwinqt5.cpp diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index e9847f5041b6..37da28d52807 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -448,7 +448,11 @@ set(TEST_RCCS ../../tests/testdata/testdata.qrc) if (WIN32) set (QGIS_APP_SRCS ${QGIS_APP_SRCS} main.cpp ${TEST_RCCS}) - set (QGIS_APPMAIN_SRCS mainwin.cpp) + if(BUILD_WITH_QT6) + set (QGIS_APPMAIN_SRCS mainwin.cpp) + else() + set (QGIS_APPMAIN_SRCS mainwinqt5.cpp) + endif() if (NOT MSVC) enable_language(RC) set(CMAKE_RC_COMPILER_INIT ${CMAKE_GENERATOR_RC}) diff --git a/src/app/mainwin.cpp b/src/app/mainwin.cpp index c90ef7cc88f4..1cb76b18a380 100644 --- a/src/app/mainwin.cpp +++ b/src/app/mainwin.cpp @@ -21,55 +21,55 @@ #include #include -void showError( std::string message, std::string title ) +void showError( std::wstring message, std::wstring title ) { - std::string newmessage = "Oops, looks like an error loading QGIS \n\n Details: \n\n" + message; - MessageBox( + std::wstring newmessage = L"Oops, looks like an error loading QGIS \n\n Details: \n\n" + message; + MessageBoxW( NULL, newmessage.c_str(), title.c_str(), MB_ICONERROR | MB_OK ); - std::cerr << message << std::endl; + std::wcerr << message << std::endl; } -std::string moduleExeBaseName( void ) +std::wstring moduleExeBaseName( void ) { DWORD l = MAX_PATH; - std::unique_ptr filepath; + std::unique_ptr filepath; for ( ;; ) { - filepath.reset( new char[l] ); - if ( GetModuleFileName( nullptr, filepath.get(), l ) < l ) + filepath.reset( new WCHAR[l] ); + if ( GetModuleFileNameW( nullptr, filepath.get(), l ) < l ) break; l += MAX_PATH; } - std::string basename( filepath.get() ); + std::wstring basename( filepath.get() ); return basename; } int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/ ) { - std::string exename( moduleExeBaseName() ); - std::string basename( exename.substr( 0, exename.size() - 4 ) ); + std::wstring exename( moduleExeBaseName() ); + std::wstring basename( exename.substr( 0, exename.size() - 4 ) ); if ( getenv( "OSGEO4W_ROOT" ) && __argc == 2 && strcmp( __argv[1], "--postinstall" ) == 0 ) { - std::string envfile( basename + ".env" ); + std::wstring envfile( basename + L".env" ); // write or update environment file - if ( _access( envfile.c_str(), 0 ) < 0 || _access( envfile.c_str(), 2 ) == 0 ) + if ( _waccess( envfile.c_str(), 0 ) < 0 || _waccess( envfile.c_str(), 2 ) == 0 ) { - std::list vars; + std::list vars; try { - std::ifstream varfile; - varfile.open( basename + ".vars" ); + std::wifstream varfile; + varfile.open( basename + L".vars" ); - std::string var; + std::wstring var; while ( std::getline( varfile, var ) ) { vars.push_back( var ); @@ -77,28 +77,28 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST varfile.close(); } - catch ( std::ifstream::failure &e ) + catch ( std::wifstream::failure &e ) { - std::string message = "Could not read environment variable list " + basename + ".vars" + " [" + e.what() + "]"; - showError( message, "Error loading QGIS" ); + std::wstring message = L"Could not read environment variable list " + basename + L".vars" + L" [" + _wcserror( errno ) + L"]"; + showError( message, L"Error loading QGIS" ); return EXIT_FAILURE; } try { - std::ofstream file; - file.open( envfile, std::ifstream::out ); + std::wofstream file; + file.open( envfile, std::wifstream::out ); - for ( std::list::const_iterator it = vars.begin(); it != vars.end(); ++it ) + for ( std::list::const_iterator it = vars.begin(); it != vars.end(); ++it ) { - if ( getenv( it->c_str() ) ) - file << *it << "=" << getenv( it->c_str() ) << std::endl; + if ( _wgetenv( it->c_str() ) ) + file << *it << "=" << _wgetenv( it->c_str() ) << std::endl; } } - catch ( std::ifstream::failure &e ) + catch ( std::wifstream::failure &e ) { - std::string message = "Could not write environment file " + basename + ".env" + " [" + e.what() + "]"; - showError( message, "Error loading QGIS" ); + std::wstring message = L"Could not write environment file " + basename + L".env" + L" [" + _wcserror( errno ) + L"]"; + showError( message, L"Error loading QGIS" ); return EXIT_FAILURE; } } @@ -108,31 +108,31 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST try { - std::ifstream file; - file.open( basename + ".env" ); + std::wifstream file; + file.open( basename + L".env" ); - std::string var; + std::wstring var; while ( std::getline( file, var ) ) { - if ( _putenv( var.c_str() ) < 0 ) + if ( _wputenv( var.c_str() ) < 0 ) { - std::string message = "Could not set environment variable:" + var; - showError( message, "Error loading QGIS" ); + std::wstring message = L"Could not set environment variable:" + var; + showError( message, L"Error loading QGIS" ); return EXIT_FAILURE; } } } - catch ( std::ifstream::failure &e ) + catch ( std::wifstream::failure &e ) { - std::string message = "Could not read environment file " + basename + ".env" + " [" + e.what() + "]"; - showError( message, "Error loading QGIS" ); + std::wstring message = L"Could not read environment file " + basename + L".env" + L" [" + _wcserror( errno ) + L"]"; + showError( message, L"Error loading QGIS" ); return EXIT_FAILURE; } #ifndef _MSC_VER // MinGW #pragma GCC diagnostic ignored "-Wcast-function-type" #endif - HINSTANCE hKernelDLL = LoadLibrary( "kernel32.dll" ); + HINSTANCE hKernelDLL = LoadLibraryW( L"kernel32.dll" ); BOOL ( *SetDefaultDllDirectories )( DWORD ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "SetDefaultDllDirectories" ) ) : 0; DLL_DIRECTORY_COOKIE( *AddDllDirectory )( PCWSTR ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "AddDllDirectory" ) ) : 0; #ifndef _MSC_VER // MinGW @@ -168,7 +168,7 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST #ifdef _MSC_VER - HINSTANCE hGetProcIDDLL = LoadLibrary( "qgis_app.dll" ); + HINSTANCE hGetProcIDDLL = LoadLibraryW( L"qgis_app.dll" ); #else // MinGW HINSTANCE hGetProcIDDLL = LoadLibrary( "libqgis_app.dll" ); @@ -188,9 +188,9 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST 0, NULL ); - std::string message = "Could not load qgis_app.dll \n Windows Error: " + std::string( errorText ) - + "\n Help: \n\n Check " + basename + ".env for correct environment paths"; - showError( message, "Error loading QGIS" ); + std::wstring message = L"Could not load qgis_app.dll \n Windows Error: " + std::wstring( errorText ) + + L"\n Help: \n\n Check " + basename + L".env for correct environment paths"; + showError( message, L"Error loading QGIS" ); LocalFree( errorText ); errorText = NULL; @@ -207,7 +207,7 @@ int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPST if ( !realmain ) { - showError( "Could not locate main function in qgis_app.dll", "Error loading QGIS" ); + showError( L"Could not locate main function in qgis_app.dll", L"Error loading QGIS" ); return EXIT_FAILURE; } diff --git a/src/app/mainwinqt5.cpp b/src/app/mainwinqt5.cpp new file mode 100644 index 000000000000..c90ef7cc88f4 --- /dev/null +++ b/src/app/mainwinqt5.cpp @@ -0,0 +1,215 @@ +/*************************************************************************** + mainwin.cpp + --------------------- + begin : February 2017 + copyright : (C) 2017 by Juergen E. Fischer + email : jef at norbit dot de + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include +#include + +#include +#include +#include +#include +#include + +void showError( std::string message, std::string title ) +{ + std::string newmessage = "Oops, looks like an error loading QGIS \n\n Details: \n\n" + message; + MessageBox( + NULL, + newmessage.c_str(), + title.c_str(), + MB_ICONERROR | MB_OK + ); + std::cerr << message << std::endl; +} + +std::string moduleExeBaseName( void ) +{ + DWORD l = MAX_PATH; + std::unique_ptr filepath; + for ( ;; ) + { + filepath.reset( new char[l] ); + if ( GetModuleFileName( nullptr, filepath.get(), l ) < l ) + break; + + l += MAX_PATH; + } + + std::string basename( filepath.get() ); + return basename; +} + +int CALLBACK WinMain( HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/ ) +{ + std::string exename( moduleExeBaseName() ); + std::string basename( exename.substr( 0, exename.size() - 4 ) ); + + if ( getenv( "OSGEO4W_ROOT" ) && __argc == 2 && strcmp( __argv[1], "--postinstall" ) == 0 ) + { + std::string envfile( basename + ".env" ); + + // write or update environment file + if ( _access( envfile.c_str(), 0 ) < 0 || _access( envfile.c_str(), 2 ) == 0 ) + { + std::list vars; + + try + { + std::ifstream varfile; + varfile.open( basename + ".vars" ); + + std::string var; + while ( std::getline( varfile, var ) ) + { + vars.push_back( var ); + } + + varfile.close(); + } + catch ( std::ifstream::failure &e ) + { + std::string message = "Could not read environment variable list " + basename + ".vars" + " [" + e.what() + "]"; + showError( message, "Error loading QGIS" ); + return EXIT_FAILURE; + } + + try + { + std::ofstream file; + file.open( envfile, std::ifstream::out ); + + for ( std::list::const_iterator it = vars.begin(); it != vars.end(); ++it ) + { + if ( getenv( it->c_str() ) ) + file << *it << "=" << getenv( it->c_str() ) << std::endl; + } + } + catch ( std::ifstream::failure &e ) + { + std::string message = "Could not write environment file " + basename + ".env" + " [" + e.what() + "]"; + showError( message, "Error loading QGIS" ); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; + } + + try + { + std::ifstream file; + file.open( basename + ".env" ); + + std::string var; + while ( std::getline( file, var ) ) + { + if ( _putenv( var.c_str() ) < 0 ) + { + std::string message = "Could not set environment variable:" + var; + showError( message, "Error loading QGIS" ); + return EXIT_FAILURE; + } + } + } + catch ( std::ifstream::failure &e ) + { + std::string message = "Could not read environment file " + basename + ".env" + " [" + e.what() + "]"; + showError( message, "Error loading QGIS" ); + return EXIT_FAILURE; + } + +#ifndef _MSC_VER // MinGW +#pragma GCC diagnostic ignored "-Wcast-function-type" +#endif + HINSTANCE hKernelDLL = LoadLibrary( "kernel32.dll" ); + BOOL ( *SetDefaultDllDirectories )( DWORD ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "SetDefaultDllDirectories" ) ) : 0; + DLL_DIRECTORY_COOKIE( *AddDllDirectory )( PCWSTR ) = hKernelDLL ? reinterpret_cast( GetProcAddress( hKernelDLL, "AddDllDirectory" ) ) : 0; +#ifndef _MSC_VER // MinGW +#pragma GCC diagnostic pop +#endif + + if ( SetDefaultDllDirectories && AddDllDirectory ) + { + SetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS ); + + wchar_t windir[MAX_PATH]; + GetWindowsDirectoryW( windir, MAX_PATH ); + wchar_t systemdir[MAX_PATH]; + GetSystemDirectoryW( systemdir, MAX_PATH ); + + wchar_t *path = wcsdup( _wgetenv( L"PATH" ) ); + +#ifdef _UCRT + for ( wchar_t *p = wcstok( path, L";", nullptr ); p; p = wcstok( NULL, L";", nullptr ) ) +#else + for ( wchar_t *p = wcstok( path, L";" ); p; p = wcstok( NULL, L";" ) ) +#endif + { + if ( wcsicmp( p, windir ) == 0 ) + continue; + if ( wcsicmp( p, systemdir ) == 0 ) + continue; + AddDllDirectory( p ); + } + + free( path ); + } + + +#ifdef _MSC_VER + HINSTANCE hGetProcIDDLL = LoadLibrary( "qgis_app.dll" ); +#else +// MinGW + HINSTANCE hGetProcIDDLL = LoadLibrary( "libqgis_app.dll" ); +#endif + + if ( !hGetProcIDDLL ) + { + DWORD error = GetLastError(); + LPTSTR errorText = NULL; + + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + error, + MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), + ( LPTSTR )&errorText, + 0, + NULL ); + + std::string message = "Could not load qgis_app.dll \n Windows Error: " + std::string( errorText ) + + "\n Help: \n\n Check " + basename + ".env for correct environment paths"; + showError( message, "Error loading QGIS" ); + + LocalFree( errorText ); + errorText = NULL; + return EXIT_FAILURE; + } + +#ifndef _MSC_VER // MinGW +#pragma GCC diagnostic ignored "-Wcast-function-type" +#endif + int ( *realmain )( int, char *[] ) = ( int ( * )( int, char *[] ) ) GetProcAddress( hGetProcIDDLL, "main" ); +#ifndef _MSC_VER // MinGW +#pragma GCC diagnostic pop +#endif + + if ( !realmain ) + { + showError( "Could not locate main function in qgis_app.dll", "Error loading QGIS" ); + return EXIT_FAILURE; + } + + return realmain( __argc, __argv ); +} From a58ffde420723b589b6eb4aefa938bf830b6451d Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 3 May 2024 17:14:04 +0200 Subject: [PATCH 06/43] Vendored dep fixes --- external/mdal/frmts/mdal_h2i.cpp | 2 +- external/mdal/mdal_utils.cpp | 14 ++++++++------ external/nmea/parse.c | 6 +++--- external/nmea/sentence.h | 2 +- external/qspatialite/CMakeLists.txt | 14 +++++++------- external/qspatialite/qsql_spatialite.cpp | 2 +- external/untwine/api/QgisUntwine_win.cpp | 2 +- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/external/mdal/frmts/mdal_h2i.cpp b/external/mdal/frmts/mdal_h2i.cpp index 0b2ca0f33dbb..be5b2b6834ad 100644 --- a/external/mdal/frmts/mdal_h2i.cpp +++ b/external/mdal/frmts/mdal_h2i.cpp @@ -137,7 +137,7 @@ bool MDAL::DriverH2i::parseJsonFile( const std::string filePath, MetadataH2i &me metadata.dirPath = MDAL::dirName( filePath ); } - catch ( Json::exception &e ) + catch ( Json::exception & ) { return false; } diff --git a/external/mdal/mdal_utils.cpp b/external/mdal/mdal_utils.cpp index efcbc1b6489a..4691f00b99a8 100644 --- a/external/mdal/mdal_utils.cpp +++ b/external/mdal/mdal_utils.cpp @@ -17,7 +17,9 @@ #include #ifdef _MSC_VER +#ifndef UNICODE #define UNICODE +#endif #include #include #include @@ -1113,12 +1115,12 @@ std::vector MDAL::Library::libraryFilesInDir( const std::string &di { std::vector filesList; #ifdef _WIN32 - WIN32_FIND_DATA data; + WIN32_FIND_DATAA data; HANDLE hFind; std::string pattern = dirPath; pattern.push_back( '*' ); - hFind = FindFirstFile( pattern.c_str(), &data ); + hFind = FindFirstFileA( pattern.c_str(), &data ); if ( hFind == INVALID_HANDLE_VALUE ) return filesList; @@ -1129,7 +1131,7 @@ std::vector MDAL::Library::libraryFilesInDir( const std::string &di if ( !fileName.empty() && fileExtension( fileName ) == ".dll" ) filesList.push_back( fileName ); } - while ( FindNextFile( hFind, &data ) != 0 ); + while ( FindNextFileA( hFind, &data ) != 0 ); FindClose( hFind ); #else @@ -1140,8 +1142,8 @@ std::vector MDAL::Library::libraryFilesInDir( const std::string &di std::string fileName( de->d_name ); if ( !fileName.empty() ) { - std::string extentsion = fileExtension( fileName ); - if ( extentsion == ".so" || extentsion == ".dylib" ) + std::string extension = fileExtension( fileName ); + if ( extension == ".so" || extension == ".dylib" ) filesList.push_back( fileName ); } de = readdir( dir ); @@ -1160,7 +1162,7 @@ bool MDAL::Library::loadLibrary() #ifdef _WIN32 UINT uOldErrorMode = SetErrorMode( SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS ); - d->mLibrary = LoadLibrary( d->mLibraryFile.c_str() ); + d->mLibrary = LoadLibraryA( d->mLibraryFile.c_str() ); SetErrorMode( uOldErrorMode ); #else d->mLibrary = dlopen( d->mLibraryFile.c_str(), RTLD_LAZY ); diff --git a/external/nmea/parse.c b/external/nmea/parse.c index e137d2729852..a181f9a0ab5c 100644 --- a/external/nmea/parse.c +++ b/external/nmea/parse.c @@ -415,14 +415,14 @@ int nmea_parse_GPRMC( const char *buff, int buff_sz, nmeaGPRMC *pack ) nmea_trace_buff( buff, buff_sz ); nsen = nmea_scanf( buff, buff_sz, - "$G%CRMC,%s,%C,%f,%C,%f,%C,%f,%f,%2d%2d%2d,%f,%C,%C,%C*", + "$G%CRMC,%s,%C,%f,%C,%f,%C,%f,%f,%2d%2d%2d,%f,%C,%C*", &( type ), &( time_buff[0] ), &( pack->status ), &( pack->lat ), &( pack->ns ), &( pack->lon ), &( pack->ew ), &( pack->speed ), &( pack->direction ), &( pack->utc.day ), &( pack->utc.mon ), &( pack->utc.year ), - &( pack->declination ), &( pack->declin_ew ), &( pack->mode ), &( pack->navstatus ) ); + &( pack->declination ), &( pack->declin_ew ), &( pack->mode ) ); - if ( nsen < 14 || nsen > 16 ) + if ( nsen != 14 && nsen != 15 ) { nmea_error( "G?RMC parse error!" ); return 0; diff --git a/external/nmea/sentence.h b/external/nmea/sentence.h index d007a3cdc0d3..1ed707f40a38 100644 --- a/external/nmea/sentence.h +++ b/external/nmea/sentence.h @@ -118,7 +118,7 @@ typedef struct _nmeaGPRMC double declination; //!< Magnetic variation degrees (Easterly var. subtracts from true course) char declin_ew; //!< [E]ast or [W]est char mode; //!< Mode indicator of fix type (A = autonomous, D = differential, E = estimated, N = not valid, S = simulator) - char navstatus; //!< NMEA v4.1 - Navigation Status type (S = Safe, C = Caution, U = Unsafe, V = Navigational status not valid) + } nmeaGPRMC; /** diff --git a/external/qspatialite/CMakeLists.txt b/external/qspatialite/CMakeLists.txt index 33536dafe913..527f383303c7 100644 --- a/external/qspatialite/CMakeLists.txt +++ b/external/qspatialite/CMakeLists.txt @@ -7,18 +7,18 @@ add_definitions(-DQT_SHARED) include_directories(SYSTEM ${SQLITE3_INCLUDE_DIR} - ${Qt5Sql_PRIVATE_INCLUDE_DIRS} + ${${QT_VERSION_BASE}Sql_PRIVATE_INCLUDE_DIRS} ) -set(QSQLSPATIALITE_SRC qsql_spatialite.cpp smain.cpp) -QT5_WRAP_CPP(QSQLSPATIALITE_SRC qsql_spatialite.h smain.h) +set(QSQLSPATIALITE_SRC qsql_spatialite.cpp smain.cpp qsql_spatialite.h smain.h) add_library(qsqlspatialite SHARED ${QSQLSPATIALITE_SRC}) + target_link_libraries(qsqlspatialite - ${Qt5Core_LIBRARIES} - ${Qt5Sql_LIBRARIES} - spatialite::spatialite - qgis_core + ${QT_VERSION_BASE}::Core + ${QT_VERSION_BASE}::Sql + spatialite::spatialite + qgis_core ) install(TARGETS qsqlspatialite diff --git a/external/qspatialite/qsql_spatialite.cpp b/external/qspatialite/qsql_spatialite.cpp index 0e8f15a25f76..5a75a04748b3 100644 --- a/external/qspatialite/qsql_spatialite.cpp +++ b/external/qspatialite/qsql_spatialite.cpp @@ -632,7 +632,7 @@ bool QSpatiaLiteDriver::open( const QString &db, const QString &, const QString bool openReadOnlyOption = false; bool openUriOption = false; - const auto opts = conOpts.splitRef( QLatin1Char( ';' ) ); + const auto opts = conOpts.split( QLatin1Char( ';' ) ); for ( auto option : opts ) { option = option.trimmed(); diff --git a/external/untwine/api/QgisUntwine_win.cpp b/external/untwine/api/QgisUntwine_win.cpp index 7469655df8f8..47d355ce3675 100644 --- a/external/untwine/api/QgisUntwine_win.cpp +++ b/external/untwine/api/QgisUntwine_win.cpp @@ -28,7 +28,7 @@ bool QgisUntwine::start(Options& options) cmdline += "--" + op.first + " \"" + op.second + "\" "; PROCESS_INFORMATION processInfo; - STARTUPINFO startupInfo; + STARTUPINFOA startupInfo; ZeroMemory(&processInfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&startupInfo, sizeof(STARTUPINFO)); From 07a23234ac2b2d275cb226e9ea9a8aa45bb4a781 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 3 May 2024 17:14:55 +0200 Subject: [PATCH 07/43] More bash --- .github/workflows/windows-qt6.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 13a37d912f1e..33020747bbe4 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -75,10 +75,12 @@ jobs: -D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} - name: 🌋 Build + shell: bash run: | cmake --build "${{ github.workspace }}/build" --config Release - name: 📦 Package + shell: bash run: | cmake --install "${{ github.workspace }}/build" --config Release From b77072d3b5c0a7f069eb11fb5d027afff6e8150f Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 3 May 2024 18:17:28 +0200 Subject: [PATCH 08/43] Fix paths --- .github/workflows/windows-qt6.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 33020747bbe4..e296bfc550b2 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -66,9 +66,9 @@ jobs: -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\tools\python3\Scripts\sip-build.exe" \ - -D PYUIC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows\tools\python3\pyuic5.bat" \ - -D PYRCC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows\tools\python3\pyrcc5.bat" \ + -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 WITH_QTWEBKIT=OFF \ -D VCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/src" \ -D NUGET_USERNAME=m-kuhn \ From 2fdef03e6cf90c76adeef5c12afe244a776afa5b Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 5 May 2024 20:05:27 +0200 Subject: [PATCH 09/43] Port QgsAttributeTableConfig fix --- src/core/qgsattributetableconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/qgsattributetableconfig.h b/src/core/qgsattributetableconfig.h index ba50862a3312..9daf64a74a2f 100644 --- a/src/core/qgsattributetableconfig.h +++ b/src/core/qgsattributetableconfig.h @@ -48,7 +48,7 @@ class CORE_EXPORT QgsAttributeTableConfig /** * Defines the configuration of a column in the attribute table. */ - struct ColumnConfig + struct CORE_EXPORT ColumnConfig { //! Constructor for ColumnConfig ColumnConfig() = default; From 39ced782668ea82439d97f2579d8e0d6e5d3dc92 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 5 May 2024 20:06:15 +0200 Subject: [PATCH 10/43] Fix QgsExpressionContext --- src/core/qgsexpressioncontext.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/qgsexpressioncontext.cpp b/src/core/qgsexpressioncontext.cpp index b05f99490a5e..8e0b9c2bcedd 100644 --- a/src/core/qgsexpressioncontext.cpp +++ b/src/core/qgsexpressioncontext.cpp @@ -106,7 +106,11 @@ void QgsExpressionContextScope::addVariable( const QgsExpressionContextScope::St bool QgsExpressionContextScope::removeVariable( const QString &name ) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return mVariables.remove( name ); +#else return mVariables.remove( name ) > 0; +#endif } bool QgsExpressionContextScope::hasVariable( const QString &name ) const From 6ab1edb0a71d5c0ffc7c4fd6aee55aa2a10eb151 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 6 May 2024 08:12:00 +0200 Subject: [PATCH 11/43] utf16 --- src/app/main.cpp | 8 ++++---- src/app/qgisapp.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 5cb8ee81e586..a71b31ecbfaa 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -177,9 +177,9 @@ void usage( const QString &appName ) << QStringLiteral( " the PostGIS extension\n" ) ; // OK #ifdef Q_OS_WIN - MessageBox( nullptr, - msg.join( QString() ).toLocal8Bit().constData(), - "QGIS command line options", + MessageBoxW( nullptr, + reinterpret_cast( msg.join( QString() ).utf16() ), + L"QGIS command line options", MB_OK ); #else std::cout << msg.join( QString() ).toLocal8Bit().constData(); @@ -219,7 +219,7 @@ void myPrint( const char *fmt, ... ) #if defined(Q_OS_WIN) char buffer[1024]; vsnprintf( buffer, sizeof buffer, fmt, ap ); - OutputDebugString( buffer ); + OutputDebugStringA( buffer ); #else vfprintf( stderr, fmt, ap ); #endif diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index c6856c998c8d..f7db2547b8e0 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -13054,7 +13054,7 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory ) CFRelease( urlRef ); #elif defined(Q_OS_WIN) if ( url.startsWith( "file://", Qt::CaseInsensitive ) ) - ShellExecute( 0, 0, url.mid( 7 ).toLocal8Bit().constData(), 0, 0, SW_SHOWNORMAL ); + ShellExecuteW( 0, 0, reinterpret_cast( url.mid( 7 ).utf16() ), 0, 0, SW_SHOWNORMAL ); else QDesktopServices::openUrl( url ); #else From 4260974e4a936823aea60d8eb264a0ce971f0d1a Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 6 May 2024 11:11:12 +0200 Subject: [PATCH 12/43] Bundle and ccache --- .github/workflows/windows-qt6.yml | 19 +++++++++++-- CMakeLists.txt | 34 +--------------------- cmake/Bundle.cmake | 47 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 cmake/Bundle.cmake diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index e296bfc550b2..db462a3a0b23 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -46,6 +46,9 @@ jobs: tag: 'v2.5.25' extract: true + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + - name: 🌱 Install dependencies and generate project files shell: bash run: | @@ -69,6 +72,8 @@ jobs: -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=m-kuhn \ @@ -82,7 +87,7 @@ jobs: - name: 📦 Package shell: bash run: | - cmake --install "${{ github.workspace }}/build" --config Release + cmake --build "${{ github.workspace }}/build" --target bundle --config Release - name: 📑 Upload dep build logs uses: actions/upload-artifact@v4 @@ -91,4 +96,14 @@ jobs: name: build-logs-x64-windows path: | C:/src/**/*.log - \ No newline at end of file + + - name: 📤 Upload bundle +# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' + uses: actions/upload-artifact@v4 + with: + name: qgis-windows-qt6 + path: | + build/*-win64.zip + + - uses: m-kuhn/action-tmate@patch-1 + if: always() diff --git a/CMakeLists.txt b/CMakeLists.txt index 88df603d44f5..5ef29f50ad5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1223,39 +1223,7 @@ 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 "info@qgis.org") - 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) endif() if (UNIX AND NOT APPLE) diff --git a/cmake/Bundle.cmake b/cmake/Bundle.cmake new file mode 100644 index 000000000000..a1ffffd26f4e --- /dev/null +++ b/cmake/Bundle.cmake @@ -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 "info@qgis.org") + set(CPACK_NSIS_MODIFY_PATH ON) +endif() + +if(CREATE_ZIP) + list(APPEND CPACK_GENERATOR "ZIP") +endif() + +include(CPack) From ffc6e54f81dcda64d19d750f5853222a47d85243 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 6 May 2024 16:37:44 +0200 Subject: [PATCH 13/43] Define bison output files --- src/core/CMakeLists.txt | 6 +++--- src/core/mesh/qgsmeshcalclexer.ll | 2 +- src/core/qgsexpressionlexer.ll | 2 +- src/core/qgsexpressionparser.yy | 2 +- src/core/qgssqlstatementlexer.ll | 2 +- src/core/qgssqlstatementparser.yy | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 070d417c746f..1b90558d5881 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,13 +1,13 @@ ############################################################ # sources -BISON_TARGET(QgsExpressionParser qgsexpressionparser.yy ${CMAKE_CURRENT_BINARY_DIR}/qgsexpressionparser.cpp COMPILE_FLAGS "-p exp_") +BISON_TARGET(QgsExpressionParser qgsexpressionparser.yy ${CMAKE_CURRENT_BINARY_DIR}/qgsexpressionparser.cpp COMPILE_FLAGS "-p exp_" DEFINES_FILE "${CMAKE_CURRENT_BINARY_DIR}/qgsexpressionparser.h") FLEX_TARGET(QgsExpressionLexer qgsexpressionlexer.ll ${CMAKE_CURRENT_BINARY_DIR}/qgsexpressionlexer.cpp) ADD_FLEX_BISON_DEPENDENCY(QgsExpressionLexer QgsExpressionParser) -BISON_TARGET(QgsSqlStatementParser qgssqlstatementparser.yy ${CMAKE_CURRENT_BINARY_DIR}/qgssqlstatementparser.cpp COMPILE_FLAGS "-p sqlstatement_") +BISON_TARGET(QgsSqlStatementParser qgssqlstatementparser.yy ${CMAKE_CURRENT_BINARY_DIR}/qgssqlstatementparser.cpp COMPILE_FLAGS "-p sqlstatement_" DEFINES_FILE "${CMAKE_CURRENT_BINARY_DIR}/qgssqlstatementparser.h") FLEX_TARGET(QgsSqlStatementLexer qgssqlstatementlexer.ll ${CMAKE_CURRENT_BINARY_DIR}/qgssqlstatementlexer.cpp) ADD_FLEX_BISON_DEPENDENCY(QgsSqlStatementLexer QgsSqlStatementParser) -BISON_TARGET(QgsMeshCalcParser mesh/qgsmeshcalcparser.yy ${CMAKE_CURRENT_BINARY_DIR}/qgsmeshcalcparser.cpp COMPILE_FLAGS "-p mesh_") +BISON_TARGET(QgsMeshCalcParser mesh/qgsmeshcalcparser.yy ${CMAKE_CURRENT_BINARY_DIR}/qgsmeshcalcparser.cpp COMPILE_FLAGS "-p mesh_" DEFINES_FILE "${CMAKE_CURRENT_BINARY_DIR}/qgsmeshcalcparser.h") FLEX_TARGET(QgsMeshCalcLexer mesh/qgsmeshcalclexer.ll ${CMAKE_CURRENT_BINARY_DIR}/qgsmeshcalclexer.cpp) ADD_FLEX_BISON_DEPENDENCY(QgsMeshCalcLexer QgsMeshCalcParser) diff --git a/src/core/mesh/qgsmeshcalclexer.ll b/src/core/mesh/qgsmeshcalclexer.ll index b764872176a6..a469cb586d45 100644 --- a/src/core/mesh/qgsmeshcalclexer.ll +++ b/src/core/mesh/qgsmeshcalclexer.ll @@ -27,7 +27,7 @@ %{ //directly included in the output program #include "qgsmeshcalcnode.h" - #include "qgsmeshcalcparser.hpp" + #include "qgsmeshcalcparser.h" // if not defined, searches for isatty() // which doesn't in MSVC compiler diff --git a/src/core/qgsexpressionlexer.ll b/src/core/qgsexpressionlexer.ll index d00ce9946aff..7e46463a7e23 100644 --- a/src/core/qgsexpressionlexer.ll +++ b/src/core/qgsexpressionlexer.ll @@ -37,7 +37,7 @@ #include "expression/qgsexpressionnodeimpl.h" #include "qgsexpressionfunction.h" struct expression_parser_context; -#include "qgsexpressionparser.hpp" +#include "qgsexpressionparser.h" #include // if not defined, searches for isatty() diff --git a/src/core/qgsexpressionparser.yy b/src/core/qgsexpressionparser.yy index 80a89b841397..199b81b27401 100644 --- a/src/core/qgsexpressionparser.yy +++ b/src/core/qgsexpressionparser.yy @@ -35,7 +35,7 @@ #define MAX_ERRORS 10 struct expression_parser_context; -#include "qgsexpressionparser.hpp" +#include "qgsexpressionparser.h" //! from lexer typedef void* yyscan_t; diff --git a/src/core/qgssqlstatementlexer.ll b/src/core/qgssqlstatementlexer.ll index f64fa47db9ba..73fccbc0abb1 100644 --- a/src/core/qgssqlstatementlexer.ll +++ b/src/core/qgssqlstatementlexer.ll @@ -31,7 +31,7 @@ #include "qgssqlstatement.h" struct sqlstatement_parser_context; -#include "qgssqlstatementparser.hpp" +#include "qgssqlstatementparser.h" #include // if not defined, searches for isatty() diff --git a/src/core/qgssqlstatementparser.yy b/src/core/qgssqlstatementparser.yy index dc065831edf6..c7ef8f9d4ec9 100644 --- a/src/core/qgssqlstatementparser.yy +++ b/src/core/qgssqlstatementparser.yy @@ -30,7 +30,7 @@ #define YYINCLUDED_STDLIB_H 1 struct sqlstatement_parser_context; -#include "qgssqlstatementparser.hpp" +#include "qgssqlstatementparser.h" //! from lexer typedef void* yyscan_t; From 1be5878601e35d7d32bf5bf8a804fffc22e69f54 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 6 May 2024 21:04:57 +0200 Subject: [PATCH 14/43] No absolute install paths --- src/app/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 37da28d52807..44f62ba7ea23 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -679,7 +679,7 @@ if (WITH_PDAL) endif() if(MSVC) - install(FILES qgis.ico qgis-mime.ico qgis-qgs.ico qgis-qlr.ico qgis-qml.ico qgis-qpt.ico DESTINATION ${CMAKE_INSTALL_PREFIX}/icons) + install(FILES qgis.ico qgis-mime.ico qgis-qgs.ico qgis-qlr.ico qgis-qml.ico qgis-qpt.ico DESTINATION icons) endif() install(TARGETS qgis_app From a1c0d6bba61fb96dfbed1d2df65a68960f80a031 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 6 May 2024 23:17:54 +0200 Subject: [PATCH 15/43] Create zip and fix ccache --- .github/workflows/windows-qt6.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index db462a3a0b23..4b2d6d2860ff 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -48,6 +48,8 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1.2 + with: + max-size: 1G - name: 🌱 Install dependencies and generate project files shell: bash @@ -60,8 +62,10 @@ jobs: -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 \ @@ -98,12 +102,8 @@ jobs: C:/src/**/*.log - name: 📤 Upload bundle -# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' uses: actions/upload-artifact@v4 with: name: qgis-windows-qt6 path: | build/*-win64.zip - - - uses: m-kuhn/action-tmate@patch-1 - if: always() From f6d725ef9281074ed0db6c5a8a8226c43f2d62c6 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 9 May 2024 09:18:31 +0200 Subject: [PATCH 16/43] Install deps --- CMakeLists.txt | 1 + cmake/VcpkgInstallDeps.cmake | 27 +++++++++++++++++++++++++++ cmake/VcpkgToolchain.cmake | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 cmake/VcpkgInstallDeps.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ef29f50ad5c..45392354f7b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1224,6 +1224,7 @@ endif() # Enable packaging if (WITH_CORE) include(Bundle) + include(VcpkgInstallDeps) endif() if (UNIX AND NOT APPLE) diff --git a/cmake/VcpkgInstallDeps.cmake b/cmake/VcpkgInstallDeps.cmake new file mode 100644 index 000000000000..e4878beb7289 --- /dev/null +++ b/cmake/VcpkgInstallDeps.cmake @@ -0,0 +1,27 @@ +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}/tools/python3/" + DESTINATION "bin" + PATTERN "*.sip" EXCLUDE) diff --git a/cmake/VcpkgToolchain.cmake b/cmake/VcpkgToolchain.cmake index e31d207b8e8d..3a2793dfc3ed 100644 --- a/cmake/VcpkgToolchain.cmake +++ b/cmake/VcpkgToolchain.cmake @@ -61,4 +61,4 @@ set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") set(VCPKG_MANIFEST_DIR "${CMAKE_SOURCE_DIR}/vcpkg") # Copies DLLs built by vcpkg when an install() command is run. # Only works on Windows and even there not reliably ... -set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON CACHE BOOL "Copy dependency DLLs on install") +# set(X_VCPKG_APPLOCAL_DEPS_INSTALL ON CACHE BOOL "Copy dependency DLLs on install") From 23d6c2f2da57100ee7b04a280e3982f50421fd28 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 10 May 2024 10:18:43 +0200 Subject: [PATCH 17/43] Pin winflexbison See https://github.com/lexxmark/winflexbison/issues/86 --- .github/workflows/windows-qt6.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 4b2d6d2860ff..d8245faed3c6 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -43,7 +43,7 @@ jobs: with: repository: 'lexxmark/winflexbison' fileName: '*.zip' - tag: 'v2.5.25' + tag: 'v2.5.24' extract: true - name: ccache From b8cfca18549b2bea0a532977438485c508c7589e Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sat, 11 May 2024 06:31:54 +0200 Subject: [PATCH 18/43] Install qt plugins and qml --- .github/workflows/windows-qt6.yml | 2 +- cmake/VcpkgInstallDeps.cmake | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index d8245faed3c6..fa9245fcdc5b 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -106,4 +106,4 @@ jobs: with: name: qgis-windows-qt6 path: | - build/*-win64.zip + build/*-win64.zip \ No newline at end of file diff --git a/cmake/VcpkgInstallDeps.cmake b/cmake/VcpkgInstallDeps.cmake index e4878beb7289..0d45f584c844 100644 --- a/cmake/VcpkgInstallDeps.cmake +++ b/cmake/VcpkgInstallDeps.cmake @@ -22,6 +22,7 @@ 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) From c9ecaef73d7ee1d3ae836c5f10ebaf723eddcbd8 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 13 May 2024 16:48:34 +0200 Subject: [PATCH 19/43] Bump baseline --- vcpkg/ports/gdal/cmake-project-include.cmake | 13 - vcpkg/ports/gdal/find-link-libraries.patch | 109 ------ .../gdal/fix-gdal-target-interfaces.patch | 15 - vcpkg/ports/gdal/libkml.patch | 46 --- vcpkg/ports/gdal/portfile.cmake | 195 ---------- vcpkg/ports/gdal/target-is-valid.patch | 21 -- vcpkg/ports/gdal/usage | 4 - vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake | 23 -- vcpkg/ports/gdal/vcpkg.json | 334 ------------------ vcpkg/ports/swig/portfile.cmake | 30 -- vcpkg/ports/swig/vcpkg.json | 19 - vcpkg/vcpkg.json | 4 +- 12 files changed, 2 insertions(+), 811 deletions(-) delete mode 100644 vcpkg/ports/gdal/cmake-project-include.cmake delete mode 100644 vcpkg/ports/gdal/find-link-libraries.patch delete mode 100644 vcpkg/ports/gdal/fix-gdal-target-interfaces.patch delete mode 100644 vcpkg/ports/gdal/libkml.patch delete mode 100644 vcpkg/ports/gdal/portfile.cmake delete mode 100644 vcpkg/ports/gdal/target-is-valid.patch delete mode 100644 vcpkg/ports/gdal/usage delete mode 100644 vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake delete mode 100644 vcpkg/ports/gdal/vcpkg.json delete mode 100644 vcpkg/ports/swig/portfile.cmake delete mode 100644 vcpkg/ports/swig/vcpkg.json diff --git a/vcpkg/ports/gdal/cmake-project-include.cmake b/vcpkg/ports/gdal/cmake-project-include.cmake deleted file mode 100644 index 409b7b1a6436..000000000000 --- a/vcpkg/ports/gdal/cmake-project-include.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(GDAL_USE_KEA) - find_package(Kealib CONFIG REQUIRED) - add_library(KEA::KEA ALIAS Kealib::Kealib) - set(GDAL_CHECK_PACKAGE_KEA_NAMES Kealib CACHE INTERNAL "vcpkg") - set(GDAL_CHECK_PACKAGE_KEA_TARGETS Kealib::Kealib CACHE INTERNAL "vcpkg") -endif() - -if(GDAL_USE_WEBP) - find_package(WebP CONFIG REQUIRED) - add_library(WEBP::WebP ALIAS WebP::webp) - set(GDAL_CHECK_PACKAGE_WebP_NAMES WebP CACHE INTERNAL "vcpkg") - set(GDAL_CHECK_PACKAGE_WebP_TARGETS WebP::webp CACHE INTERNAL "vcpkg") -endif() diff --git a/vcpkg/ports/gdal/find-link-libraries.patch b/vcpkg/ports/gdal/find-link-libraries.patch deleted file mode 100644 index 8e9c163ef7b4..000000000000 --- a/vcpkg/ports/gdal/find-link-libraries.patch +++ /dev/null @@ -1,109 +0,0 @@ -diff --git a/cmake/modules/packages/FindFreeXL.cmake b/cmake/modules/packages/FindFreeXL.cmake -index 6c86fb8..0634412 100644 ---- a/cmake/modules/packages/FindFreeXL.cmake -+++ b/cmake/modules/packages/FindFreeXL.cmake -@@ -37,7 +37,15 @@ include(SelectLibraryConfigurations) - - find_package(PkgConfig QUIET) - if(PKG_CONFIG_FOUND) -- pkg_check_modules(PC_FREEXL QUIET freexl) -+ pkg_check_modules(PC_FREEXL QUIET IMPORTED_TARGET freexl) -+endif() -+if(PC_FREEXL_FOUND) -+ set(FREEXL_INCLUDE_DIR "${PC_FREEXL_INCLUDE_DIRS}" CACHE STRING "") -+ set(FREEXL_LIBRARY "${PC_FREEXL_LIBRARIES}" CACHE STRING "") -+ if(NOT TARGET FREEXL::freexl) -+ add_library(FREEXL::freexl INTERFACE IMPORTED) -+ set_target_properties(FREEXL::freexl PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_FREEXL) -+ endif() - endif() - - find_path(FREEXL_INCLUDE_DIR -diff --git a/cmake/modules/packages/FindOpenJPEG.cmake b/cmake/modules/packages/FindOpenJPEG.cmake -index c697484..6e83222 100644 ---- a/cmake/modules/packages/FindOpenJPEG.cmake -+++ b/cmake/modules/packages/FindOpenJPEG.cmake -@@ -32,9 +32,18 @@ endfunction() - - find_package(PkgConfig QUIET) - if(PKG_CONFIG_FOUND) -- pkg_check_modules(PC_OPENJPEG QUIET libopenjp2) -+ pkg_check_modules(PC_OPENJPEG QUIET IMPORTED_TARGET libopenjp2) - set(OPENJPEG_VERSION_STRING ${PC_OPENJPEG_VERSION}) - endif() -+if(PC_OPENJPEG_FOUND) -+ set(OPENJPEG_INCLUDE_DIR "${PC_OPENJPEG_INCLUDE_DIRS}" CACHE STRING "") -+ set(OPENJPEG_LIBRARY "${PC_OPENJPEG_LIBRARIES}" CACHE STRING "") -+ if(NOT TARGET OPENJPEG::OpenJPEG) -+ add_library(OPENJPEG::OpenJPEG INTERFACE IMPORTED) -+ set_target_properties(OPENJPEG::OpenJPEG PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PC_OPENJPEG_INCLUDE_DIRS}") -+ set_target_properties(OPENJPEG::OpenJPEG PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_OPENJPEG) -+ endif() -+endif() - - - find_path(OPENJPEG_INCLUDE_DIR opj_config.h -diff --git a/cmake/modules/packages/FindPoppler.cmake b/cmake/modules/packages/FindPoppler.cmake -index 3807ec0..8059eb4 100644 ---- a/cmake/modules/packages/FindPoppler.cmake -+++ b/cmake/modules/packages/FindPoppler.cmake -@@ -42,11 +42,19 @@ This module defines the following variables: - - find_package(PkgConfig QUIET) - if(PKG_CONFIG_FOUND) -- pkg_check_modules(PC_Poppler QUIET poppler) -+ pkg_check_modules(PC_Poppler QUIET IMPORTED_TARGET poppler) - if(PC_Poppler_VERSION) - set(Poppler_VERSION_STRING ${PC_Poppler_VERSION}) - endif() - endif() -+if(PC_Poppler_FOUND) -+ find_path(Poppler_INCLUDE_DIR NAMES Object.h PATHS ${PC_Poppler_INCLUDE_DIRS} NO_DEFAULT_PATH) -+ set(Poppler_LIBRARY "${PC_Poppler_LIBRARIES}" CACHE STRING "") -+ if(NOT TARGET Poppler::Poppler) -+ add_library(Poppler::Poppler INTERFACE IMPORTED) -+ set_target_properties(Poppler::Poppler PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Poppler) -+ endif() -+endif() - find_path(Poppler_INCLUDE_DIR NAMES "poppler-config.h" "cpp/poppler-version.h" "qt5/poppler-qt5.h" "qt4/poppler-qt4.h" - "glib/poppler.h" - HINTS ${PC_Poppler_INCLUDE_DIRS} -@@ -77,6 +85,15 @@ endforeach() - foreach(_comp IN LISTS Poppler_known_components) - list(FIND Poppler_FIND_COMPONENTS "${_comp}" _nextcomp) - if(_nextcomp GREATER -1) -+ pkg_check_modules(PC_Poppler_${_comp} QUIET IMPORTED_TARGET ${Poppler_${_comp}_pkg_config}) -+ if(PC_Poppler_${_comp}_FOUND) -+ set(Poppler_${_comp}_INCLUDE_DIR "${PC_Poppler_${_comp}_INCLUDE_DIRS}" CACHE STRING "") -+ set(Poppler_${_comp}_LIBRARY "${PC_Poppler_${_comp}_LIBRARIES}" CACHE STRING "") -+ if(NOT TARGET Poppler::Poppler_${_comp}) -+ add_library(Poppler::${_comp} INTERFACE IMPORTED) -+ set_target_properties(Poppler::${_comp} PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Poppler_${_comp}) -+ endif() -+ endif() - find_path(Poppler_${_comp}_INCLUDE_DIR - NAMES ${Poppler_${_comp}_header} - PATH_SUFFIXES poppler -diff --git a/cmake/modules/packages/FindSPATIALITE.cmake b/cmake/modules/packages/FindSPATIALITE.cmake -index 00612b0..6388719 100644 ---- a/cmake/modules/packages/FindSPATIALITE.cmake -+++ b/cmake/modules/packages/FindSPATIALITE.cmake -@@ -38,9 +38,17 @@ endif() - - find_package(PkgConfig QUIET) - if(PKG_CONFIG_FOUND) -- pkg_check_modules(PC_SPATIALITE QUIET spatialite) -+ pkg_check_modules(PC_SPATIALITE QUIET IMPORTED_TARGET spatialite) - set(SPATIALITE_VERSION_STRING ${PC_SPATIALITE_VERSION}) - endif() -+if(PC_SPATIALITE_FOUND) -+ set(SPATIALITE_INCLUDE_DIR "${PC_SPATIALITE_INCLUDE_DIRS}" CACHE STRING "") -+ set(SPATIALITE_LIBRARY "${PC_SPATIALITE_LIBRARIES}" CACHE STRING "") -+ if(NOT TARGET SPATIALITE::SPATIALITE) -+ add_library(SPATIALITE::SPATIALITE INTERFACE IMPORTED) -+ set_target_properties(SPATIALITE::SPATIALITE PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_SPATIALITE) -+ endif() -+endif() - - find_path(SPATIALITE_INCLUDE_DIR - NAMES spatialite.h diff --git a/vcpkg/ports/gdal/fix-gdal-target-interfaces.patch b/vcpkg/ports/gdal/fix-gdal-target-interfaces.patch deleted file mode 100644 index bf159fce593a..000000000000 --- a/vcpkg/ports/gdal/fix-gdal-target-interfaces.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/cmake/helpers/GdalDriverHelper.cmake b/cmake/helpers/GdalDriverHelper.cmake -index 838f0fd..380e20d 100644 ---- a/cmake/helpers/GdalDriverHelper.cmake -+++ b/cmake/helpers/GdalDriverHelper.cmake -@@ -248,6 +248,10 @@ function(gdal_target_interfaces _TARGET) - if (_res) - target_compile_options(${_TARGET} PRIVATE ${_res}) - endif () -+ get_property(_res TARGET ${_LIB} PROPERTY INTERFACE_LINK_LIBRARIES) -+ if (_res) -+ gdal_target_interfaces(${_TARGET} ${_res}) -+ endif () - endif () - endforeach () - endfunction() diff --git a/vcpkg/ports/gdal/libkml.patch b/vcpkg/ports/gdal/libkml.patch deleted file mode 100644 index ef25d06de525..000000000000 --- a/vcpkg/ports/gdal/libkml.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/cmake/modules/packages/FindLibKML.cmake b/cmake/modules/packages/FindLibKML.cmake -index 9418247..589b83d 100644 ---- a/cmake/modules/packages/FindLibKML.cmake -+++ b/cmake/modules/packages/FindLibKML.cmake -@@ -56,6 +56,8 @@ find_library(LIBKML_BASE_LIBRARY - HINTS ${PC_LIBKML_LIBRARY_DIRS} ) - mark_as_advanced(LIBKML_BASE_LIBRARY) - -+cmake_policy(PUSH) -+cmake_policy(SET CMP0057 NEW) - set(libkml_known_components DOM CONVENIENCE ENGINE REGIONATOR) - foreach(_comp IN LISTS libkml_known_components) - if(${_comp} IN_LIST LibKML_FIND_COMPONENTS) -@@ -99,21 +101,20 @@ find_package_handle_standard_args(LibKML - if(LIBKML_FOUND) - set(LIBKML_INCLUDE_DIRS "${LIBKML_INCLUDE_DIR}") - set(LIBKML_LIBRARIES "${LIBKML_BASE_LIBRARY}") -+ find_package(LibKML CONFIG REQUIRED) - if(NOT TARGET LIBKML::LibKML) -- add_library(LIBKML::LibKML UNKNOWN IMPORTED) -+ add_library(LIBKML::LibKML INTERFACE IMPORTED) - set_target_properties(LIBKML::LibKML PROPERTIES -- INTERFACE_INCLUDE_DIRECTORIES "${LIBKML_INCLUDE_DIR}" -- IMPORTED_LINK_INTERFACE_LANGUAGES "C++" -- IMPORTED_LOCATION "${LIBKML_BASE_LIBRARY}") -+ INTERFACE_LINK_LIBRARIES kmlbase) - endif() - foreach(_comp IN LISTS libkml_known_components) - if(${_comp} IN_LIST LibKML_FIND_COMPONENTS) -+ string(TOLOWER ${_comp} _name) - list(APPEND LIBKML_LIBRARIES "${LIBKML_${_comp}_LIBRARY}") - if(NOT TARGET LIBKML::${_comp}) -- add_library(LIBKML::${_comp} UNKNOWN IMPORTED) -+ add_library(LIBKML::${_comp} INTERFACE IMPORTED) - set_target_properties(LIBKML::${_comp} PROPERTIES -- IMPORTED_LINK_INTERFACE_LANGUAGES "C++" -- IMPORTED_LOCATION "${LIBKML_${_comp}_LIBRARY}") -+ INTERFACE_LINK_LIBRARIES kml${_name}) - endif() - endif() - endforeach() -@@ -129,3 +130,4 @@ if(LIBKML_FOUND) - endif() - endforeach() - endif() -+cmake_policy(POP) diff --git a/vcpkg/ports/gdal/portfile.cmake b/vcpkg/ports/gdal/portfile.cmake deleted file mode 100644 index 30e653a04a92..000000000000 --- a/vcpkg/ports/gdal/portfile.cmake +++ /dev/null @@ -1,195 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO OSGeo/gdal - REF "v${VERSION}" - SHA512 764490362968b05c0edc1c73c3b51b9a517689f95f0e3e3af141da8ef81614111859bbbf2a1571f047acfbd6ba50a16320ba15ed238cbd73732a960c718d5d50 - HEAD_REF master - PATCHES - find-link-libraries.patch - fix-gdal-target-interfaces.patch - libkml.patch - target-is-valid.patch -) -# `vcpkg clean` stumbles over one subdir -file(REMOVE_RECURSE "${SOURCE_PATH}/autotest") - -# Avoid abseil, no matter if vcpkg or system -vcpkg_replace_string("${SOURCE_PATH}/ogr/ogrsf_frmts/flatgeobuf/flatbuffers/base.h" [[__has_include("absl/strings/string_view.h")]] "(0)") - -# Cf. cmake/helpers/CheckDependentLibraries.cmake -# The default for all `GDAL_USE_` dependencies is `OFF`. -# Here, we explicitly control dependencies provided via vpcpkg. -# "core" is used for a dependency which must be enabled to avoid vendored lib. -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - cfitsio GDAL_USE_CFITSIO - curl GDAL_USE_CURL - expat GDAL_USE_EXPAT - freexl GDAL_USE_FREEXL - geos GDAL_USE_GEOS - core GDAL_USE_GEOTIFF - gif GDAL_USE_GIF - hdf5 GDAL_USE_HDF5 - iconv GDAL_USE_ICONV - jpeg GDAL_USE_JPEG - core GDAL_USE_JSONC - kea GDAL_USE_KEA - lerc GDAL_USE_LERC - libkml GDAL_USE_LIBKML - lzma GDAL_USE_LIBLZMA - libxml2 GDAL_USE_LIBXML2 - mysql-libmariadb GDAL_USE_MYSQL - netcdf GDAL_USE_NETCDF - odbc GDAL_USE_ODBC - openjpeg GDAL_USE_OPENJPEG - openssl GDAL_USE_OPENSSL - pcre2 GDAL_USE_PCRE2 - png GDAL_USE_PNG - poppler GDAL_USE_POPPLER - postgresql GDAL_USE_POSTGRESQL - qhull GDAL_USE_QHULL - #core GDAL_USE_SHAPELIB # https://github.com/OSGeo/gdal/issues/5711, https://github.com/microsoft/vcpkg/issues/16041 - core GDAL_USE_SHAPELIB_INTERNAL - libspatialite GDAL_USE_SPATIALITE - sqlite3 GDAL_USE_SQLITE3 - core GDAL_USE_TIFF - webp GDAL_USE_WEBP - core GDAL_USE_ZLIB - zstd GDAL_USE_ZSTD - python BUILD_PYTHON_BINDINGS - tools BUILD_APPS - INVERTED_FEATURES - libspatialite CMAKE_DISABLE_FIND_PACKAGE_SPATIALITE -) -if(GDAL_USE_ICONV AND VCPKG_TARGET_IS_WINDOWS) - list(APPEND FEATURE_OPTIONS -D_ICONV_SECOND_ARGUMENT_IS_NOT_CONST=ON) -endif() - -if("python" IN_LIST FEATURES) - list(APPEND OPTION_RELEASE - "-DSWIG_DIR=${CURRENT_HOST_INSTALLED_DIR}/tools/swig" - "-DSWIG_EXECUTABLE=${CURRENT_HOST_INSTALLED_DIR}/tools/swig/swig${VCPKG_HOST_EXECUTABLE_SUFFIX}" - ) -else() - list(APPEND FEATURE_OPTIONS - "-DCMAKE_DISABLE_FIND_PACKAGE_SWIG=ON" - ) -endif() - -# Compatibility with older Android versions https://github.com/OSGeo/gdal/pull/5941 -if(VCPKG_TARGET_IS_ANDROID AND ANRDOID_PLATFORM VERSION_LESS 24 AND (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")) - list(APPEND FEATURE_OPTIONS -DBUILD_WITHOUT_64BIT_OFFSET=ON) -endif() - -string(REPLACE "dynamic" "" qhull_target "Qhull::qhull${VCPKG_LIBRARY_LINKAGE}_r") - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - -DVCPKG_HOST_TRIPLET=${HOST_TRIPLET} # for host pkgconf in PATH - ${FEATURE_OPTIONS} - -DBUILD_DOCS=OFF - -DBUILD_TESTING=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_CSharp=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Java=ON - -DCMAKE_DISABLE_FIND_PACKAGE_JNI=ON - -DCMAKE_DISABLE_FIND_PACKAGE_Arrow=ON - -DGDAL_USE_INTERNAL_LIBS=OFF - -DGDAL_USE_EXTERNAL_LIBS=OFF - -DGDAL_BUILD_OPTIONAL_DRIVERS=ON - -DOGR_BUILD_OPTIONAL_DRIVERS=ON - -DFIND_PACKAGE2_KEA_ENABLED=OFF - -DGDAL_CHECK_PACKAGE_MySQL_NAMES=unofficial-libmariadb - -DGDAL_CHECK_PACKAGE_MySQL_TARGETS=unofficial::libmariadb - -DMYSQL_LIBRARIES=unofficial::libmariadb - -DGDAL_CHECK_PACKAGE_NetCDF_NAMES=netCDF - -DGDAL_CHECK_PACKAGE_NetCDF_TARGETS=netCDF::netcdf - -DGDAL_CHECK_PACKAGE_QHULL_NAMES=Qhull - "-DGDAL_CHECK_PACKAGE_QHULL_TARGETS=${qhull_target}" - "-DQHULL_LIBRARY=${qhull_target}" - "-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake" - OPTIONS_DEBUG - -DBUILD_APPS=OFF - -DCMAKE_DISABLE_FIND_PACKAGE_SWIG=ON - OPTIONS_RELEASE - ${OPTIONS_RELEASE} - MAYBE_UNUSED_VARIABLES - QHULL_LIBRARY -) -vcpkg_cmake_install() -vcpkg_copy_pdbs() -vcpkg_fixup_pkgconfig() -vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/gdal) -vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/gdal/GDALConfig.cmake" - "include(CMakeFindDependencyMacro)" - "include(CMakeFindDependencyMacro) -# gdal needs a pkg-config tool. A host dependency provides pkgconf. -get_filename_component(vcpkg_host_prefix \"\${CMAKE_CURRENT_LIST_DIR}/../../../${HOST_TRIPLET}\" ABSOLUTE) -list(APPEND CMAKE_PROGRAM_PATH \"\${vcpkg_host_prefix}/tools/pkgconf\")" -) - -if (BUILD_APPS) - vcpkg_copy_tools( - TOOL_NAMES - gdal_contour - gdal_create - gdal_footprint - gdal_grid - gdal_rasterize - gdal_translate - gdal_viewshed - gdaladdo - gdalbuildvrt - gdaldem - gdalenhance - gdalinfo - gdallocationinfo - gdalmanage - gdalmdiminfo - gdalmdimtranslate - gdalsrsinfo - gdaltindex - gdaltransform - gdalwarp - gnmanalyse - gnmmanage - nearblack - ogr2ogr - ogrinfo - ogrlineref - ogrtindex - sozip - AUTO_CLEAN - ) -endif() - -file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/include" - "${CURRENT_PACKAGES_DIR}/debug/share" -) - -file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/gdal-config" "${CURRENT_PACKAGES_DIR}/debug/bin/gdal-config") - -file(GLOB bin_files "${CURRENT_PACKAGES_DIR}/bin/*") -if(NOT bin_files) - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/bin" - "${CURRENT_PACKAGES_DIR}/debug/bin" - ) -endif() - -if("python" IN_LIST FEATURES) - file(COPY "${CURRENT_PACKAGES_DIR}/Lib/site-packages/" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}") - # TODO: Generalize for non windows - file(COPY "${CURRENT_PACKAGES_DIR}/Scripts" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../Scripts") - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/Lib/site-packages" - "${CURRENT_PACKAGES_DIR}/Scripts" - ) -endif() - -vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/cpl_config.h" "#define GDAL_PREFIX \"${CURRENT_PACKAGES_DIR}\"" "") - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.TXT") diff --git a/vcpkg/ports/gdal/target-is-valid.patch b/vcpkg/ports/gdal/target-is-valid.patch deleted file mode 100644 index c7acf739064a..000000000000 --- a/vcpkg/ports/gdal/target-is-valid.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/cmake/helpers/CheckDependentLibraries.cmake b/cmake/helpers/CheckDependentLibraries.cmake -index f5c920a..53494c9 100644 ---- a/cmake/helpers/CheckDependentLibraries.cmake -+++ b/cmake/helpers/CheckDependentLibraries.cmake -@@ -41,6 +41,7 @@ endif() - # https://github.com/OSGeo/gdal/issues/5324 - function (gdal_check_target_is_valid target res_var) - get_target_property(_interface_include_directories ${target} "INTERFACE_INCLUDE_DIRECTORIES") -+ get_target_property(_type ${target} "TYPE") - if(_interface_include_directories) - foreach(_dir IN LISTS _interface_include_directories) - if(NOT EXISTS "${_dir}") -@@ -54,7 +55,7 @@ function (gdal_check_target_is_valid target res_var) - # property, but a GeoTIFF_INCLUDE_DIRS variable. - set_target_properties(${target} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${GeoTIFF_INCLUDE_DIRS}") -- else() -+ elseif(NOT _type STREQUAL "INTERFACE" AND _type STREQUAL "ALIAS") - message(WARNING "Target ${target} has no INTERFACE_INCLUDE_DIRECTORIES property. Ignoring that target.") - set(${res_var} FALSE PARENT_SCOPE) - return() diff --git a/vcpkg/ports/gdal/usage b/vcpkg/ports/gdal/usage deleted file mode 100644 index 59eea89c714d..000000000000 --- a/vcpkg/ports/gdal/usage +++ /dev/null @@ -1,4 +0,0 @@ -The package GDAL provides CMake targets: - - find_package(GDAL CONFIG REQUIRED) - target_link_libraries(main PRIVATE GDAL::GDAL) diff --git a/vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake b/vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake deleted file mode 100644 index f51e7cb8baa3..000000000000 --- a/vcpkg/ports/gdal/vcpkg-cmake-wrapper.cmake +++ /dev/null @@ -1,23 +0,0 @@ -cmake_policy(PUSH) -cmake_policy(SET CMP0012 NEW) -cmake_policy(SET CMP0054 NEW) - -list(REMOVE_ITEM ARGS "NO_MODULE" "CONFIG" "MODULE") -list(APPEND ARGS "CONFIG") -# The current port version should satisfy GDAL 3.0 ... 3.5 -list(GET ARGS 1 vcpkg_gdal_maybe_version) -if(vcpkg_gdal_maybe_version MATCHES "(^3\$|^3[.][0-5])") - list(REMOVE_AT ARGS "1") -endif() -unset(vcpkg_gdal_maybe_version) -_find_package(${ARGS} CONFIG) -if(GDAL_FOUND) - get_filename_component(vcpkg_gdal_prefix "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) - set(GDAL_INCLUDE_DIR "${vcpkg_gdal_prefix}/include" CACHE INTERNAL "") - set(GDAL_INCLUDE_DIRS "${GDAL_INCLUDE_DIR}") - set(GDAL_LIBRARY GDAL::GDAL CACHE INTERNAL "") - set(GDAL_LIBRARIES "${GDAL_LIBRARY}") - unset(vcpkg_gdal_prefix) -endif() - -cmake_policy(POP) diff --git a/vcpkg/ports/gdal/vcpkg.json b/vcpkg/ports/gdal/vcpkg.json deleted file mode 100644 index de6ffcf7b194..000000000000 --- a/vcpkg/ports/gdal/vcpkg.json +++ /dev/null @@ -1,334 +0,0 @@ -{ - "name": "gdal", - "version-semver": "3.8.4", - "description": "The Geographic Data Abstraction Library for reading and writing geospatial raster and vector data", - "homepage": "https://gdal.org", - "license": null, - "supports": "!uwp", - "dependencies": [ - "json-c", - "libgeotiff", - { - "name": "pkgconf", - "host": true - }, - { - "name": "proj", - "default-features": false, - "features": [ - "tiff" - ] - }, - { - "name": "tiff", - "default-features": false - }, - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - }, - { - "name": "vcpkg-pkgconfig-get-modules", - "host": true - }, - "zlib" - ], - "default-features": [ - "default-features" - ], - "features": { - "python": { - "description": "Build python bindings", - "dependencies": [ - "python3", - { - "name": "swig", - "host": true - }, - { - "name": "py-setuptools", - "host": true - } - ] - }, - "aws-ec2-windows": { - "description": "Optimized detection of AWS EC2 Windows hosts", - "dependencies": [ - "atlmfc" - ] - }, - "cfitsio": { - "description": "Enable cfitsio support", - "dependencies": [ - "cfitsio" - ] - }, - "curl": { - "description": "Enable CURL network support", - "dependencies": [ - { - "name": "curl", - "default-features": false - } - ] - }, - "default-features": { - "description": "Default set of features, including recommended features", - "dependencies": [ - { - "name": "gdal", - "default-features": false, - "features": [ - "gif", - "iconv", - "libkml", - "libxml2", - "lzma", - "openjpeg", - "openssl", - "pcre2", - "recommended-features", - "webp", - "zstd" - ] - }, - { - "name": "gdal", - "default-features": false, - "features": [ - "libspatialite", - "postgresql" - ], - "platform": "!uwp" - }, - { - "name": "gdal", - "default-features": false, - "features": [ - "hdf5", - "netcdf" - ], - "platform": "!uwp & !(windows & arm64) & !android & !ios" - } - ] - }, - "expat": { - "description": "Use EXPAT library", - "dependencies": [ - "expat" - ] - }, - "freexl": { - "description": "Enable FREEXL support", - "dependencies": [ - "freexl" - ] - }, - "geos": { - "description": "Enable GEOS support", - "dependencies": [ - "geos" - ] - }, - "gif": { - "description": "Enable GIF support", - "dependencies": [ - "giflib" - ] - }, - "hdf5": { - "description": "Enable HDF5 support", - "dependencies": [ - { - "name": "hdf5", - "default-features": false, - "features": [ - "cpp" - ] - } - ] - }, - "iconv": { - "description": "Use iconv library", - "dependencies": [ - "libiconv" - ] - }, - "jpeg": { - "description": "Use JPEG compression library", - "dependencies": [ - "libjpeg-turbo" - ] - }, - "kea": { - "description": "Enable KEA driver", - "dependencies": [ - { - "name": "gdal", - "default-features": false, - "features": [ - "hdf5" - ] - }, - "kealib" - ] - }, - "lerc": { - "description": "Enable LERC support", - "dependencies": [ - "lerc" - ] - }, - "libkml": { - "description": "Enable the LibKML driver", - "dependencies": [ - "libkml" - ] - }, - "libspatialite": { - "description": "Create or update SpatiaLite databases using libspatialite", - "dependencies": [ - "libspatialite" - ] - }, - "libxml2": { - "description": "Use LibXML2 library", - "dependencies": [ - "libxml2" - ] - }, - "lzma": { - "description": "Use LZMA library", - "dependencies": [ - "liblzma" - ] - }, - "mysql-libmariadb": { - "description": "Add mysql support using libmariadb", - "dependencies": [ - "libmariadb" - ] - }, - "netcdf": { - "description": "Enable NetCDF support", - "dependencies": [ - { - "name": "netcdf-c", - "default-features": false - } - ] - }, - "openjpeg": { - "description": "Use OpenJPEG library", - "dependencies": [ - "openjpeg" - ] - }, - "openssl": { - "description": "Use OpenSSL library", - "dependencies": [ - "openssl" - ] - }, - "pcre2": { - "description": "Enable PCRE2 support for sqlite3", - "dependencies": [ - "pcre2" - ] - }, - "png": { - "description": "Use PNG compression library", - "dependencies": [ - "libpng" - ] - }, - "poppler": { - "description": "Enable PDF reading support via poppler", - "dependencies": [ - { - "name": "poppler", - "default-features": false, - "features": [ - "private-api" - ] - } - ] - }, - "postgresql": { - "description": "Enable PostgreSQL support", - "dependencies": [ - "libpq" - ] - }, - "qhull": { - "description": "Use QHULL library", - "dependencies": [ - "qhull" - ] - }, - "recommended-features": { - "description": "Features that are explicity marked as recommended by GDAL.", - "dependencies": [ - { - "name": "gdal", - "default-features": false, - "features": [ - "curl", - "expat", - "geos", - "jpeg", - "lerc", - "png", - "qhull", - "sqlite3" - ] - } - ] - }, - "sqlite3": { - "description": "Enable SQLite3 support", - "dependencies": [ - { - "name": "sqlite3", - "features": [ - "rtree" - ] - } - ] - }, - "supported-default-features": { - "description": "This feature is an alias for default-features. It is retained for compatibility.", - "dependencies": [ - { - "name": "gdal", - "features": [ - "default-features" - ] - } - ] - }, - "system-libraries": { - "$supports": "!windows", - "description": "This feature does nothing. It is retained for compatibility." - }, - "tools": { - "description": "Builds gdal and ogr executables" - }, - "webp": { - "description": "Enable WEBP support", - "dependencies": [ - "libwebp" - ] - }, - "zstd": { - "description": "Use ZSTD library", - "dependencies": [ - "zstd" - ] - } - } -} diff --git a/vcpkg/ports/swig/portfile.cmake b/vcpkg/ports/swig/portfile.cmake deleted file mode 100644 index d19d1a35df91..000000000000 --- a/vcpkg/ports/swig/portfile.cmake +++ /dev/null @@ -1,30 +0,0 @@ -set(VCPKG_BUILD_TYPE release) - -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO swig/swig - REF "v${VERSION}" - SHA512 5d653333f73356d4d5ba8b615882e49f33f188bc68d8204352116bc4aca7946ec01ce2e02524c5ce805b98c2219ed05e664120485bf18095c5c0785436487074 - HEAD_REF master -) - -vcpkg_find_acquire_program(BISON) - -list(APPEND OPTIONS "-D BISON_EXECUTABLE=${BISON}") - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - ${OPTIONS} -) - -vcpkg_cmake_install() -vcpkg_copy_pdbs() -vcpkg_fixup_pkgconfig() - -vcpkg_copy_tools(TOOL_NAMES swig) -file(COPY "${CURRENT_PACKAGES_DIR}/bin/" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/swig") -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin") - -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") -set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) \ No newline at end of file diff --git a/vcpkg/ports/swig/vcpkg.json b/vcpkg/ports/swig/vcpkg.json deleted file mode 100644 index 5190cf6f8771..000000000000 --- a/vcpkg/ports/swig/vcpkg.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "swig", - "version": "4.2.1", - "description": "SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.", - "homepage": "http://www.swig.org/", - "dependencies": - [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - }, - "pcre2" - ] -} - \ No newline at end of file diff --git a/vcpkg/vcpkg.json b/vcpkg/vcpkg.json index f3baf6677e28..a4c36103f127 100644 --- a/vcpkg/vcpkg.json +++ b/vcpkg/vcpkg.json @@ -2,13 +2,13 @@ "vcpkg-configuration": { "default-registry": { "kind": "git", - "baseline": "04b0cf2b3fd1752d3c3db969cbc10ba0a4613cee", + "baseline": "090344cfc0b2844466e2251536fbe6c2408e5eb6", "repository": "https://github.com/microsoft/vcpkg" }, "registries": [ { "kind": "git", - "baseline": "1b757963f749da01b93a3cdfee29b91a7ac3a862", + "baseline": "7d2535039cd5d76570c6fa2822359c16f02a8a0b", "repository": "https://github.com/open-vcpkg/python-registry", "packages": [ "python3", From 2d8a9d1f5185049950ae17476c8b94ae7fcd762b Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 13 May 2024 16:51:35 +0200 Subject: [PATCH 20/43] Consume gdal and swig from python-registry --- vcpkg/vcpkg.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcpkg/vcpkg.json b/vcpkg/vcpkg.json index a4c36103f127..c6e2f6693cd6 100644 --- a/vcpkg/vcpkg.json +++ b/vcpkg/vcpkg.json @@ -13,6 +13,8 @@ "packages": [ "python3", "py-*", + "gdal", + "swig", "vcpkg-python-scripts" ] } From ad03cab1a8e89c3e02059aedf9615ed95b4a7fd6 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 13 May 2024 22:51:28 +0200 Subject: [PATCH 21/43] Prepare for merge --- .github/workflows/windows-qt6.yml | 6 +++--- cmake/VcpkgToolchain.cmake | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index fa9245fcdc5b..b91770805fa0 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -3,7 +3,7 @@ name: 🪟 Windows Qt6 on: push: branches: - - windows-qt6 + - master - release-** pull_request: release: @@ -80,7 +80,7 @@ jobs: -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ -D WITH_QTWEBKIT=OFF \ -D VCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/src" \ - -D NUGET_USERNAME=m-kuhn \ + -D NUGET_USERNAME=${{ github.actor }} \ -D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} - name: 🌋 Build @@ -106,4 +106,4 @@ jobs: with: name: qgis-windows-qt6 path: | - build/*-win64.zip \ No newline at end of file + build/*-win64.zip diff --git a/cmake/VcpkgToolchain.cmake b/cmake/VcpkgToolchain.cmake index 3a2793dfc3ed..5f77d11fd51c 100644 --- a/cmake/VcpkgToolchain.cmake +++ b/cmake/VcpkgToolchain.cmake @@ -1,5 +1,5 @@ -set(NUGET_SOURCE "https://nuget.pkg.github.com/m-kuhn/index.json") -set(NUGET_USERNAME "m-kuhn" CACHE STRING "Nuget user") +set(NUGET_SOURCE "https://nuget.pkg.github.com/qgis/index.json" CACHE STRING "Nuget source") +set(NUGET_USERNAME "qgis" CACHE STRING "Nuget user") # Setup features (dependencies) based on cmake configuration if(WITH_BINDINGS) @@ -39,7 +39,7 @@ if(NOT "${NUGET_TOKEN}" STREQUAL "" AND WIN32) "${_CONFIG_PATH}" @ONLY) execute_process( - COMMAND ${_NUGET_EXE} setapikey "${NUGET_TOKEN}" -src "https://nuget.pkg.github.com/m-kuhn/index.json" -configfile ${_CONFIG_PATH} + COMMAND ${_NUGET_EXE} setapikey "${NUGET_TOKEN}" -src ${NUGET_SOURCE} -configfile ${_CONFIG_PATH} OUTPUT_VARIABLE _OUTPUT ERROR_VARIABLE _ERROR RESULT_VARIABLE _RESULT) From 4ecffc4656160986943838afa5c691898f395292 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 13 May 2024 23:15:02 +0200 Subject: [PATCH 22/43] Remove unneeded features --- cmake/VcpkgToolchain.cmake | 6 ------ vcpkg/vcpkg.json | 9 --------- 2 files changed, 15 deletions(-) diff --git a/cmake/VcpkgToolchain.cmake b/cmake/VcpkgToolchain.cmake index 5f77d11fd51c..cbcf923ceeba 100644 --- a/cmake/VcpkgToolchain.cmake +++ b/cmake/VcpkgToolchain.cmake @@ -8,15 +8,9 @@ endif() if(WITH_3D) list(APPEND VCPKG_MANIFEST_FEATURES "3d") endif() -if(WITH_QGIS_PROCESS) - list(APPEND VCPKG_MANIFEST_FEATURES "process") -endif() if(WITH_GUI) list(APPEND VCPKG_MANIFEST_FEATURES "gui") endif() -if(WITH_DESKTOP) - list(APPEND VCPKG_MANIFEST_FEATURES "desktop") -endif() # Setup binary cache if(NOT "${NUGET_TOKEN}" STREQUAL "" AND WIN32) diff --git a/vcpkg/vcpkg.json b/vcpkg/vcpkg.json index c6e2f6693cd6..144bd0d9cc40 100644 --- a/vcpkg/vcpkg.json +++ b/vcpkg/vcpkg.json @@ -95,12 +95,6 @@ "python3" ] }, - "customwidgets": { - "description": "Determines whether the QGIS custom widgets for QtCreator should be built" - }, - "desktop": { - "description": "Determines whether the QGIS desktop (main app) should be built" - }, "gui": { "description": "Determines whether the QGIS gui should be built", "dependencies": [ @@ -115,9 +109,6 @@ "opencl" ] }, - "process": { - "description": "Determines whether the command line QGIS process tool should be built" - }, "quick": { "description": "Build the QGIS quick components for mobile interfaces", "dependencies": [ From c380dd46c6630c1f0b7fc0b7dfeaa859d73dacba Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 13 May 2024 23:33:11 +0200 Subject: [PATCH 23/43] Fix bad merge --- external/nmea/parse.c | 6 +++--- external/nmea/sentence.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/external/nmea/parse.c b/external/nmea/parse.c index a181f9a0ab5c..e137d2729852 100644 --- a/external/nmea/parse.c +++ b/external/nmea/parse.c @@ -415,14 +415,14 @@ int nmea_parse_GPRMC( const char *buff, int buff_sz, nmeaGPRMC *pack ) nmea_trace_buff( buff, buff_sz ); nsen = nmea_scanf( buff, buff_sz, - "$G%CRMC,%s,%C,%f,%C,%f,%C,%f,%f,%2d%2d%2d,%f,%C,%C*", + "$G%CRMC,%s,%C,%f,%C,%f,%C,%f,%f,%2d%2d%2d,%f,%C,%C,%C*", &( type ), &( time_buff[0] ), &( pack->status ), &( pack->lat ), &( pack->ns ), &( pack->lon ), &( pack->ew ), &( pack->speed ), &( pack->direction ), &( pack->utc.day ), &( pack->utc.mon ), &( pack->utc.year ), - &( pack->declination ), &( pack->declin_ew ), &( pack->mode ) ); + &( pack->declination ), &( pack->declin_ew ), &( pack->mode ), &( pack->navstatus ) ); - if ( nsen != 14 && nsen != 15 ) + if ( nsen < 14 || nsen > 16 ) { nmea_error( "G?RMC parse error!" ); return 0; diff --git a/external/nmea/sentence.h b/external/nmea/sentence.h index 1ed707f40a38..d007a3cdc0d3 100644 --- a/external/nmea/sentence.h +++ b/external/nmea/sentence.h @@ -118,7 +118,7 @@ typedef struct _nmeaGPRMC double declination; //!< Magnetic variation degrees (Easterly var. subtracts from true course) char declin_ew; //!< [E]ast or [W]est char mode; //!< Mode indicator of fix type (A = autonomous, D = differential, E = estimated, N = not valid, S = simulator) - + char navstatus; //!< NMEA v4.1 - Navigation Status type (S = Safe, C = Caution, U = Unsafe, V = Navigational status not valid) } nmeaGPRMC; /** From 3488d7daa5091968c5153f96e92bfe945a78845d Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 13 May 2024 23:34:49 +0200 Subject: [PATCH 24/43] Fix indentation --- src/app/main.cpp | 6 +++--- src/app/qgisapp.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index a71b31ecbfaa..71f0ce0d443d 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -178,9 +178,9 @@ void usage( const QString &appName ) #ifdef Q_OS_WIN MessageBoxW( nullptr, - reinterpret_cast( msg.join( QString() ).utf16() ), - L"QGIS command line options", - MB_OK ); + reinterpret_cast( msg.join( QString() ).utf16() ), + L"QGIS command line options", + MB_OK ); #else std::cout << msg.join( QString() ).toLocal8Bit().constData(); #endif diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index f7db2547b8e0..4dfb52a021b8 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -13054,7 +13054,7 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory ) CFRelease( urlRef ); #elif defined(Q_OS_WIN) if ( url.startsWith( "file://", Qt::CaseInsensitive ) ) - ShellExecuteW( 0, 0, reinterpret_cast( url.mid( 7 ).utf16() ), 0, 0, SW_SHOWNORMAL ); + ShellExecuteW( 0, 0, reinterpret_cast( url.mid( 7 ).utf16() ), 0, 0, SW_SHOWNORMAL ); else QDesktopServices::openUrl( url ); #else From 117b82aae6ec0c1ffe6213b3d43d5b9f056dcf13 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 13 May 2024 23:47:42 +0200 Subject: [PATCH 25/43] Allow writing packages --- .github/workflows/windows-qt6.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index b91770805fa0..8bc0f4a43cd9 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -13,6 +13,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + packages: write + jobs: build: name: build (windows) From 152810a17ddbebe37d8e842d47c624dfc1ecf773 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 13 May 2024 23:59:18 +0200 Subject: [PATCH 26/43] UX --- .github/workflows/windows-qt6.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 8bc0f4a43cd9..fa337cbfbe1b 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -38,10 +38,10 @@ jobs: # See https://github.com/actions/runner-images/issues/9398 toolset: 14.39 - - name: Setup vcpkg + - name: 🎡 Setup vcpkg uses: ./.github/actions/setup-vcpkg - - name: Setup flex/bison + - name: 🦬 Setup flex/bison uses: robinraju/release-downloader@v1.10 with: repository: 'lexxmark/winflexbison' @@ -49,7 +49,7 @@ jobs: tag: 'v2.5.24' extract: true - - name: ccache + - name: 🛍️ Setup ccache uses: hendrikmuhs/ccache-action@v1.2 with: max-size: 1G From 0ff6542bcb8f75981f769a239540218d022185b1 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Tue, 14 May 2024 09:10:54 +0200 Subject: [PATCH 27/43] Add python dependencies --- vcpkg/ports/py-qgis-requirements/portfile.cmake | 11 +++++++++++ .../ports/py-qgis-requirements/requirements.txt | 3 +++ vcpkg/ports/py-qgis-requirements/vcpkg.json | 16 ++++++++++++++++ vcpkg/vcpkg.json | 4 +++- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 vcpkg/ports/py-qgis-requirements/portfile.cmake create mode 100644 vcpkg/ports/py-qgis-requirements/requirements.txt create mode 100644 vcpkg/ports/py-qgis-requirements/vcpkg.json diff --git a/vcpkg/ports/py-qgis-requirements/portfile.cmake b/vcpkg/ports/py-qgis-requirements/portfile.cmake new file mode 100644 index 000000000000..1d48252e6d1c --- /dev/null +++ b/vcpkg/ports/py-qgis-requirements/portfile.cmake @@ -0,0 +1,11 @@ +set(BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + +file(MAKE_DIRECTORY ${BUILD_DIR}) + +vcpkg_execute_required_process( + COMMAND "${CURRENT_INSTALLED_DIR}/tools/python3/python${VCPKG_HOST_EXECUTABLE_SUFFIX}" "-m" "pip" "install" "-r" "${CURRENT_PORT_DIR}/requirements.txt" "--target" "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}" + WORKING_DIRECTORY "${BUILD_DIR}" + LOGNAME "requirements-install-${TARGET_TRIPLET}-rel" + ) + +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) \ No newline at end of file diff --git a/vcpkg/ports/py-qgis-requirements/requirements.txt b/vcpkg/ports/py-qgis-requirements/requirements.txt new file mode 100644 index 000000000000..fc0dc4e52116 --- /dev/null +++ b/vcpkg/ports/py-qgis-requirements/requirements.txt @@ -0,0 +1,3 @@ +psycopg2==2.9.9 +isort==5.13.2 +autopep8==2.1.0 diff --git a/vcpkg/ports/py-qgis-requirements/vcpkg.json b/vcpkg/ports/py-qgis-requirements/vcpkg.json new file mode 100644 index 000000000000..c874880aeec0 --- /dev/null +++ b/vcpkg/ports/py-qgis-requirements/vcpkg.json @@ -0,0 +1,16 @@ +{ + "name": "py-qgis-requirements", + "version-date": "2024-05-14", + "description": "pip installed python requirements", + "dependencies": [ + { + "name": "py-setuptools", + "host": true + }, + { + "name": "py-pip", + "host": true + }, + "python3" + ] +} diff --git a/vcpkg/vcpkg.json b/vcpkg/vcpkg.json index 144bd0d9cc40..53c547c07ced 100644 --- a/vcpkg/vcpkg.json +++ b/vcpkg/vcpkg.json @@ -8,7 +8,7 @@ "registries": [ { "kind": "git", - "baseline": "7d2535039cd5d76570c6fa2822359c16f02a8a0b", + "baseline": "3edb3eb7092173dddb15359aa48b1599708fd96e", "repository": "https://github.com/open-vcpkg/python-registry", "packages": [ "python3", @@ -92,6 +92,8 @@ "py-pip", "py-pyqt6", "py-qscintilla", + "py-pyyaml", + "py-qgis-requirements", "python3" ] }, From 90ee3db05dd9e1e72dfe36d8c407093c7b1a17ad Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Wed, 15 May 2024 22:40:13 +0200 Subject: [PATCH 28/43] Update comment --- .github/workflows/build_artifact_comment.yml | 103 ++++++++----------- .github/workflows/windows-qt6.yml | 7 ++ 2 files changed, 50 insertions(+), 60 deletions(-) diff --git a/.github/workflows/build_artifact_comment.yml b/.github/workflows/build_artifact_comment.yml index b3414fceb241..6cb4dc973d21 100644 --- a/.github/workflows/build_artifact_comment.yml +++ b/.github/workflows/build_artifact_comment.yml @@ -2,7 +2,9 @@ name: Write build artifact comments on: workflow_run: - workflows: [🪟 MingW64 Windows 64bit Build] + workflows: + - "🪟 MingW64 Windows 64bit Build" + - "🪟 Windows Qt6" types: - completed @@ -11,7 +13,6 @@ permissions: jobs: on-success: - permissions: pull-requests: write @@ -22,86 +23,68 @@ jobs: uses: actions/github-script@v7 with: script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "QGIS for Windows 64bit" + const artifactName = context.payload.workflow_run.name.includes("MingW64") ? "QGIS for Windows 64bit" : "qgis-windows-qt6"; + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, }); - if (matchArtifacts.length>0) - { - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifacts[0].id, - archive_format: 'zip', + const artifact = artifacts.data.artifacts.find(a => a.name == artifactName); + if (artifact) { + const download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: artifact.id, + archive_format: 'zip', }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/QGIS for Windows 64bit.zip`, Buffer.from(download.data)); - core.setOutput('artifact_id', matchArtifacts[0].id); - } - else - { - core.setOutput('artifact_id', 0); - } - let matchArtifactsDebugSymbols = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "QGIS for Windows 64bit Debug Symbols" - }); - if (matchArtifactsDebugSymbols.length>0) - { - core.setOutput('debug_symbols_artifact_id', matchArtifactsDebugSymbols[0].id); - } - else - { - core.setOutput('debug_symbols_artifact_id', 0); + const fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${artifactName}`, Buffer.from(download.data)); + core.setOutput('artifact_url', `${context.repo.owner}/${context.repo.repo}/suites/${context.payload.workflow_run.check_suite_id}/artifacts/${artifact.id}`); + } else { + core.setOutput('artifact_url', ''); } - - name: 'Unzip artifact' - if: fromJSON(steps.download_artifact.outputs.artifact_id) > 0 - run: | - unzip "QGIS for Windows 64bit.zip" - unzip -j qgis-portable-win64.zip pr_number git_commit - - - name: 'Post artifact download link as comment on PR' - if: fromJSON(steps.download_artifact.outputs.artifact_id) > 0 + - name: 'Post or update PR comment' uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - let fs = require('fs'); - let issue_number = Number(fs.readFileSync('./pr_number')); - let git_sha = String(fs.readFileSync('./git_commit')).trim(); + const fs = require('fs'); + const issue_number = Number(fs.readFileSync('./pr_number')); + const git_sha = String(fs.readFileSync('./git_commit')).trim(); + const artifactUrl = steps.download_artifact.outputs.artifact_url; + const buildType = context.payload.workflow_run.name.includes("MingW64") ? "Windows" : "Qt6"; + const bodyPart = artifactUrl ? `${buildType} builds of this PR are available for testing [here](https://github.com/${artifactUrl}).` : `${buildType} build N/A`; + const prComments = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue_number, }); - const PREFIX = "## 🪟 Windows builds ready!"; - let body = PREFIX + "\n\n" + - "Windows builds of this PR are available for testing [here](https://github.com/" + context.repo.owner + "/" + context.repo.repo + "/suites/" + context.payload.workflow_run.check_suite_id + "/artifacts/${{steps.download_artifact.outputs.artifact_id}})."; - if ( ${{steps.download_artifact.outputs.debug_symbols_artifact_id}} > 0 ) - { - body += " Debug symbols for this build are available [here](https://github.com/" + context.repo.owner + "/" + context.repo.repo + "/suites/" + context.payload.workflow_run.check_suite_id + "/artifacts/${{steps.download_artifact.outputs.debug_symbols_artifact_id}})."; - } - body += "\n\n*(Built from commit " + git_sha + ")*"; + const commentPrefix = "## 🪟 Build Details"; + const existingComment = prComments.data.find(comment => comment.body.startsWith(commentPrefix)); + let newBody; - const winBuildComment = prComments.data?.find(c => c.body.startsWith(PREFIX)); - if (!!winBuildComment) { - // update the existing comment + if (existingComment) { + const regex = new RegExp(`(## ${buildType} builds ready![\\s\\S]*?)(?=(## (Windows|Qt6) builds ready!|$))`, "g"); + const replacement = `## ${buildType} builds ready!\n\n${bodyPart}\n\n`; + if (existingComment.body.includes(`## ${buildType} builds ready!`)) { + newBody = existingComment.body.replace(regex, replacement); + } else { + newBody = existingComment.body + replacement; + } await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, - comment_id: winBuildComment.id, - body: body + comment_id: existingComment.id, + body: newBody }); } else { - // submit a new comment + newBody = `${commentPrefix}\n\n${replacement}\n\n*(Built from commit ${git_sha})*`; await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue_number, - body: body + body: newBody }); } diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index fa337cbfbe1b..cfecf4401cee 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -104,6 +104,13 @@ jobs: path: | C:/src/**/*.log + - name: Save PR number to zips + run: | + echo ${{ github.event.number }} | tee pr_number + zip -u *-win64.zip pr_number + echo ${{ github.event.pull_request.head.sha }} | tee git_commit + zip -u *-win64.zip git_commit + - name: 📤 Upload bundle uses: actions/upload-artifact@v4 with: From 9332fba37f19f96db4f16d2c61581780297c8208 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 16 May 2024 11:55:38 +0200 Subject: [PATCH 29/43] Update windows-qt6.yml --- .github/workflows/windows-qt6.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index cfecf4401cee..71af71ca3cca 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -107,9 +107,9 @@ jobs: - name: Save PR number to zips run: | echo ${{ github.event.number }} | tee pr_number - zip -u *-win64.zip pr_number + powershell Compress-Archive -update pr_number *-win64.zip echo ${{ github.event.pull_request.head.sha }} | tee git_commit - zip -u *-win64.zip git_commit + powershell Compress-Archive -update git_commit *-win64.zip - name: 📤 Upload bundle uses: actions/upload-artifact@v4 From f9d44d749c19444dcf7f54859d1c3ca7905435e5 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 2 Jun 2024 16:55:50 +0200 Subject: [PATCH 30/43] Create sdk --- .github/workflows/windows-qt6.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 71af71ca3cca..e298294c7606 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -96,6 +96,19 @@ jobs: 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 + + - 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() From a8dda9975beb94bd8e8299318c8bfe1d2391ea48 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 3 Jun 2024 08:02:58 +0200 Subject: [PATCH 31/43] Absolute path --- .github/workflows/windows-qt6.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index e298294c7606..afcc9eb109c9 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -99,7 +99,7 @@ jobs: - 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 + vcpkg.exe export --zip --output-dir=./sdk --x-install-root=${{ github.workspace }}/build/vcpkg_installed - name: 📤 Upload sdk # if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' From 77589b68008c0ac0e39b0d6bd6904214aee70514 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 3 Jun 2024 09:09:48 +0200 Subject: [PATCH 32/43] Update windows-qt6.yml --- .github/workflows/windows-qt6.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index afcc9eb109c9..d5052f9f4161 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -99,7 +99,7 @@ jobs: - name: 📦 Create SDK # if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' run: | - vcpkg.exe export --zip --output-dir=./sdk --x-install-root=${{ github.workspace }}/build/vcpkg_installed + vcpkg.exe export --zip --output-dir=./sdk --x-install-root=$( cygpath "${{ github.workspace }}/build" )/vcpkg_installed - name: 📤 Upload sdk # if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' From 10f26a9b726cd7a5071a0e9ab0cd231af6b5765f Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 3 Jun 2024 13:21:20 +0200 Subject: [PATCH 33/43] Debug --- .github/workflows/windows-qt6.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index d5052f9f4161..d04259d0b3d7 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -96,6 +96,8 @@ jobs: run: | cmake --build "${{ github.workspace }}/build" --target bundle --config Release + - uses: m-kuhn/action-tmate@patch-1 + - name: 📦 Create SDK # if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' run: | From 296bd9f66473fe5677bda3293774faff8f569acc Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Wed, 5 Jun 2024 18:28:17 +0200 Subject: [PATCH 34/43] Fix sdk export --- .github/workflows/windows-qt6.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index d04259d0b3d7..5ab3e5842022 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -96,12 +96,10 @@ jobs: run: | cmake --build "${{ github.workspace }}/build" --target bundle --config Release - - uses: m-kuhn/action-tmate@patch-1 - - name: 📦 Create SDK # if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' run: | - vcpkg.exe export --zip --output-dir=./sdk --x-install-root=$( cygpath "${{ github.workspace }}/build" )/vcpkg_installed + vcpkg.exe export --zip --output-dir=./sdk --x-install-root=$( cygpath "${{ github.workspace }}/build" )/vcpkg_installed --x-manifest-dir=vcpkg - name: 📤 Upload sdk # if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' From ad6725be6367f6f8cbd29e9e88f7a4a4409575e1 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sat, 8 Jun 2024 12:57:57 +0200 Subject: [PATCH 35/43] Fix param --- .github/workflows/windows-qt6.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 5ab3e5842022..6ce58e040fec 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -99,8 +99,8 @@ jobs: - name: 📦 Create SDK # if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' run: | - vcpkg.exe export --zip --output-dir=./sdk --x-install-root=$( cygpath "${{ github.workspace }}/build" )/vcpkg_installed --x-manifest-dir=vcpkg - + vcpkg.exe export --zip --output-dir=./sdk --x-install-root=$( cygpath "${{ github.workspace }}/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 From c23690c073383f9d6e868de35e81293cda06e175 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sat, 8 Jun 2024 13:12:04 +0200 Subject: [PATCH 36/43] Update windows-qt6.yml --- .github/workflows/windows-qt6.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 6ce58e040fec..c1f1a6a5c564 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -34,9 +34,6 @@ jobs: - 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 From 67e58ae45bac95f012d84d269aba207f7e701fcc Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sat, 29 Jun 2024 18:07:30 +0200 Subject: [PATCH 37/43] Bump cmake version --- .github/workflows/windows-qt6.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index c1f1a6a5c564..06452115e2dd 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -30,7 +30,7 @@ jobs: - name: 🐩 Install CMake and Ninja uses: lukka/get-cmake@latest with: - cmakeVersion: 3.29.2 + cmakeVersion: 3.29.6 - name: 🧽 Developer Command Prompt for Microsoft Visual C++ uses: ilammy/msvc-dev-cmd@v1 @@ -88,6 +88,9 @@ jobs: run: | cmake --build "${{ github.workspace }}/build" --config Release + - uses: m-kuhn/action-tmate@patch-1 + if: failure() + - name: 📦 Package shell: bash run: | From 6e24900fe638ca91ce962fe802bf731984e1ee1f Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 30 Jun 2024 07:48:20 +0200 Subject: [PATCH 38/43] Add more python deps --- vcpkg/ports/py-qgis-requirements/portfile.cmake | 13 ++++++++++--- vcpkg/ports/py-qgis-requirements/requirements.txt | 8 +++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/vcpkg/ports/py-qgis-requirements/portfile.cmake b/vcpkg/ports/py-qgis-requirements/portfile.cmake index 1d48252e6d1c..ff3a4c265213 100644 --- a/vcpkg/ports/py-qgis-requirements/portfile.cmake +++ b/vcpkg/ports/py-qgis-requirements/portfile.cmake @@ -1,11 +1,18 @@ set(BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") -file(MAKE_DIRECTORY ${BUILD_DIR}) +file(MAKE_DIRECTORY "${BUILD_DIR}") +file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}") + +if(VCPKG_TARGET_IS_WINDOWS) + set(PYTHON_EXECUTABLE "${CURRENT_INSTALLED_DIR}/tools/python3/python${VCPKG_HOST_EXECUTABLE_SUFFIX}") +else() + set(PYTHON_EXECUTABLE "${CURRENT_INSTALLED_DIR}/tools/python3/python${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR}") +endif() vcpkg_execute_required_process( - COMMAND "${CURRENT_INSTALLED_DIR}/tools/python3/python${VCPKG_HOST_EXECUTABLE_SUFFIX}" "-m" "pip" "install" "-r" "${CURRENT_PORT_DIR}/requirements.txt" "--target" "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}" + COMMAND "${PYTHON_EXECUTABLE}" "-m" "pip" "install" "-r" "${CURRENT_PORT_DIR}/requirements.txt" "--target" "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}" "--no-deps" WORKING_DIRECTORY "${BUILD_DIR}" LOGNAME "requirements-install-${TARGET_TRIPLET}-rel" ) -set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) \ No newline at end of file +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) diff --git a/vcpkg/ports/py-qgis-requirements/requirements.txt b/vcpkg/ports/py-qgis-requirements/requirements.txt index fc0dc4e52116..c9acbc76ceec 100644 --- a/vcpkg/ports/py-qgis-requirements/requirements.txt +++ b/vcpkg/ports/py-qgis-requirements/requirements.txt @@ -1,3 +1,9 @@ -psycopg2==2.9.9 isort==5.13.2 autopep8==2.1.0 +jinja2==3.1.4 +OWSLib==0.31.0 +lxml==5.2.2 +python-dateutil==2.9.0.post0 +six==1.16.0 +pytz==2024.1 +requests==2.32.3 From b22291b01a400128942014f4d54ebb57296d6d56 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 30 Jun 2024 09:07:49 +0200 Subject: [PATCH 39/43] relative --- .github/workflows/windows-qt6.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 06452115e2dd..8170a6e9dca3 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -99,7 +99,7 @@ jobs: - name: 📦 Create SDK # if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' run: | - vcpkg.exe export --zip --output-dir=./sdk --x-install-root=$( cygpath "${{ github.workspace }}/build" )/vcpkg_installed --x-manifest-root=vcpkg + 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' From 1c7c16af4a16154f8fc334b7dfee3955ed2e8bba Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 30 Jun 2024 11:33:05 +0200 Subject: [PATCH 40/43] Add sdk support --- CMakeLists.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45392354f7b0..0a22b0073b9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,9 +26,27 @@ set (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be bui 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) +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") From a10ee78b02ab8eb3d82e246c8ba2aabd4f7f0f88 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 30 Jun 2024 11:36:47 +0200 Subject: [PATCH 41/43] Complain if toolchain is not around --- cmake/VcpkgToolchain.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/VcpkgToolchain.cmake b/cmake/VcpkgToolchain.cmake index cbcf923ceeba..cf86064479e9 100644 --- a/cmake/VcpkgToolchain.cmake +++ b/cmake/VcpkgToolchain.cmake @@ -50,7 +50,9 @@ if(NOT "${NUGET_TOKEN}" STREQUAL "" AND WIN32) file(TO_NATIVE_PATH "${_CONFIG_PATH}" _CONFIG_PATH_NATIVE) set(ENV{VCPKG_BINARY_SOURCES} "$ENV{VCPKG_BINARY_SOURCES};nugetconfig,${_CONFIG_PATH_NATIVE},readwrite") endif() - +if(NOT DEFINED ENV{VCPKG_ROOT}) + message(FATAL_ERROR "Vcpkg is not available. Bootstrap vcpkg by following the 'Acquire vcpkg' section of https://devblogs.microsoft.com/cppblog/vcpkg-artifacts/#acquire-vcpkg") +endif() set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") set(VCPKG_MANIFEST_DIR "${CMAKE_SOURCE_DIR}/vcpkg") # Copies DLLs built by vcpkg when an install() command is run. From d0b36a87ccb56439baad94de1fbc45d3a86aab88 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 1 Jul 2024 11:36:31 +0200 Subject: [PATCH 42/43] More robust sip version check --- cmake/FindPyQt6.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/FindPyQt6.cmake b/cmake/FindPyQt6.cmake index a938417a03fd..1e54cbecfe9d 100644 --- a/cmake/FindPyQt6.cmake +++ b/cmake/FindPyQt6.cmake @@ -22,7 +22,7 @@ IF(EXISTS PYQT6_VERSION_STR) SET(PYQT6_FOUND TRUE) ELSE(EXISTS PYQT6_VERSION_STR) - IF(SIP_BUILD_EXECUTABLE) + IF(${SIP_VERSION_STR} VERSION_GREATER 4) # SIP >= 5.0 path FILE(GLOB _pyqt6_metadata "${Python_SITEARCH}/PyQt6-*.dist-info/METADATA") @@ -42,7 +42,7 @@ ELSE(EXISTS PYQT6_VERSION_STR) SET(PYQT6_FOUND TRUE) ENDIF(PYQT6_VERSION_STR) - ELSE(SIP_BUILD_EXECUTABLE) + ELSE() # SIP 4.x path FIND_FILE(_find_pyqt6_py FindPyQt6.py PATHS ${CMAKE_MODULE_PATH} NO_CMAKE_FIND_ROOT_PATH) @@ -61,7 +61,7 @@ ELSE(EXISTS PYQT6_VERSION_STR) SET(PYQT6_FOUND TRUE) ENDIF(pyqt_config) - ENDIF(SIP_BUILD_EXECUTABLE) + ENDIF() IF(PYQT6_FOUND) IF(NOT PyQt6_FIND_QUIETLY) From ffedc336bc8360f15e3693ec84708cfbc2d29174 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 8 Jul 2024 15:18:07 +0200 Subject: [PATCH 43/43] Improve docs --- INSTALL.md | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 0c877ef7e6ec..c42c0737a097 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -709,12 +709,83 @@ 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 +## 4.3 Building on Windows with vcpkg + +Vcpkg is a free and open source cross platform ecosystem for libraries. +It provides precise control over the versions of dependencies that are used, more of that is covered below. + +### 4.3.1 Install Build Tools + +1. Download and install the free (as in free beer) [Microsoft Visual Studio 2022 Community Edition](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022). +2. Obtain [winflexbison](https://github.com/lexxmark/winflexbison/releases). + +### 4.3.2 Build QGIS + +There are two ways, to build with vcpkg. Either you download an sdk, which allows you +to reuse dependencies that are already built. This is generally easier and recommended. +It is also possible to build all dependencies yourself, which allows you more control +over the dependencies. + +#### 4.3.2.1 Build with an SDK + +1. Download and unzip SDK (e.g. from a release, shall we do daily exports?) +2. Build + +We will now configure QGIS. + +Open a _Developer PowerShell for VS 2022_ + +```ps +# We assume you have a copy of the QGIS source code available +# and have changed the working directory into it + +# Configure +cmake -S . \ + -B build \ + -DSDK_PATH="path/to/vcpkg-export-[date]" \ + -DBUILD_WITH_QT6=ON \ + -DWITH_QTWEBKIT=OFF \ + -DVCPKG_TARGET_TRIPLET=x64-windows-release +``` + +This will provide you with a configured project. You can either build it directly +from the command line. + +```ps +# Build +cmake --build build --config Release +``` + +Or you can open the generated `.sln` file in the `build` folder with Visual Studio. +This will allow you to use all the tools that this IDE has to offer. + +#### 4.3.2.1 Build all the dependencies locally + +It is also possible to build all the dependencies locally. +This will require some time, cpu and disk space. + +```ps +# We assume you have a copy of the QGIS source code available +# and have changed the working directory into it + +# Configure +cmake -S . \ + -B build \ + -D WITH_VCPKG \ + -D BUILD_WITH_QT6=ON \ + -D WITH_QTWEBKIT=OFF \ + -D VCPKG_TARGET_TRIPLET=x64-windows-release \ + -D VCPKG_HOST_TRIPLET=x64-windows-release +``` + +**Manage dependency versions** + +The dependencies are defined in the file `vcpkg/vcpkg.json`. +This file defines which versions of registries are used. +To update to the most recent version, you can use the command `vcpkg x-update-baseline --x-manifest-root=vcpkg`. +If you want to patch or update a specific dependency, you can copy the port for this +dependency into the folder `vcpkg/ports`. Whenever the build is reconfigured, it will check for dependencies that need to be rebuilt. -- Install Microsoft Visual Studio Community Edition as explained in ... -- Get all dependencies - - Download an SDK - - Build all dependencies yourself # 5. Building on MacOS X