diff --git a/cmake/FindO2.cmake b/cmake/FindO2.cmake index 421d52af182ad..800348cec9bab 100644 --- a/cmake/FindO2.cmake +++ b/cmake/FindO2.cmake @@ -1,59 +1,30 @@ -# Find O2 -# ~~~~~~~~~ -# Copyright (c) 2016, Monsanto Company, USA -# Author: Larry Shaffer, +# FindO2.cmake - Find the O2 library using pkg-config # -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# -# CMake module to search for O2 OAuth 1/2 library from: -# https://github.com/pipacs/o2 -# -# If it's found it sets O2_FOUND to TRUE -# and following variables are set: -# O2_INCLUDE_DIR -# O2_LIBRARY -# O2_LIBRARY_STATIC - -IF (O2_INCLUDE_DIR AND (O2_LIBRARY OR O2_LIBRARY_STATIC)) - SET(O2_FOUND TRUE) +# This module defines: +# - `O2_FOUND` - Set to TRUE if the library is found. +# - `O2_INCLUDE_DIRS` - Include directories for the library. +# - `O2_LIBRARIES` - Libraries to link against. +# - The alias target `o2::o2` if the library is found. -ELSE (O2_INCLUDE_DIR AND (O2_LIBRARY OR O2_LIBRARY_STATIC)) +find_package(PkgConfig REQUIRED) - FIND_PATH(O2_INCLUDE_DIR o2.h - PATHS - /usr/include - /usr/local/include - "$ENV{LIB_DIR}/include" - $ENV{INCLUDE} - PATH_SUFFIXES o2 - ) - FIND_LIBRARY(O2_LIBRARY NAMES o2 - PATHS - /usr/local/lib - /usr/lib - "$ENV{LIB_DIR}/lib" - "$ENV{LIB}" - ) - FIND_LIBRARY(O2_LIBRARY_STATIC NAMES libo2.a libo2_static.a o2_static - PATHS - /usr/local/lib - /usr/lib - "$ENV{LIB_DIR}/lib" - "$ENV{LIB}" - ) +pkg_search_module(PC_O2 IMPORTED_TARGET o2) - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(O2 DEFAULT_MSG O2_LIBRARY O2_INCLUDE_DIR) +if (PC_O2_FOUND) + set(O2_FOUND TRUE) + set(O2_INCLUDE_DIRS ${PC_O2_INCLUDE_DIRS}) + set(O2_LIBRARIES ${PC_O2_LIBRARIES}) -ENDIF (O2_INCLUDE_DIR AND (O2_LIBRARY OR O2_LIBRARY_STATIC)) + add_library(o2::o2 ALIAS PkgConfig::PC_O2) +else() + set(O2_FOUND FALSE) + if (NOT O2_FIND_QUIETLY) + message(WARNING "O2 library not found via pkg-config.") + endif() + if (O2_FIND_REQUIRED) + message(FATAL_ERROR "O2 library is required but was not found.") + endif() +endif() -IF (O2_FOUND) - IF (NOT O2_FIND_QUIETLY) - MESSAGE(STATUS "Found O2: ${O2_LIBRARY} ${O2_LIBRARY_STATIC}") - ENDIF (NOT O2_FIND_QUIETLY) -ELSE (O2_FOUND) - IF (O2_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find O2") - ENDIF (O2_FIND_REQUIRED) -ENDIF (O2_FOUND) +# Mark results for cache +mark_as_advanced(O2_INCLUDE_DIRS O2_LIBRARIES) diff --git a/src/auth/oauth2/CMakeLists.txt b/src/auth/oauth2/CMakeLists.txt index 5f9931446376b..a4348cf48f5dc 100644 --- a/src/auth/oauth2/CMakeLists.txt +++ b/src/auth/oauth2/CMakeLists.txt @@ -3,7 +3,12 @@ ######################################################## # Packages -option(WITH_INTERNAL_O2 "Download and locally include source of o2 library" ON) +if(WITH_VGPKG) + set(WITH_INTERNAL_O2_DEFAULT OFF) +else() + set(WITH_INTERNAL_O2_DEFAULT ON) +endif() +option(WITH_INTERNAL_O2 "Download and locally include source of o2 library" ${WITH_INTERNAL_O2_DEFAULT}) if(WITH_INTERNAL_O2) set(O2_SOURCE_DIR ${CMAKE_SOURCE_DIR}/external/o2/src) @@ -113,12 +118,7 @@ target_link_libraries(authmethod_oauth2_a qgis_core) if(WITH_INTERNAL_O2) target_include_directories(authmethod_oauth2_a SYSTEM PUBLIC ${O2_INCLUDE_DIR}) else() - if(NOT "${O2_LIBRARY}" STREQUAL "") - # prefer dynamic linking - target_link_libraries(authmethod_oauth2_a ${O2_LIBRARY}) - else() - target_link_libraries(authmethod_oauth2_a ${O2_LIBRARY_STATIC}) - endif() + target_link_libraries(authmethod_oauth2_a o2::o2) endif() target_include_directories(authmethod_oauth2_a PRIVATE @@ -154,12 +154,7 @@ else() if(WITH_INTERNAL_O2) target_include_directories(authmethod_oauth2 SYSTEM PUBLIC ${O2_INCLUDE_DIR}) else() - if(NOT "${O2_LIBRARY}" STREQUAL "") - # prefer dynamic linking - target_link_libraries(authmethod_oauth2 ${O2_LIBRARY}) - else() - target_link_libraries(authmethod_oauth2 ${O2_LIBRARY_STATIC}) - endif() + target_link_libraries(authmethod_oauth2 o2::o2) endif() if(WIN32) diff --git a/vcpkg/ports/o2/portfile.cmake b/vcpkg/ports/o2/portfile.cmake new file mode 100644 index 0000000000000..6810c518bfc25 --- /dev/null +++ b/vcpkg/ports/o2/portfile.cmake @@ -0,0 +1,24 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO qgis/o2 + REF "v${VERSION}" + SHA512 69f5d61e257cae41d870f1353dc86b8334065a6a6bcab108c8ccfed3fd11297654e29f6e7838b3a65a519df51ec218bef1853a53a4f06c03e4592c8e21512d8a + HEAD_REF master + PATCHES + qt6.patch +) + +vcpkg_cmake_configure( + DISABLE_PARALLEL_CONFIGURE + SOURCE_PATH ${SOURCE_PATH} + OPTIONS + -Do2_WITH_QT6=ON + -Do2_WITH_KEYCHAIN=ON +) +vcpkg_cmake_install() +vcpkg_fixup_pkgconfig() + +vcpkg_copy_pdbs() + +# Handle copyright +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/vcpkg/ports/o2/qt6.patch b/vcpkg/ports/o2/qt6.patch new file mode 100644 index 0000000000000..b53fced98274e --- /dev/null +++ b/vcpkg/ports/o2/qt6.patch @@ -0,0 +1,777 @@ +From ba9c01b12373451b89862df5f7a055ac7f826dff Mon Sep 17 00:00:00 2001 +From: Matthias Kuhn +Date: Tue, 10 Dec 2024 07:58:10 +0100 +Subject: [PATCH] [Qt6] Focus on Qt6 + +Drop Qt4 compatibility +Replace o2_WITH_QT5 with o2_WITH_QT6 +--- + .github/workflows/build.yml | 77 ++++++++++++------- + .../workflows/clang_static_analyzer/start.sh | 2 +- + .github/workflows/codeql.yml | 2 +- + .github/workflows/coverity-scan.yml | 2 +- + .github/workflows/mac/install.sh | 2 +- + CMakeLists.txt | 11 +-- + examples/CMakeLists.txt | 4 +- + examples/facebookdemo/CMakeLists.txt | 32 ++------ + .../CMakeLists.txt | 32 ++------ + examples/msgraphdemo/CMakeLists.txt | 32 ++------ + examples/msgraphdemo/msgraphdemo.cpp | 10 +-- + .../CMakeLists.txt | 34 ++------ + .../msgraphdemo.cpp | 9 ++- + examples/twitterdemo/CMakeLists.txt | 32 ++------ + examples/vimeodemo/CMakeLists.txt | 32 ++------ + examples/vimeodemo/vimeodemo.cpp | 9 ++- + examples/youtubedemo/CMakeLists.txt | 32 ++------ + src/CMakeLists.txt | 26 ++----- + src/o2.cpp | 12 --- + tests/CMakeLists.txt | 6 +- + 20 files changed, 132 insertions(+), 266 deletions(-) + +diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml +index bf1ecde..57ed038 100644 +--- a/.github/workflows/build.yml ++++ b/.github/workflows/build.yml +@@ -1,13 +1,19 @@ +-name: 🧪Qt 5 linux build ++name: 🧪 Linux build + + on: + push: ++ branches: ++ - main + pull_request: + branches: + - main + + jobs: + build: ++ strategy: ++ matrix: ++ qt_version: [5, 6] ++ + runs-on: ubuntu-latest + + steps: +@@ -16,41 +22,56 @@ jobs: + + - name: Get deps + run: | ++ if [ "${{ matrix.qt_version }}" -eq 6 ]; then ++ QT_PACKAGES="qt6-base-dev \ ++ qtkeychain-qt6-dev \ ++ qt6-webengine-dev \ ++ qt6-webengine-dev-tools \ ++ libglx-dev \ ++ libgl1-mesa-dev" ++ else ++ QT_PACKAGES="qtbase5-dev \ ++ qt5keychain-dev \ ++ qtscript5-dev \ ++ qtwebengine5-dev" ++ fi + sudo apt-get install \ + cmake \ + ninja-build \ + clang \ +- qtbase5-dev \ +- qt5keychain-dev \ +- qtscript5-dev \ +- qtwebengine5-dev ++ ${QT_PACKAGES} ++ + + - name: Build + run: | +- mkdir -p build +- cd build ++ if [ "${{ matrix.qt_version }}" -eq 6 ]; then ++ CMAKE_QT_OPTION="o2_WITH_QT6:BOOL=ON" ++ else ++ CMAKE_QT_OPTION="o2_WITH_QT6:BOOL=OFF" ++ fi + cmake -GNinja \ +- -Do2_BUILD_EXAMPLES:BOOL=ON \ +- -Do2_WITH_TESTS=ON \ +- -Do2_SHOW_TRACE:BOOL=ON \ +- -Do2_WITH_DROPBOX:BOOL=ON \ +- -Do2_WITH_FACEBOOK:BOOL=ON \ +- -Do2_WITH_FLICKR:BOOL=ON \ +- -Do2_WITH_GOOGLE:BOOL=ON \ +- -Do2_WITH_HUBIC:BOOL=ON \ +- -Do2_WITH_KEYCHAIN:BOOL=ON \ +- -Do2_WITH_MSGRAPH:BOOL=ON \ +- -Do2_WITH_OAUTH1:BOOL=ON \ +- -Do2_WITH_QT5:BOOL=ON \ +- -Do2_WITH_SKYDRIVE:BOOL=ON \ +- -Do2_WITH_SMUGMUG:BOOL=ON \ +- -Do2_WITH_SPOTIFY:BOOL=ON \ +- -Do2_WITH_SURVEYMONKEY:BOOL=ON \ +- -Do2_WITH_TWITTER:BOOL=ON \ +- -Do2_WITH_UBER:BOOL=ON \ +- -Do2_WITH_VIMEO:BOOL=ON \ +- .. +- ninja ++ -Do2_BUILD_EXAMPLES:BOOL=ON \ ++ -Do2_WITH_TESTS=ON \ ++ -Do2_SHOW_TRACE:BOOL=ON \ ++ -Do2_WITH_DROPBOX:BOOL=ON \ ++ -Do2_WITH_FACEBOOK:BOOL=ON \ ++ -Do2_WITH_FLICKR:BOOL=ON \ ++ -Do2_WITH_GOOGLE:BOOL=ON \ ++ -Do2_WITH_HUBIC:BOOL=ON \ ++ -Do2_WITH_KEYCHAIN:BOOL=ON \ ++ -Do2_WITH_MSGRAPH:BOOL=ON \ ++ -Do2_WITH_OAUTH1:BOOL=ON \ ++ -D${CMAKE_QT_OPTION} \ ++ -Do2_WITH_SKYDRIVE:BOOL=ON \ ++ -Do2_WITH_SMUGMUG:BOOL=ON \ ++ -Do2_WITH_SPOTIFY:BOOL=ON \ ++ -Do2_WITH_SURVEYMONKEY:BOOL=ON \ ++ -Do2_WITH_TWITTER:BOOL=ON \ ++ -Do2_WITH_UBER:BOOL=ON \ ++ -Do2_WITH_VIMEO:BOOL=ON \ ++ -S . \ ++ -B build ++ cmake --build build + + - name: Run Tests + run: | +diff --git a/.github/workflows/clang_static_analyzer/start.sh b/.github/workflows/clang_static_analyzer/start.sh +index af49bc3..4bbaf59 100755 +--- a/.github/workflows/clang_static_analyzer/start.sh ++++ b/.github/workflows/clang_static_analyzer/start.sh +@@ -32,7 +32,7 @@ scan-build -o scanbuildoutput -plist -v cmake -Do2_BUILD_EXAMPLES:BOOL=ON \ + -Do2_WITH_KEYCHAIN:BOOL=ON \ + -Do2_WITH_MSGRAPH:BOOL=ON \ + -Do2_WITH_OAUTH1:BOOL=ON \ +- -Do2_WITH_QT5:BOOL=ON \ ++ -Do2_WITH_QT6:BOOL=OFF \ + -Do2_WITH_SKYDRIVE:BOOL=ON \ + -Do2_WITH_SMUGMUG:BOOL=ON \ + -Do2_WITH_SPOTIFY:BOOL=ON \ +diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml +index 857e3d4..455e1e4 100644 +--- a/.github/workflows/codeql.yml ++++ b/.github/workflows/codeql.yml +@@ -98,7 +98,7 @@ jobs: + -Do2_WITH_KEYCHAIN:BOOL=ON \ + -Do2_WITH_MSGRAPH:BOOL=ON \ + -Do2_WITH_OAUTH1:BOOL=ON \ +- -Do2_WITH_QT5:BOOL=ON \ ++ -Do2_WITH_QT6:BOOL=OFF \ + -Do2_WITH_SKYDRIVE:BOOL=ON \ + -Do2_WITH_SMUGMUG:BOOL=ON \ + -Do2_WITH_SPOTIFY:BOOL=ON \ +diff --git a/.github/workflows/coverity-scan.yml b/.github/workflows/coverity-scan.yml +index c1d1c5c..e2d5446 100644 +--- a/.github/workflows/coverity-scan.yml ++++ b/.github/workflows/coverity-scan.yml +@@ -36,7 +36,7 @@ jobs: + -Do2_WITH_KEYCHAIN:BOOL=ON \ + -Do2_WITH_MSGRAPH:BOOL=ON \ + -Do2_WITH_OAUTH1:BOOL=ON \ +- -Do2_WITH_QT5:BOOL=ON \ ++ -Do2_WITH_QT6:BOOL=OFF \ + -Do2_WITH_SKYDRIVE:BOOL=ON \ + -Do2_WITH_SMUGMUG:BOOL=ON \ + -Do2_WITH_SPOTIFY:BOOL=ON \ +diff --git a/.github/workflows/mac/install.sh b/.github/workflows/mac/install.sh +index 5e5acb5..c630c05 100644 +--- a/.github/workflows/mac/install.sh ++++ b/.github/workflows/mac/install.sh +@@ -26,7 +26,7 @@ cmake -GNinja \ + -Do2_WITH_KEYCHAIN:BOOL=ON \ + -Do2_WITH_MSGRAPH:BOOL=ON \ + -Do2_WITH_OAUTH1:BOOL=ON \ +- -Do2_WITH_QT5:BOOL=ON \ ++ -Do2_WITH_QT6:BOOL=OFF \ + -Do2_WITH_SKYDRIVE:BOOL=ON \ + -Do2_WITH_SMUGMUG:BOOL=ON \ + -Do2_WITH_SPOTIFY:BOOL=ON \ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f0cd666..01fdd05 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -18,7 +18,7 @@ set(API_VERSION ${VER_MAJOR}.${VER_MINOR}.${API_VER_PATCH}) + + project(o2 VERSION ${PROJECT_VERSION}) + +-option(o2_WITH_QT5 "Use Qt5" ON) ++option(o2_WITH_QT6 "Use Qt6" ON) + + set(o2_LIB_SUFFIX "" CACHE STRING "Suffix for install 'lib' directory, e.g. 64 for lib64") + +@@ -89,14 +89,11 @@ if (o2_WITH_OAUTH1) + endif() + + if(o2_WITH_KEYCHAIN) +- if(o2_WITH_QT5) +- find_package(Qt5Keychain CONFIG REQUIRED) +- else() ++ if(o2_WITH_QT6) + find_package(Qt6Keychain CONFIG REQUIRED) ++ else() ++ find_package(Qt5Keychain CONFIG REQUIRED) + endif() +- +- message("Found QTKeychain") +- + endif(o2_WITH_KEYCHAIN) + + if(o2_WITH_TWITTER OR o2_WITH_DROPBOX OR o2_WITH_FLICKR OR o2_WITH_SMUGMUG) +diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt +index 22d7ccc..6a33548 100644 +--- a/examples/CMakeLists.txt ++++ b/examples/CMakeLists.txt +@@ -22,5 +22,7 @@ endif(o2_WITH_VIMEO) + + if (o2_WITH_MSGRAPH) + add_subdirectory(msgraphdemo) +- add_subdirectory(msgraphexternalinterceptordemo) ++ if (NOT o2_WITH_QT6) # Not yet completely updated to Qt6 compatibility, should not be too hard to do ++ add_subdirectory(msgraphexternalinterceptordemo) ++ endif (NOT o2_WITH_QT6) + endif(o2_WITH_MSGRAPH) +diff --git a/examples/facebookdemo/CMakeLists.txt b/examples/facebookdemo/CMakeLists.txt +index 61f4a7a..981866d 100644 +--- a/examples/facebookdemo/CMakeLists.txt ++++ b/examples/facebookdemo/CMakeLists.txt +@@ -6,21 +6,11 @@ set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +-if(o2_WITH_QT5) +- # Qt5 packages find their own dependencies. +- find_package(Qt5Core REQUIRED) +- find_package(Qt5Widgets REQUIRED) +- find_package(Qt5Script REQUIRED) +- find_package(Qt5Network REQUIRED) +-else(o2_WITH_QT5) +- set(QT_USE_QTNETWORK true) +- set(QT_USE_QTSCRIPT true) +- find_package(Qt4 REQUIRED) +-endif(o2_WITH_QT5) +- +-if (NOT o2_WITH_QT5) +- include( ${QT_USE_FILE} ) +-endif(NOT o2_WITH_QT5) ++if(o2_WITH_QT6) ++ find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED) ++else() ++ find_package(Qt5 COMPONENTS Core Widgets Script Network REQUIRED) ++endif() + + include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} "../../src" ) + +@@ -30,15 +20,7 @@ set(fb_SRCS + fbdemo.h + ) + +-if(NOT o2_WITH_QT5) +- add_definitions(${QT4_DEFINITIONS}) +-endif(NOT o2_WITH_QT5) +- + add_executable( fbexample ${fb_SRCS} ) + +-if(o2_WITH_QT5) +- target_link_libraries( fbexample Qt5::Core Qt5::Widgets Qt5::Network ) +- target_link_libraries( fbexample o2 ) +-else(o2_WITH_QT5) +- target_link_libraries( fbexample ${QT_LIBRARIES} o2 ) +-endif(o2_WITH_QT5) ++target_link_libraries( fbexample Qt::Core Qt::Widgets Qt::Network ) ++target_link_libraries( fbexample o2 ) +diff --git a/examples/facebookexternalinterceptordemo/CMakeLists.txt b/examples/facebookexternalinterceptordemo/CMakeLists.txt +index afc3d27..8614c7c 100644 +--- a/examples/facebookexternalinterceptordemo/CMakeLists.txt ++++ b/examples/facebookexternalinterceptordemo/CMakeLists.txt +@@ -6,21 +6,11 @@ set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +-if(o2_WITH_QT5) +- # Qt5 packages find their own dependencies. +- find_package(Qt5Core REQUIRED) +- find_package(Qt5Widgets REQUIRED) +- find_package(Qt5Script REQUIRED) +- find_package(Qt5Network REQUIRED) +-else(o2_WITH_QT5) +- set(QT_USE_QTNETWORK true) +- set(QT_USE_QTSCRIPT true) +- find_package(Qt4 REQUIRED) +-endif(o2_WITH_QT5) +- +-if (NOT o2_WITH_QT5) +- include( ${QT_USE_FILE} ) +-endif(NOT o2_WITH_QT5) ++if(o2_WITH_QT6) ++ find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED) ++else() ++ find_package(Qt5 COMPONENTS Core Widgets Script Network REQUIRED) ++endif() + + include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} "../../src" ) + +@@ -29,15 +19,7 @@ set(fb_SRCS + fbdemo.cpp + ) + +-if(NOT o2_WITH_QT5) +- add_definitions(${QT4_DEFINITIONS}) +-endif(NOT o2_WITH_QT5) +- + add_executable( fbexample ${fb_SRCS} ) + +-if(o2_WITH_QT5) +- qt5_use_modules( fbexample Core Widgets Network ) +- target_link_libraries( fbexample o2 ) +-else(o2_WITH_QT5) +- target_link_libraries( fbexample ${QT_LIBRARIES} o2 ) +-endif(o2_WITH_QT5) ++target_link_libraries( fbexample Qt::Core Qt::Widgets Qt::Network ) ++target_link_libraries( fbexample o2 ) +diff --git a/examples/msgraphdemo/CMakeLists.txt b/examples/msgraphdemo/CMakeLists.txt +index c131f4a..5fe8bd8 100644 +--- a/examples/msgraphdemo/CMakeLists.txt ++++ b/examples/msgraphdemo/CMakeLists.txt +@@ -6,21 +6,11 @@ set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +-if(o2_WITH_QT5) +- # Qt5 packages find their own dependencies. +- find_package(Qt5Core REQUIRED) +- find_package(Qt5Gui REQUIRED) +- find_package(Qt5Network REQUIRED) +- find_package(Qt5Widgets REQUIRED) +-else(o2_WITH_QT5) +- set(QT_USE_QTNETWORK true) +- set(QT_USE_QTSCRIPT true) +- find_package(Qt4 REQUIRED) +-endif(o2_WITH_QT5) +- +-if (NOT o2_WITH_QT5) +- include( ${QT_USE_FILE} ) +-endif(NOT o2_WITH_QT5) ++if(o2_WITH_QT6) ++ find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED) ++else() ++ find_package(Qt5 COMPONENTS Core Widgets Script Network REQUIRED) ++endif() + + include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} "../../src" ) + +@@ -30,15 +20,7 @@ set(msgraph_SRCS + msgraphdemo.h + ) + +-if(NOT o2_WITH_QT5) +- add_definitions(${QT4_DEFINITIONS}) +-endif(NOT o2_WITH_QT5) +- + add_executable( msgraphexample ${msgraph_SRCS} ) + +-if(o2_WITH_QT5) +- target_link_libraries( msgraphexample Qt5::Core Qt5::Gui Qt5::Network Qt5::Widgets ) +- target_link_libraries( msgraphexample o2 ) +-else(o2_WITH_QT5) +- target_link_libraries( msgraphexample ${QT_LIBRARIES} o2 ) +-endif(o2_WITH_QT5) ++target_link_libraries( msgraphexample Qt::Core Qt::Widgets Qt::Network ) ++target_link_libraries( msgraphexample o2 ) +diff --git a/examples/msgraphdemo/msgraphdemo.cpp b/examples/msgraphdemo/msgraphdemo.cpp +index 8095b03..b38630d 100644 +--- a/examples/msgraphdemo/msgraphdemo.cpp ++++ b/examples/msgraphdemo/msgraphdemo.cpp +@@ -4,7 +4,7 @@ + #include + #include + #include +-#include ++#include + + #include "msgraphdemo.h" + #include "o0globals.h" +@@ -114,13 +114,13 @@ void MsgraphDemo::onFinished(int requestId, QNetworkReply::NetworkError error, Q + return; + } + +- QRegExp userPrincipalNameRE("\"userPrincipalName\":\"([^\"]+)\""); +- if (userPrincipalNameRE.indexIn(reply) == -1) { ++ QRegularExpression userPrincipalNameRE("\"userPrincipalName\":\"([^\"]+)\""); ++ QRegularExpressionMatch match = userPrincipalNameRE.match(reply); ++ if (!match.hasMatch()) { + qDebug() << "Can not parse reply:" << reply; + emit userPrincipalNameFailed(); + return; + } +- +- qInfo() << "userPrincipalName: " << userPrincipalNameRE.cap(1); ++ qInfo() << "userPrincipalName: " << match.captured(0); + emit userPrincipalNameReceived(); + } +diff --git a/examples/msgraphexternalinterceptordemo/CMakeLists.txt b/examples/msgraphexternalinterceptordemo/CMakeLists.txt +index 4b4373b..b2ba18b 100644 +--- a/examples/msgraphexternalinterceptordemo/CMakeLists.txt ++++ b/examples/msgraphexternalinterceptordemo/CMakeLists.txt +@@ -7,23 +7,11 @@ set(CMAKE_AUTOUIC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +-if(o2_WITH_QT5) +- # Qt5 packages find their own dependencies. +- find_package(Qt5Core REQUIRED) +- find_package(Qt5Widgets REQUIRED) +- find_package(Qt5Script REQUIRED) +- find_package(Qt5Network REQUIRED) +- find_package(Qt5WebEngine REQUIRED) +- find_package(Qt5WebEngineWidgets REQUIRED) +-else(o2_WITH_QT5) +- set(QT_USE_QTNETWORK true) +- set(QT_USE_QTSCRIPT true) +- find_package(Qt4 REQUIRED) +-endif(o2_WITH_QT5) +- +-if (NOT o2_WITH_QT5) +- include( ${QT_USE_FILE} ) +-endif(NOT o2_WITH_QT5) ++if(o2_WITH_QT6) ++ find_package(Qt6 COMPONENTS Core Widgets Network WebEngineCore WebEngineWidgets REQUIRED) ++else() ++ find_package(Qt5 COMPONENTS Core Widgets Script Network WebEngine WebEngineWidgets REQUIRED) ++endif() + + include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} "../../src" ) + +@@ -34,15 +22,7 @@ set(msgraph_SRCS + webenginepage.cpp + ) + +-if(NOT o2_WITH_QT5) +- add_definitions(${QT4_DEFINITIONS}) +-endif(NOT o2_WITH_QT5) +- + add_executable( msgraphexternalinterceptorexample ${msgraph_SRCS} ) + +-if(o2_WITH_QT5) +- target_link_libraries( msgraphexternalinterceptorexample Qt5::Core Qt5::Widgets Qt5::Network Qt5::WebEngine Qt5::WebEngineWidgets ) +- target_link_libraries( msgraphexternalinterceptorexample o2 ) +-else(o2_WITH_QT5) +- target_link_libraries( msgraphexternalinterceptorexample ${QT_LIBRARIES} o2 ) +-endif(o2_WITH_QT5) ++target_link_libraries( msgraphexternalinterceptorexample Qt::Core Qt::Widgets Qt::Network Qt::WebEngineWidgets ) ++target_link_libraries( msgraphexternalinterceptorexample o2 ) +diff --git a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp +index 0e80536..73ae3dd 100644 +--- a/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp ++++ b/examples/msgraphexternalinterceptordemo/msgraphdemo.cpp +@@ -5,6 +5,7 @@ + #include + #include + #include ++#include + + #include "msgraphdemo.h" + #include "o0globals.h" +@@ -154,13 +155,13 @@ void MsgraphDemo::onFinished(int requestId, QNetworkReply::NetworkError error, Q + return; + } + +- QRegExp userPrincipalNameRE("\"userPrincipalName\":\"([^\"]+)\""); +- if (userPrincipalNameRE.indexIn(reply) == -1) { ++ QRegularExpression userPrincipalNameRE("\"userPrincipalName\":\"([^\"]+)\""); ++ QRegularExpressionMatch match = userPrincipalNameRE.match(reply); ++ if (!match.hasMatch()) { + qDebug() << "Can not parse reply:" << reply; + emit userPrincipalNameFailed(); + return; + } +- +- qInfo() << "userPrincipalName: " << userPrincipalNameRE.cap(1); ++ qInfo() << "userPrincipalName: " << match.captured(0); + emit userPrincipalNameReceived(); + } +diff --git a/examples/twitterdemo/CMakeLists.txt b/examples/twitterdemo/CMakeLists.txt +index ac677bd..7eb2d95 100644 +--- a/examples/twitterdemo/CMakeLists.txt ++++ b/examples/twitterdemo/CMakeLists.txt +@@ -6,22 +6,12 @@ set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +-if(o2_WITH_QT5) +- # Qt5 packages find their own dependencies. +- find_package(Qt5Core REQUIRED) +- find_package(Qt5Widgets REQUIRED) +- find_package(Qt5Script REQUIRED) +- find_package(Qt5Network REQUIRED) +-else(o2_WITH_QT5) +- set(QT_USE_QTNETWORK true) +- set(QT_USE_QTSCRIPT true) +- find_package(Qt4 REQUIRED) +-endif(o2_WITH_QT5) ++if(o2_WITH_QT6) ++ find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED) ++else() ++ find_package(Qt5 COMPONENTS Core Widgets Script Network REQUIRED) ++endif() + +-if (NOT o2_WITH_QT5) +- include( ${QT_USE_FILE} ) +-endif(NOT o2_WITH_QT5) +- + include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} "../../src" ) + + set(fb_SRCS +@@ -29,15 +19,7 @@ set(fb_SRCS + tweeter.cpp + ) + +-if(NOT o2_WITH_QT5) +- add_definitions(${QT4_DEFINITIONS}) +-endif(NOT o2_WITH_QT5) +- + add_executable( twitterexample ${fb_SRCS} ) + +-if(o2_WITH_QT5) +- target_link_libraries( twitterexample Qt5::Core Qt5::Widgets Qt5::Network ) +- target_link_libraries( twitterexample o2 ) +-else(o2_WITH_QT5) +- target_link_libraries( twitterexample ${QT_LIBRARIES} o2 ) +-endif(o2_WITH_QT5) ++target_link_libraries( twitterexample Qt::Core Qt::Widgets Qt::Network ) ++target_link_libraries( twitterexample o2 ) +diff --git a/examples/vimeodemo/CMakeLists.txt b/examples/vimeodemo/CMakeLists.txt +index cc417bd..5145d76 100644 +--- a/examples/vimeodemo/CMakeLists.txt ++++ b/examples/vimeodemo/CMakeLists.txt +@@ -6,21 +6,11 @@ set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +-if(o2_WITH_QT5) +- # Qt5 packages find their own dependencies. +- find_package(Qt5Core REQUIRED) +- find_package(Qt5Gui REQUIRED) +- find_package(Qt5Network REQUIRED) +- find_package(Qt5Widgets REQUIRED) +-else(o2_WITH_QT5) +- set(QT_USE_QTNETWORK true) +- set(QT_USE_QTSCRIPT true) +- find_package(Qt4 REQUIRED) +-endif(o2_WITH_QT5) +- +-if (NOT o2_WITH_QT5) +- include( ${QT_USE_FILE} ) +-endif(NOT o2_WITH_QT5) ++if(o2_WITH_QT6) ++ find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED) ++else() ++ find_package(Qt5 COMPONENTS Core Widgets Script Network REQUIRED) ++endif() + + include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} "../../src" ) + +@@ -30,15 +20,7 @@ set(vimeo_SRCS + vimeodemo.h + ) + +-if(NOT o2_WITH_QT5) +- add_definitions(${QT4_DEFINITIONS}) +-endif(NOT o2_WITH_QT5) +- + add_executable( vimeoexample ${vimeo_SRCS} ) + +-if(o2_WITH_QT5) +- target_link_libraries( vimeoexample Qt5::Core Qt5::Gui Qt5::Network Qt5::Widgets ) +- target_link_libraries( vimeoexample o2 ) +-else(o2_WITH_QT5) +- target_link_libraries( vimeoexample ${QT_LIBRARIES} o2 ) +-endif(o2_WITH_QT5) ++target_link_libraries( vimeoexample Qt::Core Qt::Widgets Qt::Network ) ++target_link_libraries( vimeoexample o2 ) +diff --git a/examples/vimeodemo/vimeodemo.cpp b/examples/vimeodemo/vimeodemo.cpp +index 49d43d0..50f6e01 100644 +--- a/examples/vimeodemo/vimeodemo.cpp ++++ b/examples/vimeodemo/vimeodemo.cpp +@@ -4,7 +4,7 @@ + #include + #include + #include +-#include ++#include + + #include "vimeodemo.h" + #include "o0globals.h" +@@ -111,13 +111,14 @@ void VimeoDemo::onFinished(int requestId, QNetworkReply::NetworkError error, QBy + return; + } + +- QRegExp nameRE("\"name\":\"([^\"]+)\""); +- if (nameRE.indexIn(reply) == -1) { ++ QRegularExpression nameRE("\"name\":\"([^\"]+)\""); ++ QRegularExpressionMatch match = nameRE.match(reply); ++ if (!match.hasMatch()) { + qDebug() << "Can not parse reply:" << reply; + emit userNameFailed(); + return; + } + +- qInfo() << "User name: " << nameRE.cap(1); ++ qInfo() << "User name: " << match.captured(0); + emit userNameReceived(); + } +diff --git a/examples/youtubedemo/CMakeLists.txt b/examples/youtubedemo/CMakeLists.txt +index 530d30a..7a0eba0 100644 +--- a/examples/youtubedemo/CMakeLists.txt ++++ b/examples/youtubedemo/CMakeLists.txt +@@ -6,21 +6,11 @@ set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +-if(o2_WITH_QT5) +- # Qt5 packages find their own dependencies. +- find_package(Qt5Core REQUIRED) +- find_package(Qt5Gui REQUIRED) +- find_package(Qt5Network REQUIRED) +- find_package(Qt5Widgets REQUIRED) +-else(o2_WITH_QT5) +- set(QT_USE_QTNETWORK true) +- set(QT_USE_QTSCRIPT true) +- find_package(Qt4 REQUIRED) +-endif(o2_WITH_QT5) +- +-if (NOT o2_WITH_QT5) +- include( ${QT_USE_FILE} ) +-endif(NOT o2_WITH_QT5) ++if(o2_WITH_QT6) ++ find_package(Qt6 COMPONENTS Core Widgets Network REQUIRED) ++else() ++ find_package(Qt5 COMPONENTS Core Widgets Script Network REQUIRED) ++endif() + + include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} "../../src" ) + +@@ -30,15 +20,7 @@ set(yt_SRCS + ytdemo.h + ) + +-if(NOT o2_WITH_QT5) +- add_definitions(${QT4_DEFINITIONS}) +-endif(NOT o2_WITH_QT5) +- + add_executable( ytexample ${yt_SRCS} ) + +-if(o2_WITH_QT5) +- target_link_libraries( ytexample Qt5::Core Qt5::Gui Qt5::Network Qt5::Widgets ) +- target_link_libraries( ytexample o2 ) +-else(o2_WITH_QT5) +- target_link_libraries( ytexample ${QT_LIBRARIES} o2 ) +-endif(o2_WITH_QT5) ++target_link_libraries( ytexample Qt::Core Qt::Widgets Qt::Network ) ++target_link_libraries( ytexample o2 ) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 323f8c2..7f144bc 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -4,19 +4,11 @@ set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +-if(o2_WITH_QT5) ++if(o2_WITH_QT6) ++ find_package(Qt6 COMPONENTS Core Network REQUIRED) ++else() + find_package(Qt5 COMPONENTS Core Network REQUIRED) +-else(o2_WITH_QT5) +- set(QT_USE_QTNETWORK true) +- set(QT_USE_QTSCRIPT true) +- find_package(Qt4 REQUIRED) +-endif(o2_WITH_QT5) +-#find_package(QJson REQUIRED) +- +-if (NOT o2_WITH_QT5) +- include( ${QT_USE_FILE} ) +-endif(NOT o2_WITH_QT5) +- ++endif() + + set( o2_SRCS + o2.cpp +@@ -205,10 +197,6 @@ if(o2_WITH_KEYCHAIN) + + endif(o2_WITH_KEYCHAIN) + +-if(NOT o2_WITH_QT5) +- add_definitions(${QT4_DEFINITIONS}) +-endif(NOT o2_WITH_QT5) +- + if(BUILD_SHARED_LIBS AND APPLE AND POLICY CMP0042) # in CMake >= 2.8.12 + cmake_policy(SET CMP0042 OLD) + set(CMAKE_MACOSX_RPATH OFF) # don't embed @rpath in install name +@@ -220,11 +208,7 @@ if(BUILD_SHARED_LIBS) + add_definitions( -DO2_SHARED_LIB ) + endif(BUILD_SHARED_LIBS) + +-if(o2_WITH_QT5) +- target_link_libraries( o2 Qt5::Core Qt5::Network ${LINK_TARGETS}) +-else(o2_WITH_QT5) +- target_link_libraries( o2 ${QT_LIBRARIES} ${LINK_TARGETS}) +-endif(o2_WITH_QT5) ++target_link_libraries( o2 Qt::Core Qt::Network ${LINK_TARGETS}) + + if(BUILD_SHARED_LIBS) + if(APPLE) +diff --git a/src/o2.cpp b/src/o2.cpp +index e63c830..ebbb7b3 100644 +--- a/src/o2.cpp ++++ b/src/o2.cpp +@@ -10,16 +10,8 @@ + #include + #include + #include +- +-#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + #include +-#endif +- +-#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + #include +-#else +-#include +-#endif + + #include "o2.h" + #include "o2pollserver.h" +@@ -197,12 +189,8 @@ void O2::link() { + + if (grantFlow_ == GrantFlowAuthorizationCode || grantFlow_ == GrantFlowImplicit || grantFlow_ == GrantFlowPkce) { + +-#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + const thread_local QRegularExpression rx("([^a-zA-Z0-9]|[-])"); + QString uniqueState = QUuid::createUuid().toString().remove(rx); +-#else +- QString uniqueState = QUuid::createUuid().toString().remove(QRegExp("([^a-zA-Z0-9]|[-])")); +-#endif + if (useExternalWebInterceptor_) { + // Save redirect URI, as we have to reuse it when requesting the access token + redirectUri_ = localhostPolicy_.arg(localPort()); +diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt +index 4fa2f60..671de99 100644 +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt +@@ -7,10 +7,10 @@ set(CMAKE_AUTORCC ON) + set(CMAKE_AUTOUIC ON) + + # Find Qt packages needed for testing +-if(o2_WITH_QT5) +- find_package(Qt5 5.15 COMPONENTS Core Network Test REQUIRED) +-else() ++if(o2_WITH_QT6) + find_package(Qt6 COMPONENTS Core Network Test REQUIRED) ++else() ++ find_package(Qt5 5.15 COMPONENTS Core Network Test REQUIRED) + endif() + + # Source files from src directory diff --git a/vcpkg/ports/o2/vcpkg.json b/vcpkg/ports/o2/vcpkg.json new file mode 100644 index 0000000000000..e40da1926ce94 --- /dev/null +++ b/vcpkg/ports/o2/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "o2", + "version": "0.1", + "description": "OAuth 2.0 for Qt", + "homepage": "https://github.com/qgis/o2", + "license": "BSD-2-Clause", + "dependencies": [ + "qtkeychain-qt6", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/vcpkg/vcpkg.json b/vcpkg/vcpkg.json index c84511c70188d..0aaff00240230 100644 --- a/vcpkg/vcpkg.json +++ b/vcpkg/vcpkg.json @@ -61,6 +61,7 @@ "libzip", "meshoptimizer", "nlohmann-json", + "o2", "pdal", "proj", "protobuf",