mirror of
https://github.com/BlackMATov/curly.hpp.git
synced 2025-12-12 19:18:28 +07:00
@@ -1,19 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
|
||||
|
||||
ROOT_DIR="${DIR}/.."
|
||||
BUILD_DIR="${ROOT_DIR}/build/coverage"
|
||||
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_COVERAGE=ON)
|
||||
(cd "${BUILD_DIR}" && cmake --build .)
|
||||
|
||||
(cd "${BUILD_DIR}" && lcov -d . -z)
|
||||
(cd "${BUILD_DIR}" && ctest --verbose)
|
||||
|
||||
(cd "${BUILD_DIR}" && lcov -d . -c -o "coverage.info")
|
||||
(cd "${BUILD_DIR}" && lcov -r "coverage.info" "*/usr/*" "*/untests/*" -o "coverage.info")
|
||||
(cd "${BUILD_DIR}" && lcov -l "coverage.info")
|
||||
|
||||
bash <(curl -s https://codecov.io/bash) -f "${BUILD_DIR}/coverage.info" || echo "Codecov did not collect coverage reports"
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
|
||||
|
||||
ROOT_DIR="${DIR}/.."
|
||||
BUILD_DIR="${ROOT_DIR}/build/darwin_release"
|
||||
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release)
|
||||
(cd "${BUILD_DIR}" && cmake --build .)
|
||||
(cd "${BUILD_DIR}" && ctest --verbose)
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
|
||||
|
||||
ROOT_DIR="${DIR}/.."
|
||||
BUILD_DIR="${ROOT_DIR}/build/linux_release"
|
||||
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release)
|
||||
(cd "${BUILD_DIR}" && cmake --build .)
|
||||
(cd "${BUILD_DIR}" && ctest --verbose)
|
||||
@@ -1,19 +0,0 @@
|
||||
@echo off
|
||||
set DIR=%~dp0
|
||||
|
||||
set ROOT_DIR=%DIR%..\
|
||||
set BUILD_DIR=%ROOT_DIR%build\windows_release_x64\
|
||||
|
||||
if not exist %BUILD_DIR% mkdir %BUILD_DIR% || goto :error
|
||||
|
||||
pushd %BUILD_DIR% || goto :error
|
||||
cmake %ROOT_DIR% -A x64 || goto :error
|
||||
cmake --build . --config Release || goto :error
|
||||
ctest --verbose || goto :error
|
||||
popd || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
@@ -1,19 +0,0 @@
|
||||
@echo off
|
||||
set DIR=%~dp0
|
||||
|
||||
set ROOT_DIR=%DIR%..\
|
||||
set BUILD_DIR=%ROOT_DIR%build\windows_release_x86\
|
||||
|
||||
if not exist %BUILD_DIR% mkdir %BUILD_DIR% || goto :error
|
||||
|
||||
pushd %BUILD_DIR% || goto :error
|
||||
cmake %ROOT_DIR% -A Win32 || goto :error
|
||||
cmake --build . --config Release || goto :error
|
||||
ctest --verbose || goto :error
|
||||
popd || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
16
.github/workflows/coverage.yml
vendored
16
.github/workflows/coverage.yml
vendored
@@ -1,16 +0,0 @@
|
||||
name: coverage
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-10.15
|
||||
name: "coverage"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install lcov by Homebrew
|
||||
run: brew install lcov
|
||||
- name: Build && Test && Upload
|
||||
run: .ci/build_coverage.sh
|
||||
21
.github/workflows/darwin.yml
vendored
21
.github/workflows/darwin.yml
vendored
@@ -10,15 +10,22 @@ jobs:
|
||||
matrix:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/macos
|
||||
- { os: "macos-10.15", xcode: "10.3" }
|
||||
- { os: "macos-10.15", xcode: "11.7" }
|
||||
- { os: "macos-10.15", xcode: "12.4" }
|
||||
- { os: "macos-10.15", xcode: "10.3", arch: "x64" }
|
||||
- { os: "macos-12", xcode: "14.2", arch: "x64" }
|
||||
name: "xcode-${{matrix.config.xcode}}"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup
|
||||
run: brew install cmake ninja
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
submodules: true
|
||||
- name: Select Xcode
|
||||
run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app"
|
||||
- name: Build && Test
|
||||
run: .ci/build_darwin.sh
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset macos-${{matrix.config.arch}}
|
||||
cmake --build --preset macos-${{matrix.config.arch}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset macos-${{matrix.config.arch}}-release
|
||||
24
.github/workflows/linux.yml
vendored
24
.github/workflows/linux.yml
vendored
@@ -11,21 +11,21 @@ jobs:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/linux
|
||||
- { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" }
|
||||
- { os: "ubuntu-20.04", cc: "gcc-8", cxx: "g++-8" }
|
||||
- { os: "ubuntu-20.04", cc: "gcc-9", cxx: "g++-9" }
|
||||
- { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" }
|
||||
- { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" }
|
||||
- { os: "ubuntu-20.04", cc: "clang-8", cxx: "clang++-8" }
|
||||
- { os: "ubuntu-20.04", cc: "clang-9", cxx: "clang++-9" }
|
||||
- { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" }
|
||||
- { os: "ubuntu-22.04", cc: "gcc-12", cxx: "g++-12" }
|
||||
- { os: "ubuntu-22.04", cc: "clang-14", cxx: "clang++-14" }
|
||||
name: "${{matrix.config.cxx}}"
|
||||
steps:
|
||||
- name: Setup
|
||||
run: sudo apt-get -y install "${{matrix.config.cc}}" "${{matrix.config.cxx}}"
|
||||
run: sudo apt-get -y install cmake ninja-build ${{matrix.config.cc}} ${{matrix.config.cxx}}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build && Test
|
||||
run: .ci/build_linux.sh
|
||||
env: { CC: "${{matrix.config.cc}}", CXX: "${{matrix.config.cxx}}" }
|
||||
submodules: true
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset linux-${{matrix.config.cc}}
|
||||
cmake --build --preset linux-${{matrix.config.cc}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset linux-${{matrix.config.cc}}-release
|
||||
|
||||
28
.github/workflows/windows.yml
vendored
28
.github/workflows/windows.yml
vendored
@@ -10,14 +10,24 @@ jobs:
|
||||
matrix:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/win
|
||||
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x86" }
|
||||
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x64" }
|
||||
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x86" }
|
||||
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x64" }
|
||||
name: "${{matrix.config.vs}} ${{matrix.config.arch}}"
|
||||
- { os: "windows-2019", vc: "msvc2019", arch: "x86" }
|
||||
- { os: "windows-2019", vc: "msvc2019", arch: "x64" }
|
||||
- { os: "windows-2022", vc: "msvc2022", arch: "x86" }
|
||||
- { os: "windows-2022", vc: "msvc2022", arch: "x64" }
|
||||
name: "${{matrix.config.vc}} ${{matrix.config.arch}}"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup
|
||||
run: choco install cmake ninja
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build && Test
|
||||
run: .ci\build_windows_${{matrix.config.arch}}.bat
|
||||
submodules: true
|
||||
- name: Select MSVC
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}
|
||||
cmake --build --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
|
||||
- name: Test
|
||||
run: |
|
||||
ctest --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
|
||||
|
||||
18
.vscode/settings.json
vendored
18
.vscode/settings.json
vendored
@@ -1,4 +1,22 @@
|
||||
{
|
||||
"[cpp]": {
|
||||
"files.encoding": "utf8",
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
},
|
||||
"[cmake]": {
|
||||
"files.encoding": "utf8",
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
},
|
||||
"[python]": {
|
||||
"files.encoding": "utf8",
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
},
|
||||
"clangd.arguments": [
|
||||
"--all-scopes-completion",
|
||||
"--background-index",
|
||||
|
||||
105
CMakeLists.txt
105
CMakeLists.txt
@@ -1,54 +1,14 @@
|
||||
# 3.11 version is required for `FetchContent`
|
||||
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
|
||||
|
||||
if(NOT DEFINED PROJECT_NAME)
|
||||
set(BUILD_AS_STANDALONE ON)
|
||||
else()
|
||||
set(BUILD_AS_STANDALONE OFF)
|
||||
endif()
|
||||
|
||||
project(curly.hpp)
|
||||
project(curly.hpp
|
||||
VERSION "0.0.1"
|
||||
DESCRIPTION "Simple cURL C++17 wrapper"
|
||||
HOMEPAGE_URL "https://github.com/blackmatov/curly.hpp")
|
||||
|
||||
option(USE_STATIC_CRT "Use static C runtime library" OFF)
|
||||
option(USE_SYSTEM_CURL "Build with cURL from system paths" OFF)
|
||||
option(USE_EMBEDDED_CURL "Build with embedded cURL library" ON)
|
||||
|
||||
#
|
||||
# linking
|
||||
#
|
||||
|
||||
if(MSVC AND USE_STATIC_CRT)
|
||||
foreach(flag CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
if(${flag} MATCHES "/MDd")
|
||||
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
#
|
||||
# coverage
|
||||
#
|
||||
|
||||
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||
if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
|
||||
set(COVERAGE_FLAGS "--coverage")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
endif()
|
||||
|
||||
#
|
||||
# library
|
||||
#
|
||||
@@ -66,6 +26,9 @@ add_library(${PROJECT_NAME} STATIC
|
||||
${CURLY_HPP_HEADERS}
|
||||
${CURLY_HPP_SOURCES})
|
||||
|
||||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS
|
||||
${PROJECT_NAME})
|
||||
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES
|
||||
${CURLY_HPP_HEADERS}
|
||||
${CURLY_HPP_SOURCES})
|
||||
@@ -98,6 +61,11 @@ target_compile_options(${PROJECT_NAME}
|
||||
-Wno-weak-vtables
|
||||
>)
|
||||
|
||||
if(USE_STATIC_CRT)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
endif()
|
||||
|
||||
#
|
||||
# dependencies
|
||||
#
|
||||
@@ -115,8 +83,7 @@ if(USE_EMBEDDED_CURL)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
embedded_curl
|
||||
GIT_REPOSITORY https://github.com/curl/curl
|
||||
GIT_TAG curl-7_84_0)
|
||||
GIT_REPOSITORY https://github.com/curl/curl)
|
||||
|
||||
FetchContent_GetProperties(embedded_curl)
|
||||
if(NOT embedded_curl_POPULATED)
|
||||
@@ -157,27 +124,29 @@ if(USE_EMBEDDED_CURL)
|
||||
endif()
|
||||
|
||||
#
|
||||
# BUILD_AS_STANDALONE
|
||||
# DEVELOPER
|
||||
#
|
||||
|
||||
if(NOT ${BUILD_AS_STANDALONE})
|
||||
return()
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/WX /W4>
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
-Werror -Wall -Wextra -Wpedantic>
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Werror -Weverything -Wconversion>)
|
||||
|
||||
enable_testing()
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(EnableASan)
|
||||
include(EnableGCov)
|
||||
include(EnableUBSan)
|
||||
|
||||
add_subdirectory(untests)
|
||||
endif()
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/WX /W4>
|
||||
PUBLIC
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
-Werror -Wall -Wextra -Wpedantic>
|
||||
PUBLIC
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Werror -Weverything -Wconversion>)
|
||||
|
||||
enable_testing()
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
add_subdirectory(untests)
|
||||
|
||||
342
CMakePresets.json
Normal file
342
CMakePresets.json
Normal file
@@ -0,0 +1,342 @@
|
||||
{
|
||||
"version": 3,
|
||||
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 21,
|
||||
"patch": 0
|
||||
},
|
||||
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "ninja-base",
|
||||
"hidden": true,
|
||||
"generator": "Ninja Multi-Config",
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"installDir": "${sourceDir}/install/${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-base",
|
||||
"hidden": true,
|
||||
"inherits": "ninja-base",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Linux"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-7",
|
||||
"inherits": "linux-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "clang-7",
|
||||
"CMAKE_CXX_COMPILER": "clang++-7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-14",
|
||||
"inherits": "linux-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "clang-14",
|
||||
"CMAKE_CXX_COMPILER": "clang++-14"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-7",
|
||||
"inherits": "linux-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "gcc-7",
|
||||
"CMAKE_CXX_COMPILER": "g++-7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-12",
|
||||
"inherits": "linux-base",
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "gcc-12",
|
||||
"CMAKE_CXX_COMPILER": "g++-12"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-base",
|
||||
"hidden": true,
|
||||
"inherits": "ninja-base",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Darwin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64",
|
||||
"inherits": "macos-base",
|
||||
"architecture": {
|
||||
"value": "arm64",
|
||||
"strategy": "external"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-san",
|
||||
"inherits": "macos-arm64",
|
||||
"cacheVariables": {
|
||||
"BUILD_WITH_SANITIZERS": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-x64",
|
||||
"inherits": "macos-base",
|
||||
"architecture": {
|
||||
"value": "x64",
|
||||
"strategy": "external"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-san",
|
||||
"inherits": "macos-x64",
|
||||
"cacheVariables": {
|
||||
"BUILD_WITH_SANITIZERS": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-base",
|
||||
"hidden": true,
|
||||
"inherits": "ninja-base",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-x86-msvc2019",
|
||||
"inherits": "windows-base",
|
||||
"architecture": {
|
||||
"value": "x86",
|
||||
"strategy": "external"
|
||||
},
|
||||
"toolset": {
|
||||
"value": "v142,host=x64",
|
||||
"strategy": "external"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "cl",
|
||||
"CMAKE_CXX_COMPILER": "cl"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-x64-msvc2019",
|
||||
"inherits": "windows-base",
|
||||
"architecture": {
|
||||
"value": "x64",
|
||||
"strategy": "external"
|
||||
},
|
||||
"toolset": {
|
||||
"value": "v142,host=x64",
|
||||
"strategy": "external"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "cl",
|
||||
"CMAKE_CXX_COMPILER": "cl"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-x86-msvc2022",
|
||||
"inherits": "windows-base",
|
||||
"architecture": {
|
||||
"value": "x86",
|
||||
"strategy": "external"
|
||||
},
|
||||
"toolset": {
|
||||
"value": "v143,host=x64",
|
||||
"strategy": "external"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "cl",
|
||||
"CMAKE_CXX_COMPILER": "cl"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "windows-x64-msvc2022",
|
||||
"inherits": "windows-base",
|
||||
"architecture": {
|
||||
"value": "x64",
|
||||
"strategy": "external"
|
||||
},
|
||||
"toolset": {
|
||||
"value": "v143,host=x64",
|
||||
"strategy": "external"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "cl",
|
||||
"CMAKE_CXX_COMPILER": "cl"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "linux-clang-7-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "linux-clang-7"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-7-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "linux-clang-7"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-14-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "linux-clang-14"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-14-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "linux-clang-14"
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-7-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "linux-gcc-7"
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-7-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "linux-gcc-7"
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-12-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "linux-gcc-12"
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-12-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "linux-gcc-12"
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-arm64-san"
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "macos-arm64"
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-x64-san"
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "macos-x64"
|
||||
},
|
||||
{
|
||||
"name": "windows-x86-msvc2019-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "windows-x86-msvc2019"
|
||||
},
|
||||
{
|
||||
"name": "windows-x86-msvc2019-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "windows-x86-msvc2019"
|
||||
},
|
||||
{
|
||||
"name": "windows-x64-msvc2019-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "windows-x64-msvc2019"
|
||||
},
|
||||
{
|
||||
"name": "windows-x64-msvc2019-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "windows-x64-msvc2019"
|
||||
},
|
||||
{
|
||||
"name": "windows-x86-msvc2022-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "windows-x86-msvc2022"
|
||||
},
|
||||
{
|
||||
"name": "windows-x86-msvc2022-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "windows-x86-msvc2022"
|
||||
},
|
||||
{
|
||||
"name": "windows-x64-msvc2022-debug",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "windows-x64-msvc2022"
|
||||
},
|
||||
{
|
||||
"name": "windows-x64-msvc2022-release",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "windows-x64-msvc2022"
|
||||
}
|
||||
],
|
||||
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "test-base",
|
||||
"hidden": true,
|
||||
"output": {
|
||||
"verbosity": "verbose"
|
||||
},
|
||||
"configuration": "Release"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-7-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "linux-clang-7"
|
||||
},
|
||||
{
|
||||
"name": "linux-clang-14-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "linux-clang-14"
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-7-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "linux-gcc-7"
|
||||
},
|
||||
{
|
||||
"name": "linux-gcc-12-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "linux-gcc-12"
|
||||
},
|
||||
{
|
||||
"name": "macos-arm64-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "macos-arm64"
|
||||
},
|
||||
{
|
||||
"name": "macos-x64-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "macos-x64"
|
||||
},
|
||||
{
|
||||
"name": "windows-x86-msvc2019-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "windows-x86-msvc2019"
|
||||
},
|
||||
{
|
||||
"name": "windows-x64-msvc2019-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "windows-x64-msvc2019"
|
||||
},
|
||||
{
|
||||
"name": "windows-x86-msvc2022-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "windows-x86-msvc2022"
|
||||
},
|
||||
{
|
||||
"name": "windows-x64-msvc2022-release",
|
||||
"inherits": "test-base",
|
||||
"configurePreset": "windows-x64-msvc2022"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
16
README.md
16
README.md
@@ -5,21 +5,18 @@
|
||||
[![linux][badge.linux]][linux]
|
||||
[![darwin][badge.darwin]][darwin]
|
||||
[![windows][badge.windows]][windows]
|
||||
[![codecov][badge.codecov]][codecov]
|
||||
[![language][badge.language]][language]
|
||||
[![license][badge.license]][license]
|
||||
|
||||
[badge.darwin]: https://img.shields.io/github/workflow/status/BlackMATov/curly.hpp/darwin/main?label=Xcode&logo=xcode
|
||||
[badge.linux]: https://img.shields.io/github/workflow/status/BlackMATov/curly.hpp/linux/main?label=GCC%2FClang&logo=linux
|
||||
[badge.windows]: https://img.shields.io/github/workflow/status/BlackMATov/curly.hpp/windows/main?label=Visual%20Studio&logo=visual-studio
|
||||
[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/curly.hpp/main?logo=codecov
|
||||
[badge.darwin]: https://img.shields.io/github/actions/workflow/status/BlackMATov/curly.hpp/.github/workflows/darwin.yml?label=Xcode&logo=xcode
|
||||
[badge.linux]: https://img.shields.io/github/actions/workflow/status/BlackMATov/curly.hpp/.github/workflows/linux.yml?label=GCC%2FClang&logo=linux
|
||||
[badge.windows]: https://img.shields.io/github/actions/workflow/status/BlackMATov/curly.hpp/.github/workflows/windows.yml?label=Visual%20Studio&logo=visual-studio
|
||||
[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow
|
||||
[badge.license]: https://img.shields.io/badge/license-MIT-blue
|
||||
|
||||
[darwin]: https://github.com/BlackMATov/curly.hpp/actions?query=workflow%3Adarwin
|
||||
[linux]: https://github.com/BlackMATov/curly.hpp/actions?query=workflow%3Alinux
|
||||
[windows]: https://github.com/BlackMATov/curly.hpp/actions?query=workflow%3Awindows
|
||||
[codecov]: https://codecov.io/gh/BlackMATov/curly.hpp
|
||||
[language]: https://en.wikipedia.org/wiki/C%2B%2B17
|
||||
[license]: https://en.wikipedia.org/wiki/MIT_License
|
||||
|
||||
@@ -37,9 +34,10 @@
|
||||
|
||||
## Requirements
|
||||
|
||||
- [gcc](https://www.gnu.org/software/gcc/) **>= 7**
|
||||
- [clang](https://clang.llvm.org/) **>= 7**
|
||||
- [msvc](https://visualstudio.microsoft.com/) **>= 2017**
|
||||
- [gcc](https://www.gnu.org/software/gcc/) **>= 7**
|
||||
- [msvc](https://visualstudio.microsoft.com/) **>= 2019**
|
||||
- [xcode](https://developer.apple.com/xcode/) **>= 10.3**
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -47,7 +45,7 @@ Just add the root repository directory to your cmake project:
|
||||
|
||||
```cmake
|
||||
add_subdirectory(external/curly.hpp)
|
||||
target_link_libraries(your_project_target curly.hpp)
|
||||
target_link_libraries(your_project_target PUBLIC curly.hpp::curly.hpp)
|
||||
```
|
||||
|
||||
### CMake options
|
||||
|
||||
16
cmake/EnableASan.cmake
Normal file
16
cmake/EnableASan.cmake
Normal file
@@ -0,0 +1,16 @@
|
||||
# https://clang.llvm.org/docs/AddressSanitizer.html
|
||||
|
||||
add_library(${PROJECT_NAME}.enable_asan INTERFACE)
|
||||
add_library(${PROJECT_NAME}::enable_asan ALIAS ${PROJECT_NAME}.enable_asan)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}.enable_asan INTERFACE
|
||||
-fsanitize=address
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize-address-use-after-scope
|
||||
-fsanitize-address-use-after-return=always)
|
||||
|
||||
target_link_options(${PROJECT_NAME}.enable_asan INTERFACE
|
||||
-fsanitize=address
|
||||
-fno-omit-frame-pointer
|
||||
-fsanitize-address-use-after-scope
|
||||
-fsanitize-address-use-after-return=always)
|
||||
10
cmake/EnableGCov.cmake
Normal file
10
cmake/EnableGCov.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html
|
||||
|
||||
add_library(${PROJECT_NAME}.enable_gcov INTERFACE)
|
||||
add_library(${PROJECT_NAME}::enable_gcov ALIAS ${PROJECT_NAME}.enable_gcov)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}.enable_gcov INTERFACE
|
||||
--coverage)
|
||||
|
||||
target_link_options(${PROJECT_NAME}.enable_gcov INTERFACE
|
||||
--coverage)
|
||||
12
cmake/EnableUBSan.cmake
Normal file
12
cmake/EnableUBSan.cmake
Normal file
@@ -0,0 +1,12 @@
|
||||
# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
|
||||
|
||||
add_library(${PROJECT_NAME}.enable_ubsan INTERFACE)
|
||||
add_library(${PROJECT_NAME}::enable_ubsan ALIAS ${PROJECT_NAME}.enable_ubsan)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}.enable_ubsan INTERFACE
|
||||
-fsanitize=undefined
|
||||
-fno-omit-frame-pointer)
|
||||
|
||||
target_link_options(${PROJECT_NAME}.enable_ubsan INTERFACE
|
||||
-fsanitize=undefined
|
||||
-fno-omit-frame-pointer)
|
||||
@@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/curly.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/curly.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <curly.hpp/curly.hpp>
|
||||
|
||||
@@ -1,39 +1,90 @@
|
||||
project(curly.hpp.untests)
|
||||
|
||||
#
|
||||
# coverage
|
||||
#
|
||||
|
||||
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||
if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
|
||||
set(COVERAGE_FLAGS "--coverage")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
endif()
|
||||
|
||||
#
|
||||
# executable
|
||||
#
|
||||
|
||||
file(GLOB_RECURSE UNTESTS_SOURCES "*.cpp" "*.hpp")
|
||||
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} curly.hpp)
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${UNTESTS_SOURCES})
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-ctad-maybe-unsupported
|
||||
-Wno-padded
|
||||
-Wno-unknown-warning-option
|
||||
-Wno-weak-vtables
|
||||
-Wno-zero-as-null-pointer-constant
|
||||
>)
|
||||
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE curly.hpp::curly.hpp)
|
||||
|
||||
#
|
||||
# setup defines
|
||||
#
|
||||
|
||||
function(setup_defines_for_target TARGET)
|
||||
target_compile_definitions(${TARGET} PRIVATE
|
||||
DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
|
||||
DOCTEST_CONFIG_USE_STD_HEADERS)
|
||||
endfunction()
|
||||
|
||||
setup_defines_for_target(${PROJECT_NAME})
|
||||
|
||||
#
|
||||
# setup libraries
|
||||
#
|
||||
|
||||
function(setup_libraries_for_target TARGET)
|
||||
target_link_libraries(${TARGET} PRIVATE doctest::doctest_with_main)
|
||||
|
||||
if(${BUILD_WITH_COVERAGE})
|
||||
target_link_libraries(${TARGET} PRIVATE curly.hpp::enable_gcov)
|
||||
endif()
|
||||
|
||||
if(${BUILD_WITH_SANITIZERS})
|
||||
target_link_libraries(${TARGET} PRIVATE curly.hpp::enable_asan curly.hpp::enable_ubsan)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
setup_libraries_for_target(${PROJECT_NAME})
|
||||
|
||||
#
|
||||
# setup warnings
|
||||
#
|
||||
|
||||
function(setup_warnings_for_target TARGET)
|
||||
target_compile_options(${TARGET}
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/WX /W4>
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
-Werror -Wall -Wextra -Wpedantic>
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Werror -Weverything -Wconversion
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-ctad-maybe-unsupported
|
||||
-Wno-padded
|
||||
-Wno-unknown-warning-option
|
||||
-Wno-weak-vtables
|
||||
-Wno-zero-as-null-pointer-constant
|
||||
>)
|
||||
endfunction()
|
||||
|
||||
setup_warnings_for_target(${PROJECT_NAME})
|
||||
|
||||
#
|
||||
# add tests
|
||||
#
|
||||
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
|
||||
#
|
||||
# doctest/doctest
|
||||
#
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
doctest_doctest
|
||||
GIT_REPOSITORY https://github.com/doctest/doctest)
|
||||
|
||||
FetchContent_GetProperties(doctest_doctest)
|
||||
if(NOT doctest_doctest_POPULATED)
|
||||
FetchContent_Populate(doctest_doctest)
|
||||
add_subdirectory(${doctest_doctest_SOURCE_DIR} ${doctest_doctest_BINARY_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE doctest::doctest_with_main)
|
||||
endif()
|
||||
|
||||
#
|
||||
# tencent/rapidjson
|
||||
#
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/curly.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
* Copyright (C) 2019-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include "doctest/doctest.hpp"
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
#include <curly.hpp/curly.hpp>
|
||||
namespace net = curly_hpp;
|
||||
@@ -101,7 +101,7 @@ TEST_CASE("curly") {
|
||||
|
||||
SUBCASE("wait") {
|
||||
{
|
||||
auto req = net::request_builder("https://httpbin.org/delay/1").send();
|
||||
auto req = net::request_builder("https://httpbin.org/delay/2").send();
|
||||
REQUIRE(req.status() == net::req_status::pending);
|
||||
REQUIRE(req.wait() == net::req_status::done);
|
||||
REQUIRE(req.status() == net::req_status::done);
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest.h"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wreserved-identifier"
|
||||
#endif
|
||||
|
||||
#include "doctest.h"
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#define STATIC_REQUIRE(...)\
|
||||
static_assert(__VA_ARGS__, #__VA_ARGS__);\
|
||||
REQUIRE(__VA_ARGS__);
|
||||
|
||||
#define STATIC_REQUIRE_FALSE(...)\
|
||||
static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\
|
||||
REQUIRE(!(__VA_ARGS__));
|
||||
Reference in New Issue
Block a user