master
1#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21# SPDX-License-Identifier: curl
22#
23###########################################################################
25cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
26message(STATUS "Using CMake version ${CMAKE_VERSION}")
28option(TEST_CPP "Test C++" OFF)
30if(TEST_CPP)
31 project(test-CPP-consumer CXX)
32 set(_source "test.cpp")
33else()
34 project(test-C-consumer C)
35 set(_source "test.c")
36endif()
38option(TEST_INTEGRATION_MODE "Integration mode" "find_package")
40message(STATUS "TEST_INTEGRATION_MODE: ${TEST_INTEGRATION_MODE}")
42if(TEST_INTEGRATION_MODE STREQUAL "find_package")
43 find_package(CURL REQUIRED CONFIG)
44 find_package(CURL REQUIRED CONFIG) # Double-inclusion test
45 foreach(_result_var IN ITEMS
46 CURL_FOUND
47 CURL_SUPPORTS_HTTPS
48 CURL_SUPPORTS_Largefile
49 CURL_VERSION
50 CURL_VERSION_STRING
51 )
52 if(NOT ${_result_var})
53 message(FATAL_ERROR "'${_result_var}' variable expected, but not set by the CURL package.")
54 endif()
55 endforeach()
56 # Show variables set by find_package()
57 get_cmake_property(_vars VARIABLES)
58 foreach(_var IN ITEMS ${_vars})
59 string(TOUPPER "${_var}" _var_upper)
60 if(_var_upper MATCHES "CURL")
61 get_property(_var_type CACHE ${_var} PROPERTY TYPE)
62 if(_var_type)
63 set(_var_type ":${_var_type}")
64 endif()
65 message("find_package() sets: ${_var}${_var_type} = '${${_var}}'")
66 endif()
67 endforeach()
68elseif(TEST_INTEGRATION_MODE STREQUAL "add_subdirectory")
69 set(BUILD_SHARED_LIBS ON CACHE BOOL "")
70 set(BUILD_STATIC_LIBS ON CACHE BOOL "")
71 add_subdirectory(curl)
72elseif(TEST_INTEGRATION_MODE STREQUAL "FetchContent")
73 include(FetchContent)
74 option(FROM_GIT_REPO "Git URL" "https://github.com/curl/curl.git")
75 option(FROM_GIT_TAG "Git tag" "master")
76 FetchContent_Declare(curl
77 GIT_REPOSITORY "${FROM_GIT_REPO}"
78 GIT_TAG "${FROM_GIT_TAG}"
79 GIT_SHALLOW)
80 set(BUILD_SHARED_LIBS ON CACHE BOOL "")
81 set(BUILD_STATIC_LIBS ON CACHE BOOL "")
82 FetchContent_MakeAvailable(curl)
83elseif(TEST_INTEGRATION_MODE STREQUAL "ExternalProject")
84 include(ExternalProject)
85 set(_curl_install_dir "${CMAKE_BINARY_DIR}/curl-external-install")
86 set(_curl_static_lib "${_curl_install_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}curl${CMAKE_STATIC_LIBRARY_SUFFIX}")
87 string(REPLACE " " ";" CURL_TEST_OPTS "${CURL_TEST_OPTS}")
88 if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
89 set(_download_extract_timestamp "DOWNLOAD_EXTRACT_TIMESTAMP" "ON")
90 endif()
91 ExternalProject_Add(curl-external
92 URL "${FROM_ARCHIVE}" URL_HASH "SHA256=${FROM_HASH}"
93 ${_download_extract_timestamp}
94 PREFIX "${CMAKE_BINARY_DIR}/curl-external"
95 CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${_curl_install_dir}" -DBUILD_SHARED_LIBS=OFF -DCURL_USE_LIBPSL=OFF
96 -DCURL_USE_CMAKECONFIG=OFF -DCURL_USE_PKGCONFIG=OFF
97 -DCURL_ENABLE_SSL=OFF -DCURL_ENABLE_SSL=OFF -DCURL_DISABLE_LDAP=ON -DCURL_USE_LIBSSH2=OFF -DUSE_NGHTTP2=OFF
98 -DCURL_BROTLI=OFF -DCURL_ZLIB=OFF -DCURL_ZSTD=OFF -DUSE_LIBIDN2=OFF -DENABLE_IPV6=OFF
99 ${CURL_TEST_OPTS}
100 BUILD_BYPRODUCTS "${_curl_static_lib}")
102 add_executable(test-consumer-static-fetch "${_source}")
103 add_dependencies(test-consumer-static-fetch curl-external)
104 if(WIN32)
105 target_compile_definitions(test-consumer-static-fetch PRIVATE "CURL_STATICLIB")
106 list(APPEND _curl_static_lib "ws2_32" "bcrypt")
107 endif()
108 target_include_directories(test-consumer-static-fetch PRIVATE "${_curl_install_dir}/include")
109 target_link_libraries(test-consumer-static-fetch PRIVATE "${_curl_static_lib}")
110endif()
112if(TEST_INTEGRATION_MODE STREQUAL "find_package" OR
113 TEST_INTEGRATION_MODE STREQUAL "add_subdirectory" OR
114 TEST_INTEGRATION_MODE STREQUAL "FetchContent")
116 add_executable(test-consumer-static-ns "${_source}")
117 target_link_libraries(test-consumer-static-ns PRIVATE "CURL::libcurl_static")
119 add_executable(test-consumer-shared-ns "${_source}")
120 target_link_libraries(test-consumer-shared-ns PRIVATE "CURL::libcurl_shared")
122 # Alias for either shared or static library
123 add_executable(test-consumer-selected-ns "${_source}")
124 target_link_libraries(test-consumer-selected-ns PRIVATE "CURL::libcurl")
125endif()
127if(TEST_INTEGRATION_MODE STREQUAL "add_subdirectory" OR
128 TEST_INTEGRATION_MODE STREQUAL "FetchContent")
130 add_executable(test-consumer-static-bare "${_source}")
131 target_link_libraries(test-consumer-static-bare PRIVATE "libcurl_static")
133 add_executable(test-consumer-shared-bare "${_source}")
134 target_link_libraries(test-consumer-shared-bare PRIVATE "libcurl_shared")
136 add_executable(test-consumer-selected-bare "${_source}")
137 target_link_libraries(test-consumer-selected-bare PRIVATE "libcurl")
138endif()
Diagnostics4 git calls · 128 ms
CallStatusSizeTime0128 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2002.0 KiB123 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=123 git.response.bytes=2014 git.response.cache=MISS git.response.duration_ms=123 git.fetch.wants=0b1e581bb0c0e6cc0277be5f690f0d15790b99b1 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2014 git.pkt.payload.max=1993 git.sideband.band1.bytes=1992 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e32f879e4a8821
- Request
- fd67c9d8…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format