Skip to content
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

Update dependencies #460

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build_freebsd_task:
cmake_build_script: |
set -e -o pipefail
echo 'Configuring CMake'
cmake -S . --preset base
cmake -S . --preset base -D TREMOTESF_WITH_HTTPLIB=system
echo 'Building Debug'
cmake --build --preset base-debug
echo 'Testing Debug'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

## [Unreleased]
### Added
- Added TREMOTESF_WITH_HTTPLIB CMake option to control how cpp-httplib test dependency is searched. Possible values:
- auto: CMake find_package call, otherwise pkg-config, otherwise bundled copy is used.
- system: CMake find_package call, otherwise pkg-config, otherwise fatal error.
- bundled: bundled copy is used.
- none: cpp-httplib is not used at all and tests that require it are disabled.
### Fixed
- Clarified dependency on kwayland-integration

Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ project(tremotesf VERSION 2.6.0 LANGUAGES ${languages})

option(TREMOTESF_QT6 "Build with Qt 6" OFF)

set(TREMOTESF_WITH_HTTPLIB "auto" CACHE STRING "Where to find cpp-httplib dependency for unit tests. Possible values are: auto, system, bundled, none")
if (NOT TREMOTESF_WITH_HTTPLIB MATCHES "^(auto|system|bundled|none)$")
message(FATAL_ERROR "Invalid TREMOTESF_WITH_HTTPLIB value ${TREMOTESF_WITH_HTTPLIB}. Possible values are: auto, system, bundled, none")
endif()

include(CTest)
include(GNUInstallDirs)

Expand Down
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"inherits": "base",
"hidden": true,
"cacheVariables": {
"CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo",
"TREMOTESF_WITH_HTTPLIB": "system",
"VCPKG_INSTALLED_DIR": "${sourceDir}/vcpkg-installed",
"VCPKG_INSTALL_OPTIONS": "--disable-metrics;--clean-buildtrees-after-build;--clean-packages-after-build",
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/vcpkg-overlay-triplets"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ cmake --install /path/to/build/directory --config Debug --prefix /path/to/instal
This example uses base-multi preset in CMakePresets.json and Ninja Multi-Config generator.
You can invoke CMake in a different way if you want.

CMake configuration options:

`TREMOTESF_QT6` - boolean, determines whether Qt 6 or Qt 5 will be used.

`TREMOTESF_WITH_HTTPLIB` - determines how cpp-httplib test dependency is searched. Possible values:
- auto: CMake find_package call, otherwise pkg-config, otherwise bundled copy is used.
- system: CMake find_package call, otherwise pkg-config, otherwise fatal error.
- bundled: bundled copy is used.
- none: cpp-httplib is not used at all and tests that require it are disabled.

### GNU/Linux
- Flatpak - [Flathub](https://flathub.org/apps/details/org.equeim.Tremotesf)

Expand Down
11 changes: 6 additions & 5 deletions org.equeim.Tremotesf.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.1.1.tar.gz",
"sha256" : "523175f792eb0ff04f9e653c90746c12655f10cb70f1d5e6d6d9491420298a08"
"url" : "https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.2.1.tar.gz",
"sha256" : "841f49f2e045b9c6365997c2a8fbf76e6f215042dda4511a5bb04bc5ebc7f88a"
}
]
},
Expand All @@ -70,8 +70,8 @@
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.14.3.tar.gz",
"sha256" : "dcf6486d9030937636d8a4f820ca9531808fd7edb283893dddbaa05f99357e63"
"url" : "https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.15.3.tar.gz",
"sha256" : "2121bbf38871bb2aafb5f7f2b9b94705366170909f434428352187cb0216124e"
}
]
},
Expand All @@ -81,7 +81,8 @@
"builddir": true,
"config-opts": [
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON"
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON",
"-DTREMOTESF_WITH_HTTPLIB=system"
],
"run-tests": true,
"sources": [
Expand Down
5 changes: 4 additions & 1 deletion packaging/rpm/tremotesf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ BuildRequires: clang
%else
BuildRequires: gcc-c++
%endif
%global tremotesf_with_httplib system
%endif

%if %{defined suse_version}
Expand All @@ -64,10 +65,12 @@ BuildRequires: appstream-glib
# OBS complains about not owned directories if hicolor-icon-theme isn't installed at build time
BuildRequires: hicolor-icon-theme
%global _metainfodir %{_datadir}/metainfo
%global tremotesf_with_httplib system
%endif

%if %{defined mageia}
BuildRequires: appstream-util
%global tremotesf_with_httplib bundled
%endif

%description
Expand All @@ -79,7 +82,7 @@ Remote GUI for Transmission BitTorrent client.


%build
%cmake -D TREMOTESF_QT6=%[%{with qt6} ? "ON" : "OFF"]
%cmake -D TREMOTESF_QT6=%[%{with qt6} ? "ON" : "OFF"] -D TREMOTESF_WITH_HTTPLIB=%{tremotesf_with_httplib}
%cmake_build

%check
Expand Down
2 changes: 1 addition & 1 deletion src/3rdparty/cpp-httplib
103 changes: 62 additions & 41 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -372,50 +372,71 @@ if (BUILD_TESTING)
add_test(NAME demangle_test COMMAND demangle_test)
target_link_libraries(demangle_test tremotesf_objects Qt::Test)

# httplib breaks backwards compatibility on each minor version (i.e. seconds component).
# With CMake we need to make separate find_package() calls for each version,
# with pkg-config we can specify range
set(httplib_supported_versions 0.14 0.13 0.12 0.11)
set(httplib_next_unsupported_version 0.15)
foreach (version ${httplib_supported_versions})
message(STATUS "Trying cpp-httplib ${version} as a CMake package")
find_package(httplib "${version}" QUIET)
if (httplib_FOUND)
break()
endif ()
endforeach ()
if (httplib_FOUND)
message(STATUS "Found cpp-httplib ${httplib_VERSION} as a CMake package")
else ()
message(STATUS "Did not found cpp-httplib as a CMake package")
list(GET httplib_supported_versions -1 oldest_supported_version)
set(module "cpp-httplib >= ${oldest_supported_version}")
message(STATUS "Trying ${module} using pkg-config")
pkg_check_modules(httplib IMPORTED_TARGET "${module}" QUIET)
if (httplib_FOUND)
message(STATUS "Found cpp-httplib ${httplib_VERSION} using pkg-config")
if (httplib_VERSION VERSION_GREATER_EQUAL httplib_next_unsupported_version)
message(WARNING "cpp-httplib version ${httplib_VERSION} is not supported. Compilation or tests may fail")
if (NOT TREMOTESF_WITH_HTTPLIB STREQUAL "none")
function(find_system_httplib)
# httplib breaks backwards compatibility on each minor version (i.e. seconds component).
# With CMake we need to make separate find_package() calls for each version,
# with pkg-config we can specify range
set(httplib_supported_versions 0.15 0.14 0.13 0.12 0.11)
set(httplib_next_unsupported_version 0.16)
foreach (version ${httplib_supported_versions})
message(STATUS "Trying cpp-httplib ${version} as a CMake package")
find_package(httplib "${version}" QUIET)
if (httplib_FOUND)
break()
endif ()
endforeach ()
if (httplib_FOUND)
message(STATUS "Found cpp-httplib ${httplib_VERSION} as a CMake package")
else ()
message(STATUS "Did not found cpp-httplib as a CMake package")
list(GET httplib_supported_versions -1 oldest_supported_version)
set(module "cpp-httplib >= ${oldest_supported_version}")
message(STATUS "Trying ${module} using pkg-config")
pkg_check_modules(httplib IMPORTED_TARGET "${module}" QUIET)
if (httplib_FOUND)
message(STATUS "Found cpp-httplib ${httplib_VERSION} using pkg-config")
if (httplib_VERSION VERSION_GREATER_EQUAL httplib_next_unsupported_version)
message(WARNING "cpp-httplib version ${httplib_VERSION} is not supported. Compilation or tests may fail")
endif ()
else ()
message(STATUS "Did not found cpp-httplib using pkg-config")
endif ()
endif ()
set(httplib_FOUND "${httplib_FOUND}" PARENT_SCOPE)
endfunction()

function(include_bundled_httplib)
set(HTTPLIB_REQUIRE_OPENSSL ON)
add_subdirectory(3rdparty/cpp-httplib EXCLUDE_FROM_ALL)
set(httplib_FOUND ON PARENT_SCOPE)
endfunction()

if (TREMOTESF_WITH_HTTPLIB STREQUAL "auto")
find_system_httplib()
if (NOT httplib_FOUND)
message(WARNING "Using bundled cpp-httplib")
include_bundled_httplib()
endif()
elseif (TREMOTESF_WITH_HTTPLIB STREQUAL "system")
find_system_httplib()
elseif (TREMOTESF_WITH_HTTPLIB STREQUAL "bundled")
message(STATUS "Using bundled cpp-httplib")
include_bundled_httplib()
else()
# We shouldn't actually get here
message(FATAL_ERROR "Invalid TREMOTESF_WITH_HTTPLIB value ${TREMOTESF_WITH_HTTPLIB}")
endif()
add_executable(requestrouter_test rpc/requestrouter_test.cpp)
target_compile_definitions(requestrouter_test PRIVATE TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/rpc/test-data" CPPHTTPLIB_OPENSSL_SUPPORT)
add_test(NAME requestrouter_test COMMAND requestrouter_test)
target_link_libraries(requestrouter_test tremotesf_objects Qt::Test)
if (TARGET PkgConfig::httplib)
target_link_libraries(requestrouter_test PkgConfig::httplib)
else ()
message(STATUS "Did not found cpp-httplib using pkg-config")
target_link_libraries(requestrouter_test httplib::httplib)
endif ()
endif ()
if (NOT httplib_FOUND)
message(WARNING "Using bundled cpp-httplib")
set(HTTPLIB_REQUIRE_OPENSSL ON)
add_subdirectory(3rdparty/cpp-httplib EXCLUDE_FROM_ALL)
endif ()

add_executable(requestrouter_test rpc/requestrouter_test.cpp)
target_compile_definitions(requestrouter_test PRIVATE TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/rpc/test-data" CPPHTTPLIB_OPENSSL_SUPPORT)
add_test(NAME requestrouter_test COMMAND requestrouter_test)
target_link_libraries(requestrouter_test tremotesf_objects Qt::Test)
if (TARGET PkgConfig::httplib)
target_link_libraries(requestrouter_test PkgConfig::httplib)
else ()
target_link_libraries(requestrouter_test httplib::httplib)
endif ()
endif()

add_executable(pathutils_test rpc/pathutils_test.cpp)
add_test(NAME pathutils_test COMMAND pathutils_test)
Expand Down
3 changes: 2 additions & 1 deletion vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json",
"default-registry": {
"kind": "builtin",
"baseline": "ac97449f48a36ecd704ac375d969b6e66115e87a"
"baseline": "3dd44b931481d7a8e9ba412621fa810232b66289"
},
"registries": [
{
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "tremotesf",
"version": "0",
"supports": "windows,osx",
Expand Down
Loading