-
Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-51007: [C++] Make uriparser an external dependency #51244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ re2 | |
| simdjson | ||
| snappy | ||
| thrift-cpp>=0.11.0 | ||
| uriparser | ||
| xsimd>=14.2 | ||
| zlib | ||
| zstd | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| "openssl", | ||
| "re2", | ||
| "snappy", | ||
| "uriparser", | ||
| "utf8proc", | ||
| "xsimd", | ||
| "zlib", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # Find uriparser. | ||
| # | ||
| # Debian, Ubuntu and several other distributions ship a liburiparser-dev that | ||
| # provides only a pkg-config file, while upstream (and vcpkg, conda-forge) | ||
| # also install a CMake package configuration. Try the CMake config first, then | ||
| # fall back to pkg-config and finally to a plain library search. | ||
|
|
||
| if(uriparserAlt_FOUND) | ||
| return() | ||
| endif() | ||
|
|
||
| set(find_package_args) | ||
| if(uriparserAlt_FIND_VERSION) | ||
| list(APPEND find_package_args ${uriparserAlt_FIND_VERSION}) | ||
| endif() | ||
| if(uriparserAlt_FIND_QUIETLY) | ||
| list(APPEND find_package_args QUIET) | ||
| endif() | ||
| find_package(uriparser ${find_package_args} CONFIG) | ||
| if(uriparser_FOUND) | ||
| set(uriparserAlt_FOUND TRUE) | ||
| return() | ||
| endif() | ||
|
|
||
| if(URIPARSER_ROOT) | ||
| find_library(URIPARSER_LIB | ||
| NAMES uriparser | ||
| PATHS ${URIPARSER_ROOT} | ||
| PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES} | ||
| NO_DEFAULT_PATH) | ||
| find_path(URIPARSER_INCLUDE_DIR | ||
| NAMES uriparser/Uri.h | ||
| PATHS ${URIPARSER_ROOT} | ||
| NO_DEFAULT_PATH | ||
| PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) | ||
| else() | ||
|
Comment on lines
+42
to
+53
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this check. We need to check only CMake package and pkg-config package. |
||
| find_package(PkgConfig QUIET) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add |
||
| pkg_check_modules(URIPARSER_PC liburiparser) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add Could you add |
||
| if(URIPARSER_PC_FOUND) | ||
| set(URIPARSER_INCLUDE_DIR "${URIPARSER_PC_INCLUDEDIR}") | ||
| list(APPEND URIPARSER_PC_LIBRARY_DIRS "${URIPARSER_PC_LIBDIR}") | ||
| find_library(URIPARSER_LIB | ||
| NAMES uriparser | ||
| PATHS ${URIPARSER_PC_LIBRARY_DIRS} | ||
| NO_DEFAULT_PATH | ||
| PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES}) | ||
| set(URIPARSER_VERSION "${URIPARSER_PC_VERSION}") | ||
| else() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this because we want to use CMake target instead of variables. |
||
| find_library(URIPARSER_LIB | ||
| NAMES uriparser | ||
| PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES}) | ||
| find_path(URIPARSER_INCLUDE_DIR | ||
| NAMES uriparser/Uri.h | ||
| PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) | ||
|
Comment on lines
+66
to
+71
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this fallback. |
||
| endif() | ||
| endif() | ||
|
|
||
| find_package_handle_standard_args(uriparserAlt | ||
| REQUIRED_VARS | ||
| URIPARSER_LIB | ||
| URIPARSER_INCLUDE_DIR | ||
| VERSION_VAR | ||
| URIPARSER_VERSION) | ||
|
|
||
| if(uriparserAlt_FOUND) | ||
| if(NOT TARGET uriparser::uriparser) | ||
| add_library(uriparser::uriparser UNKNOWN IMPORTED) | ||
| set_target_properties(uriparser::uriparser | ||
| PROPERTIES IMPORTED_LOCATION "${URIPARSER_LIB}" | ||
| INTERFACE_INCLUDE_DIRECTORIES | ||
| "${URIPARSER_INCLUDE_DIR}") | ||
| endif() | ||
| endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,7 @@ set(ARROW_THIRDPARTY_DEPENDENCIES | |
| Snappy | ||
| Substrait | ||
| Thrift | ||
| uriparser | ||
| utf8proc | ||
| xsimd | ||
| ZLIB | ||
|
|
@@ -220,6 +221,8 @@ macro(build_dependency DEPENDENCY_NAME) | |
| build_substrait() | ||
| elseif("${DEPENDENCY_NAME}" STREQUAL "Thrift") | ||
| build_thrift() | ||
| elseif("${DEPENDENCY_NAME}" STREQUAL "uriparser") | ||
| build_uriparser() | ||
| elseif("${DEPENDENCY_NAME}" STREQUAL "utf8proc") | ||
| build_utf8proc() | ||
| elseif("${DEPENDENCY_NAME}" STREQUAL "xsimd") | ||
|
|
@@ -810,6 +813,14 @@ else() | |
| ) | ||
| endif() | ||
|
|
||
| if(DEFINED ENV{ARROW_URIPARSER_URL}) | ||
| set(ARROW_URIPARSER_SOURCE_URL "$ENV{ARROW_URIPARSER_URL}") | ||
| else() | ||
| set_urls(ARROW_URIPARSER_SOURCE_URL | ||
| "https://github.com/uriparser/uriparser/releases/download/uriparser-${ARROW_URIPARSER_BUILD_VERSION}/uriparser-${ARROW_URIPARSER_BUILD_VERSION}.tar.bz2" | ||
| ) | ||
| endif() | ||
|
|
||
| if(DEFINED ENV{ARROW_UTF8PROC_URL}) | ||
| set(ARROW_UTF8PROC_SOURCE_URL "$ENV{ARROW_UTF8PROC_URL}") | ||
| else() | ||
|
|
@@ -3250,6 +3261,65 @@ if(ARROW_WITH_BZ2) | |
| endif() | ||
| endif() | ||
|
|
||
| # ---------------------------------------------------------------------- | ||
| # uriparser library | ||
|
|
||
| macro(build_uriparser) | ||
| message(STATUS "Building uriparser from source") | ||
| set(URIPARSER_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/uriparser_ep-install") | ||
| if(MSVC) | ||
| set(URIPARSER_STATIC_LIB "${URIPARSER_PREFIX}/lib/uriparser.lib") | ||
| else() | ||
| set(URIPARSER_STATIC_LIB | ||
| "${URIPARSER_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}uriparser${CMAKE_STATIC_LIBRARY_SUFFIX}" | ||
| ) | ||
| endif() | ||
|
|
||
| set(URIPARSER_CMAKE_ARGS | ||
| ${EP_COMMON_CMAKE_ARGS} | ||
| -DBUILD_SHARED_LIBS=OFF | ||
| -DCMAKE_INSTALL_LIBDIR=lib | ||
| "-DCMAKE_INSTALL_PREFIX=${URIPARSER_PREFIX}" | ||
| -DURIPARSER_BUILD_DOCS=OFF | ||
| -DURIPARSER_BUILD_TESTS=OFF | ||
| -DURIPARSER_BUILD_TOOLS=OFF | ||
| # Arrow only uses the char (not wchar_t) flavor of the API. | ||
| -DURIPARSER_BUILD_WCHAR_T=OFF) | ||
|
|
||
| if(MSVC AND ARROW_USE_STATIC_CRT) | ||
| list(APPEND URIPARSER_CMAKE_ARGS -DURIPARSER_MSVC_STATIC_CRT=ON) | ||
| endif() | ||
|
|
||
| externalproject_add(uriparser_ep | ||
| ${EP_COMMON_OPTIONS} | ||
| CMAKE_ARGS ${URIPARSER_CMAKE_ARGS} | ||
| INSTALL_DIR ${URIPARSER_PREFIX} | ||
| URL ${ARROW_URIPARSER_SOURCE_URL} | ||
| URL_HASH "SHA256=${ARROW_URIPARSER_BUILD_SHA256_CHECKSUM}" | ||
| BUILD_BYPRODUCTS "${URIPARSER_STATIC_LIB}") | ||
|
Comment on lines
+3293
to
+3299
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use FetchContent instead of ExternalProject? |
||
|
|
||
| file(MAKE_DIRECTORY "${URIPARSER_PREFIX}/include") | ||
| add_library(uriparser::uriparser STATIC IMPORTED) | ||
| set_target_properties(uriparser::uriparser | ||
| PROPERTIES IMPORTED_LOCATION "${URIPARSER_STATIC_LIB}" | ||
| INTERFACE_COMPILE_DEFINITIONS "URI_STATIC_BUILD") | ||
| target_include_directories(uriparser::uriparser BEFORE | ||
| INTERFACE "${URIPARSER_PREFIX}/include") | ||
|
|
||
| add_dependencies(uriparser::uriparser uriparser_ep) | ||
|
|
||
| list(PREPEND ARROW_BUNDLED_STATIC_LIBS uriparser::uriparser) | ||
| endmacro() | ||
|
|
||
| # uriparser is mandatory: arrow::util::Uri is part of core Arrow. | ||
| resolve_dependency(uriparser | ||
| HAVE_ALT | ||
| TRUE | ||
| REQUIRED_VERSION | ||
| "1.0.2" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we require 0.9.6 or later for Ubuntu 22.04? |
||
| PC_PACKAGE_NAMES | ||
| liburiparser) | ||
|
|
||
| macro(build_utf8proc) | ||
| message(STATUS "Building utf8proc from source") | ||
| set(UTF8PROC_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/utf8proc_ep-install") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we revert this because we already have it in this list?