From: Joel Rosdahl Date: Fri, 22 Mar 2024 20:40:58 +0000 (+0100) Subject: build: Add support for using system nonstd-span X-Git-Tag: v4.10~42^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed196d2d152909023c862cb5675c18e11ece8515;p=thirdparty%2Fccache.git build: Add support for using system nonstd-span --- diff --git a/.clang-format b/.clang-format index e35a0140c..ce4d58691 100644 --- a/.clang-format +++ b/.clang-format @@ -31,7 +31,7 @@ IncludeCategories: - Regex: '^$' + - Regex: '^<(doctest/.*|fmt/.*|hiredis/.*|httplib\.h|nonstd/.*|zstd\.h)>$' Priority: 3 # System headers: - Regex: '\.h.*>$' diff --git a/LICENSE.adoc b/LICENSE.adoc index 98b8e18cd..a366cbd93 100644 --- a/LICENSE.adoc +++ b/LICENSE.adoc @@ -418,7 +418,7 @@ SOFTWARE. ---- -=== src/third_party/nonstd/span.hpp +=== src/third_party/nonstd-span/nonstd/span.hpp This is the single header version of https://github.com/martinmoene/span-lite[span-lite] 0.10.3 with the diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 9d47567a2..d381a494c 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -21,6 +21,7 @@ set_property(CACHE DEPS PROPERTY STRINGS AUTO DOWNLOAD LOCAL) find_package(CppHttplib 0.10.6 MODULE REQUIRED) find_package(Fmt 8.0.0 MODULE REQUIRED) +find_package(NonstdSpan 0.10.3 MODULE REQUIRED) find_package(Zstd 1.3.4 MODULE REQUIRED) if(ENABLE_TESTING) diff --git a/cmake/FindNonstdSpan.cmake b/cmake/FindNonstdSpan.cmake new file mode 100644 index 000000000..c15bb8506 --- /dev/null +++ b/cmake/FindNonstdSpan.cmake @@ -0,0 +1,21 @@ +mark_as_advanced(NONSTDSPAN_INCLUDE_DIR) + +if(DEP_NONSTDSPAN STREQUAL "BUNDLED") + message(STATUS "Using bundled NonstdSpan as requested") +else() + find_path(NONSTDSPAN_INCLUDE_DIR nonstd/span.hpp) + if(NONSTDSPAN_INCLUDE_DIR) + file(READ "${NONSTDSPAN_INCLUDE_DIR}/nonstd/span.hpp" _nonstdspan_h) + string(REGEX MATCH "#define span_lite_MAJOR ([0-9]+).*#define span_lite_MINOR ([0-9]+).*#define span_lite_PATCH ([0-9]+)" _ "${_nonstdspan_h}") + set(_nonstdspan_version_string "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") + if(NOT "${CMAKE_MATCH_0}" STREQUAL "" AND "${_nonstdspan_version_string}" VERSION_GREATER_EQUAL "${NonstdSpan_FIND_VERSION}") + message(STATUS "Using system NonstdSpan (${NONSTDSPAN_INCLUDE_DIR}/nonstd/span.hpp)") + add_library(dep_nonstdspan INTERFACE IMPORTED) + target_include_directories(dep_nonstdspan INTERFACE "${NONSTDSPAN_INCLUDE_DIR}") + register_dependency(NonstdSpan "SYSTEM (${NONSTDSPAN_INCLUDE_DIR}/nonstd/span.hpp)" ${_nonstdspan_version_string}) + endif() + endif() + if(NOT TARGET dep_nonstdspan) + message(STATUS "Using bundled NonstdSpan since NonstdSpan>=${NonstdSpan_FIND_VERSION} was not found locally") + endif() +endif() diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 45032dae0..c61ea667e 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -45,6 +45,7 @@ should be located or retrieved: - [fmt](https://fmt.dev)[^2] - [hiredis](https://github.com/redis/hiredis)[^2] (optional, disable with `-D REDIS_STORAGE_BACKEND=OFF`) +- [span-lite](https://github.com/martinmoene/span-lite)[^1] - [Zstandard](https://github.com/facebook/zstd)[^2] [^1]: A bundled version will be used if missing locally. diff --git a/src/ccache/CMakeLists.txt b/src/ccache/CMakeLists.txt index b17540539..4e7852146 100644 --- a/src/ccache/CMakeLists.txt +++ b/src/ccache/CMakeLists.txt @@ -46,6 +46,7 @@ target_link_libraries( ccache_framework PUBLIC dep_fmt + dep_nonstdspan third_party PRIVATE dep_cpphttplib diff --git a/src/ccache/Hash.hpp b/src/ccache/Hash.hpp index df95b66c2..4ece77f56 100644 --- a/src/ccache/Hash.hpp +++ b/src/ccache/Hash.hpp @@ -18,8 +18,9 @@ #pragma once -#include #include + +#include #include #include diff --git a/src/ccache/storage/remote/RemoteStorage.hpp b/src/ccache/storage/remote/RemoteStorage.hpp index 5551bd1d2..b8db6b8a5 100644 --- a/src/ccache/storage/remote/RemoteStorage.hpp +++ b/src/ccache/storage/remote/RemoteStorage.hpp @@ -22,6 +22,7 @@ #include #include + #include #include diff --git a/src/ccache/util/file.hpp b/src/ccache/util/file.hpp index 4707f4f58..72af09101 100644 --- a/src/ccache/util/file.hpp +++ b/src/ccache/util/file.hpp @@ -24,6 +24,7 @@ #include #include + #include #include diff --git a/src/ccache/util/string.hpp b/src/ccache/util/string.hpp index ca8029fad..c0209f89e 100644 --- a/src/ccache/util/string.hpp +++ b/src/ccache/util/string.hpp @@ -22,6 +22,7 @@ #include #include + #include // for mode_t #include diff --git a/src/ccache/util/zstd.hpp b/src/ccache/util/zstd.hpp index 557d9cbc6..01ab43bb2 100644 --- a/src/ccache/util/zstd.hpp +++ b/src/ccache/util/zstd.hpp @@ -21,6 +21,7 @@ #include #include + #include #include diff --git a/src/third_party/CMakeLists.txt b/src/third_party/CMakeLists.txt index baea1d76c..9e7d9dc97 100644 --- a/src/third_party/CMakeLists.txt +++ b/src/third_party/CMakeLists.txt @@ -59,3 +59,6 @@ add_subdirectory(blake3) if(NOT TARGET dep_cpphttplib) add_subdirectory(cpp-httplib) endif() +if(NOT TARGET dep_nonstdspan) + add_subdirectory(nonstd-span) +endif() diff --git a/src/third_party/nonstd-span/CMakeLists.txt b/src/third_party/nonstd-span/CMakeLists.txt new file mode 100644 index 000000000..9e42e6a0f --- /dev/null +++ b/src/third_party/nonstd-span/CMakeLists.txt @@ -0,0 +1,2 @@ +register_dependency(NonstdSpan BUNDLED 0.10.3) +add_header_only_library(nonstdspan DIR "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/src/third_party/nonstd/span.hpp b/src/third_party/nonstd-span/nonstd/span.hpp similarity index 100% rename from src/third_party/nonstd/span.hpp rename to src/third_party/nonstd-span/nonstd/span.hpp diff --git a/unittest/test_util_Bytes.cpp b/unittest/test_util_Bytes.cpp index 87c914a73..e1eefb77c 100644 --- a/unittest/test_util_Bytes.cpp +++ b/unittest/test_util_Bytes.cpp @@ -19,7 +19,6 @@ #include #include - #include #include