From 11c70a7e60301580497b4e7086ca86e100b428c8 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 6 Oct 2024 15:33:36 +0200 Subject: [PATCH 1/5] Build with vcpkg deps --- .github/workflows/windows-qt6.yml | 132 ++++++++++++++++++ CMakeLists.txt | 71 ++++------ cmake/Bundle.cmake | 47 +++++++ cmake/NuGet.Config.in | 18 +++ cmake/VcpkgInstallDeps.cmake | 28 ++++ cmake/VcpkgToolchain.cmake | 58 ++++++++ .../ports/py-qgis-requirements/portfile.cmake | 18 +++ .../py-qgis-requirements/requirements.txt | 9 ++ vcpkg/ports/py-qgis-requirements/vcpkg.json | 16 +++ vcpkg/ports/py-qscintilla/fix-static.patch | 29 ++++ vcpkg/ports/py-qscintilla/portfile.cmake | 62 ++++++++ vcpkg/ports/py-qscintilla/vcpkg.json | 22 +++ vcpkg/triplets/x64-windows-release.cmake | 5 + vcpkg/vcpkg.json | 132 ++++++++++++++++++ 14 files changed, 606 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/windows-qt6.yml create mode 100644 cmake/Bundle.cmake create mode 100644 cmake/NuGet.Config.in create mode 100644 cmake/VcpkgInstallDeps.cmake create mode 100644 cmake/VcpkgToolchain.cmake 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 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/triplets/x64-windows-release.cmake create mode 100644 vcpkg/vcpkg.json diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml new file mode 100644 index 000000000000..68432d391f04 --- /dev/null +++ b/.github/workflows/windows-qt6.yml @@ -0,0 +1,132 @@ +--- +name: πŸͺŸ Windows Qt6 +on: + push: + branches: + - master + - release-** + pull_request: + release: + types: ['published'] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + packages: write + +jobs: + build: + name: build (windows) + runs-on: windows-2022 + + steps: + - name: 🐣 Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: 🐩 Install CMake and Ninja + uses: lukka/get-cmake@latest + with: + cmakeVersion: 3.29.6 + + - name: 🧽 Developer Command Prompt for Microsoft Visual C++ + uses: ilammy/msvc-dev-cmd@v1 + + - name: 🎑 Setup vcpkg + uses: ./.github/actions/setup-vcpkg + + - name: 🦬 Setup flex/bison + uses: robinraju/release-downloader@v1.10 + with: + repository: 'lexxmark/winflexbison' + fileName: '*.zip' + tag: 'v2.5.24' + extract: true + + - name: πŸ›οΈ Setup ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + max-size: 1G + + - name: 🌱 Install dependencies and generate project files + shell: bash + run: | + BUILD_DIR=$( cygpath "${{ github.workspace }}/build" ) + SOURCE_DIR=$( cygpath "${{ github.workspace }}" ) + + cmake -S "${SOURCE_DIR}" \ + -B "${BUILD_DIR}" \ + -G Ninja \ + -D CMAKE_BUILD_TYPE=Release \ + -D WITH_VCPKG=ON \ + -D CREATE_ZIP=ON \ + -D VCPKG_TARGET_TRIPLET=x64-windows-release \ + -D VCPKG_HOST_TRIPLET=x64-windows-release \ + -D WITH_DESKTOP=ON \ + -D WITH_3D=ON \ + -D WITH_BINDINGS=ON \ + -D ENABLE_TESTS=OFF \ + -D BUILD_WITH_QT6=ON \ + -D USE_CCACHE=ON \ + -D FLEX_EXECUTABLE="${SOURCE_DIR}/win_flex.exe" \ + -D BISON_EXECUTABLE="${SOURCE_DIR}/win_bison.exe" \ + -D SIP_BUILD_EXECUTABLE="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\Scripts\sip-build.exe" \ + -D PYUIC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\pyuic5.bat" \ + -D PYRCC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\pyrcc5.bat" \ + -D CMAKE_C_COMPILER_LAUNCHER=ccache \ + -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -D WITH_QTWEBKIT=OFF \ + -D VCPKG_INSTALL_OPTIONS="--x-buildtrees-root=C:/src" \ + -D NUGET_USERNAME=${{ github.actor }} \ + -D NUGET_TOKEN=${{ secrets.GITHUB_TOKEN }} + + - name: πŸŒ‹ Build + shell: bash + run: | + cmake --build "${{ github.workspace }}/build" --config Release + +# - uses: m-kuhn/action-tmate@patch-1 +# if: failure() + + - name: πŸ“¦ Package + shell: bash + run: | + cmake --build "${{ github.workspace }}/build" --target bundle --config Release + + - name: πŸ“¦ Create SDK +# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' + run: | + vcpkg.exe export --zip --output-dir=./sdk --x-install-root=./build/vcpkg_installed --x-manifest-root=vcpkg + + - name: πŸ“€ Upload sdk +# if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' + uses: actions/upload-artifact@v4 + with: + name: qgis-sdk-x64-windows + path: | + sdk/vcpkg-export-*.zip + + - name: πŸ“‘ Upload dep build logs + uses: actions/upload-artifact@v4 + if: failure() + with: + name: build-logs-x64-windows + path: | + C:/src/**/*.log + + - name: Save PR number to zips + run: | + echo ${{ github.event.number }} | tee pr_number + powershell Compress-Archive -update pr_number *-win64.zip + echo ${{ github.event.pull_request.head.sha }} | tee git_commit + powershell Compress-Archive -update git_commit *-win64.zip + + - name: πŸ“€ Upload bundle + uses: actions/upload-artifact@v4 + with: + name: qgis-windows-qt6 + path: | + build/*-win64.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index 13aefcfe5e78..82c4f3e81087 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,34 @@ endif() # don't relink it only the shared object changes set(CMAKE_LINK_DEPENDS_NO_SHARED ON) +set (WITH_BINDINGS TRUE CACHE BOOL "Determines whether Python bindings should be built") +set (WITH_3D TRUE CACHE BOOL "Determines whether QGIS 3D library should be built") +set (WITH_QGIS_PROCESS TRUE CACHE BOOL "Determines whether the standalone \"qgis_process\" tool should be built") +set (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built") +set (WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library should be built") +set(WITH_VCPKG FALSE CACHE BOOL "Use the vcpkg submodule for dependency management.") + +set(WITH_VCPKG TRUE CACHE BOOL "Use the vcpkg submodule for dependency management.") +set(SDK_PATH "" CACHE STRING "Build with VCPKG SDK") + +if(NOT SDK_PATH STREQUAL "") + message(STATUS "Building with SDK -- ${SDK_PATH}") + set(CMAKE_TOOLCHAIN_FILE "${SDK_PATH}/scripts/buildsystems/vcpkg.cmake") + if(APPLE AND NOT VCPKG_TARGET_TRIPLET) + set(VCPKG_TARGET_TRIPLET "x64-osx-dynamic") + endif() + set(WITH_VCPKG ON) +elseif(WITH_VCPKG) + message(STATUS "Building local dependencies with VCPKG --") + include(VcpkgToolchain) +else() + message(STATUS "Building with system libraries --") +endif() + +if(WITH_VCPKG) + list(APPEND CMAKE_PROGRAM_PATH "${VCPKG_INSTALL_PREFIX}/${VCPKG_TARGET_TRIPLET}/") +endif() + ############################################################# # Project and version set(CPACK_PACKAGE_VERSION_MAJOR "3") @@ -138,7 +166,6 @@ if(WITH_CORE) endif() endforeach (GRASS_SEARCH_VERSION) - set (WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library (and everything built on top of it) should be built") set (WITH_OAUTH2_PLUGIN TRUE CACHE BOOL "Determines whether OAuth2 authentication method plugin should be built") if(WITH_OAUTH2_PLUGIN) @@ -149,8 +176,6 @@ if(WITH_CORE) set (WITH_ANALYSIS TRUE CACHE BOOL "Determines whether QGIS analysis library should be built") - set (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built") - if(WITH_DESKTOP) if((WIN32 AND NOT MINGW) OR (UNIX AND NOT APPLE AND NOT ANDROID AND NOT IOS)) set (CRASH_HANDLER_AVAILABLE TRUE) @@ -169,17 +194,12 @@ if(WITH_CORE) endif() endif() - set (WITH_3D TRUE CACHE BOOL "Determines whether QGIS 3D library should be built") - set (WITH_QUICK FALSE CACHE BOOL "Determines whether QGIS Quick library should be built") - set (WITH_QGIS_PROCESS TRUE CACHE BOOL "Determines whether the standalone \"qgis_process\" tool should be built") - set (NATIVE_CRSSYNC_BIN "" CACHE PATH "Path to a natively compiled synccrsdb binary. If set, crssync will not build but use provided bin instead.") mark_as_advanced (NATIVE_CRSSYNC_BIN) # try to configure and build python bindings by default - set (WITH_BINDINGS TRUE CACHE BOOL "Determines whether Python bindings should be built") if (WITH_BINDINGS) # By default bindings will be installed only to QGIS directory # Someone might want to install it to python site-packages directory @@ -1218,39 +1238,8 @@ endif() ############################################################# # Enable packaging if (WITH_CORE) - # Do not warn about runtime libs when building using VS Express - if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) - set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) - endif() - - if(QGIS_INSTALL_SYS_LIBS) - include(InstallRequiredSystemLibraries) - endif() - - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "QGIS") - set(CPACK_PACKAGE_VENDOR "Open Source Geospatial Foundation") - set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") - set(CPACK_PACKAGE_INSTALL_DIRECTORY "QGIS ${COMPLETE_VERSION}") - if(WIN32 AND NOT UNIX) - # There is a bug in NSI that does not handle full unix paths properly. Make - # sure there is at least one set of four (4) backslashes. - set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/win_build\\\\sidebar.bmp") - set(CPACK_NSIS_INSTALLED_ICON_NAME "\\\\qgis.exe") - set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} QGIS") - set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\qgis.org") - set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\qgis.org") - set(CPACK_NSIS_CONTACT "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) + include(VcpkgInstallDeps) 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) 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/VcpkgInstallDeps.cmake b/cmake/VcpkgInstallDeps.cmake new file mode 100644 index 000000000000..0d45f584c844 --- /dev/null +++ b/cmake/VcpkgInstallDeps.cmake @@ -0,0 +1,28 @@ +if(NOT WITH_VCPKG) + return() +endif() + +set(VCPKG_BASE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}") + +if(MSVC) + # At least python3.dll, qgis_analysis.dll and gsl.dll are missing + # Copy everything + file(GLOB ALL_LIBS + "${VCPKG_BASE_DIR}/bin/*.dll" + ) + install(FILES ${ALL_LIBS} DESTINATION "bin") +endif() + +set(PROJ_DATA_PATH "${VCPKG_BASE_DIR}/share/proj") + +if(NOT EXISTS "${PROJ_DATA_PATH}/proj.db") + message(FATAL_ERROR "proj.db not found at ${PROJ_DATA_PATH}/proj.db") +endif() + +install(DIRECTORY "${PROJ_DATA_PATH}/" DESTINATION "${CMAKE_INSTALL_DATADIR}/proj") +install(DIRECTORY "${VCPKG_BASE_DIR}/share/gdal/" DESTINATION "${CMAKE_INSTALL_DATADIR}/gdal") +install(DIRECTORY "${VCPKG_BASE_DIR}/bin/Qca/" DESTINATION "bin/Qca") # QCA plugins +install(DIRECTORY "${VCPKG_BASE_DIR}/Qt6/" DESTINATION "bin/Qt6") # qt plugins (qml and others) +install(DIRECTORY "${VCPKG_BASE_DIR}/tools/python3/" + DESTINATION "bin" + PATTERN "*.sip" EXCLUDE) diff --git a/cmake/VcpkgToolchain.cmake b/cmake/VcpkgToolchain.cmake new file mode 100644 index 000000000000..cbcf923ceeba --- /dev/null +++ b/cmake/VcpkgToolchain.cmake @@ -0,0 +1,58 @@ +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) + list(APPEND VCPKG_MANIFEST_FEATURES "bindings") +endif() +if(WITH_3D) + list(APPEND VCPKG_MANIFEST_FEATURES "3d") +endif() +if(WITH_GUI) + list(APPEND VCPKG_MANIFEST_FEATURES "gui") +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 ${NUGET_SOURCE} -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/py-qgis-requirements/portfile.cmake b/vcpkg/ports/py-qgis-requirements/portfile.cmake new file mode 100644 index 000000000000..ff3a4c265213 --- /dev/null +++ b/vcpkg/ports/py-qgis-requirements/portfile.cmake @@ -0,0 +1,18 @@ +set(BUILD_DIR "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel") + +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 "${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) diff --git a/vcpkg/ports/py-qgis-requirements/requirements.txt b/vcpkg/ports/py-qgis-requirements/requirements.txt new file mode 100644 index 000000000000..c9acbc76ceec --- /dev/null +++ b/vcpkg/ports/py-qgis-requirements/requirements.txt @@ -0,0 +1,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 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/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/triplets/x64-windows-release.cmake b/vcpkg/triplets/x64-windows-release.cmake new file mode 100644 index 000000000000..1ae9006118fb --- /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) diff --git a/vcpkg/vcpkg.json b/vcpkg/vcpkg.json new file mode 100644 index 000000000000..02d35cb68a33 --- /dev/null +++ b/vcpkg/vcpkg.json @@ -0,0 +1,132 @@ +{ + "vcpkg-configuration": { + "default-registry": { + "kind": "git", + "reference": "7adc2e4d49e8d0efc07a369079faa6bc3dbb90f3", + "baseline": "7adc2e4d49e8d0efc07a369079faa6bc3dbb90f3", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "git", + "baseline": "6f244bbbd70800bc478cd19664f57fc96347fb3d", + "reference": "6f244bbbd70800bc478cd19664f57fc96347fb3d", + "repository": "https://github.com/open-vcpkg/python-registry", + "packages": [ + "python3", + "py-*", + "gdal", + "swig", + "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", + { + "default-features": false, + "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", + "py-pyyaml", + "py-psycopg2", + "py-qgis-requirements", + "python3" + ] + }, + "gui": { + "description": "Determines whether the QGIS gui should be built", + "dependencies": [ + "qscintilla", + "qtmultimedia", + "qwt" + ] + }, + "opencl": { + "description": "Should OpenCL support be added", + "dependencies": [ + "opencl" + ] + }, + "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 3b2e9843843ae0d6f411cf03b02a70b85e5bf20a Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sun, 6 Oct 2024 15:36:31 +0200 Subject: [PATCH 2/5] Add github action --- .github/actions/setup-vcpkg/action.yml | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/actions/setup-vcpkg/action.yml 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 From 37de274007ccec8d6e854f749a43bb66f6b4f3ce Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 7 Oct 2024 17:05:37 +0200 Subject: [PATCH 3/5] Post comment --- .github/workflows/build_artifact_comment.yml | 1 + .github/workflows/windows-qt6.yml | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_artifact_comment.yml b/.github/workflows/build_artifact_comment.yml index dbec0aefee9f..bdd94c00054c 100644 --- a/.github/workflows/build_artifact_comment.yml +++ b/.github/workflows/build_artifact_comment.yml @@ -4,6 +4,7 @@ on: workflow_run: workflows: - πŸͺŸ MingW64 Windows 64bit Build + - πŸͺŸ Windows Qt6 types: - completed diff --git a/.github/workflows/windows-qt6.yml b/.github/workflows/windows-qt6.yml index 68432d391f04..af07f5ef7a94 100644 --- a/.github/workflows/windows-qt6.yml +++ b/.github/workflows/windows-qt6.yml @@ -117,16 +117,21 @@ jobs: path: | C:/src/**/*.log - - name: Save PR number to zips - run: | - echo ${{ github.event.number }} | tee pr_number - powershell Compress-Archive -update pr_number *-win64.zip - echo ${{ github.event.pull_request.head.sha }} | tee git_commit - powershell Compress-Archive -update git_commit *-win64.zip - - name: πŸ“€ Upload bundle uses: actions/upload-artifact@v4 + id: artifact-win64-qt6 with: name: qgis-windows-qt6 path: | build/*-win64.zip + + + - name: Schedule download comment + uses: ./.github/actions/post_sticky_comment + with: + marker: mingw64-qt6 + body: | + ### πŸͺŸ Windows Qt6 builds + Download [Windows Qt6builds of this PR for testing](${{ steps.artifact-win64-qt6.outputs.artifact-url }}). + *(Built from commit ${{ github.event.pull_request.head.sha }})* + pr: ${{ github.event.number }} From 90fcb0b25613c967ef373007c5b7befab0e174e4 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Mon, 7 Oct 2024 17:09:11 +0200 Subject: [PATCH 4/5] Remove Mingw msys2 build --- .github/workflows/mingw-w64-msys2.yml | 93 --------------------------- 1 file changed, 93 deletions(-) delete mode 100644 .github/workflows/mingw-w64-msys2.yml diff --git a/.github/workflows/mingw-w64-msys2.yml b/.github/workflows/mingw-w64-msys2.yml deleted file mode 100644 index 142cba034f5b..000000000000 --- a/.github/workflows/mingw-w64-msys2.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: MSYS2 MinGW-w64 Windows 64bit Build - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: - push: - branches: - - master - - release-** - - queued_ltr_backports - paths: - - 'src/**' - - 'external/**' - - 'python/**' - - 'tests/**' - - 'ms-windows/**' - - 'CMakeLists.txt' - - '.github/workflows/mingw-w64-msys2.yml' - pull_request: - workflow_dispatch: - -permissions: - contents: read - -jobs: - mingw-w64-msys2-build: - name: MSYS2 MinGW-w64 Windows Build - runs-on: windows-latest - #strategy: - # fail-fast: false - # matrix: - # QT_VERSION: [qt5, qt6] - # MSYSTEM: [UCRT64, CLANG64] - env: - CCACHE_DIR: build/ccache - defaults: - run: - shell: msys2 {0} - steps: - - - uses: actions/checkout@v4 - - - name: Install core & build dependencies - uses: msys2/setup-msys2@v2 - with: - msystem: UCRT64 - install: base-devel - pacboy: >- - draco:p exiv2:p gdal:p gsl:p hdf5:p libxml2:p libzip:p netcdf:p opencl-icd:p pdal:p - protobuf:p proj:p qca-qt5:p qscintilla-qt5:p qt5-3d:p qt5-base:p qt5-declarative:p - qt5-gamepad:p qt5-location:p qt5-serialport:p qt5-svg:p qtkeychain-qt5:p qtwebkit:p - qwt-qt5:p spatialindex:p cc:p cmake:p ninja:p opencl-clhpp:p qt5-tools:p python:p ccache:p - python-gdal:p python-owslib:p python-pyqt5:p python-qscintilla-qt5:p pyqt-builder:p sip:p - update: true - release: false - - - name: Restore build cache - uses: actions/cache/restore@v4 - with: - path: build - key: build-ccache-mingw64-msys2-${{Β github.event.pull_request.base.ref || github.ref_name }} - restore-keys: | - build-ccache-mingw64-msys2-master - - - name: Configure QGIS - run: | - cmake \ - -G"Ninja" \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DPython_EXECUTABLE=${MINGW_PREFIX}/bin/python \ - -DWITH_3D=ON \ - -DWITH_DRACO=ON \ - -DWITH_PDAL=ON \ - -DWITH_CUSTOM_WIDGETS=ON \ - -DWITH_BINDINGS=ON \ - -DWITH_GRASS=OFF \ - -DUSE_CCACHE=ON \ - -S . \ - -B build - - - name: Build QGIS - run: | - cmake --build build - ccache -s - - - name: Save build cache for push only - uses: actions/cache/save@v4 - if: ${{ github.event_name == 'push' }} - with: - path: build - key: build-ccache-mingw64-msys2-${{ github.ref_name }}-${{ github.run_id }} From 2c894317375b91678cb706180b98d1716395df5d Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Tue, 8 Oct 2024 10:38:24 +0200 Subject: [PATCH 5/5] Document development workflow in INSTALL.md --- INSTALL.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 92cd2828863c..ca474a1b4abe 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 in 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,85 @@ 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 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. + +### 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 gives you more control +over the dependencies. + +#### 4.3.2.1 Build with an SDK + +1. Download and unzip SDK. Get the latest [QGIS master SDK](https://nightly.link/qgis/QGIS/workflows/windows-qt6/master/qgis-sdk-x64-windows.zip). +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 +# Note: you can also use RelWithDebInfo to have debug symbols in your 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. + + # 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 @@ -1085,9 +1165,6 @@ CMake option: This will flood your terminal or system log with lots of useful output from QgsDebugMsg() calls in source code. -Those lines can be reduced or augmented by setting the QGIS_DEBUG -runtime environment variable between 0 (no messages) and 5 (all messages). - If you would like to run the test suite, you will need to do so from the build directory, as it will not work with the installed/bundled app. First set the CMake option to enable tests: