This commit is contained in:
Matthias Kuhn 2024-12-10 09:19:35 +01:00
parent d1de2574de
commit d255d21eff
5 changed files with 73 additions and 66 deletions

View File

@ -1,59 +1,30 @@
# Find O2
# ~~~~~~~~~
# Copyright (c) 2016, Monsanto Company, USA
# Author: Larry Shaffer, <lshaffer (at) boundlessgeo (dot) com>
# 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
# 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.
IF (O2_INCLUDE_DIR AND (O2_LIBRARY OR O2_LIBRARY_STATIC))
SET(O2_FOUND TRUE)
find_package(PkgConfig REQUIRED)
ELSE (O2_INCLUDE_DIR AND (O2_LIBRARY OR O2_LIBRARY_STATIC))
pkg_search_module(PC_O2 IMPORTED_TARGET o2)
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}"
)
if (PC_O2_FOUND)
set(O2_FOUND TRUE)
set(O2_INCLUDE_DIRS ${PC_O2_INCLUDE_DIRS})
set(O2_LIBRARIES ${PC_O2_LIBRARIES})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(O2 DEFAULT_MSG O2_LIBRARY O2_INCLUDE_DIR)
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()
ENDIF (O2_INCLUDE_DIR AND (O2_LIBRARY OR O2_LIBRARY_STATIC))
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)

View File

@ -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)

View File

@ -0,0 +1,22 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO qgis/o2
REF "v${VERSION}"
SHA512 e0116a8f72e8c98ef4237e36598a8f246319a30bb5bfab629e3220e7b819b1e9028c2e6caa4c92f17c4b0548c94c242120c5b4750abce2441a2db5d88b2e22f5
HEAD_REF master
)
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)

18
vcpkg/ports/o2/vcpkg.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "o2",
"version": "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
}
]
}

View File

@ -61,6 +61,7 @@
"libzip",
"meshoptimizer",
"nlohmann-json",
"o2",
"pdal",
"proj",
"protobuf",