From: Joel Rosdahl Date: Sat, 23 Mar 2024 20:00:03 +0000 (+0100) Subject: build: Add support for using system tl-expected X-Git-Tag: v4.10~42^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ff58a89ade076d9a5e730edb50bf252ae5f1f20;p=thirdparty%2Fccache.git build: Add support for using system tl-expected --- diff --git a/.clang-format b/.clang-format index ce4d58691..3910db4d9 100644 --- a/.clang-format +++ b/.clang-format @@ -31,7 +31,7 @@ IncludeCategories: - Regex: '^$' + - Regex: '^<(doctest/.*|fmt/.*|hiredis/.*|httplib\.h|nonstd/.*|tl/expected\.hpp|zstd\.h)>$' Priority: 3 # System headers: - Regex: '\.h.*>$' diff --git a/LICENSE.adoc b/LICENSE.adoc index a366cbd93..c8e824a2d 100644 --- a/LICENSE.adoc +++ b/LICENSE.adoc @@ -453,7 +453,7 @@ DEALINGS IN THE SOFTWARE. ---- -=== src/third_party/tl/expected.hpp +=== src/third_party/tl-expected/tl/expected.hpp This is https://github.com/TartanLlama/expected[TartanLlama expected] 1.1.0 with the following license: diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index d381a494c..ae50429b5 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -22,6 +22,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(TlExpected 1.1.0 MODULE REQUIRED) find_package(Zstd 1.3.4 MODULE REQUIRED) if(ENABLE_TESTING) diff --git a/cmake/FindTlExpected.cmake b/cmake/FindTlExpected.cmake new file mode 100644 index 000000000..93a6267b5 --- /dev/null +++ b/cmake/FindTlExpected.cmake @@ -0,0 +1,21 @@ +mark_as_advanced(TLEXPECTED_INCLUDE_DIR) + +if(DEP_TLEXPECTED STREQUAL "BUNDLED") + message(STATUS "Using bundled TlExpected as requested") +else() + find_path(TLEXPECTED_INCLUDE_DIR tl/expected.hpp) + if(TLEXPECTED_INCLUDE_DIR) + file(READ "${TLEXPECTED_INCLUDE_DIR}/tl/expected.hpp" _tlexpected_h) + string(REGEX MATCH "#define TL_EXPECTED_VERSION_MAJOR ([0-9]+).*#define TL_EXPECTED_VERSION_MINOR ([0-9]+).*#define TL_EXPECTED_VERSION_PATCH ([0-9]+)" _ "${_tlexpected_h}") + set(_tlexpected_version_string "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") + if(NOT "${CMAKE_MATCH_0}" STREQUAL "" AND "${_tlexpected_version_string}" VERSION_GREATER_EQUAL "${TlExpected_FIND_VERSION}") + message(STATUS "Using system TlExpected (${TLEXPECTED_INCLUDE_DIR}/tl/expected.hpp)") + add_library(dep_tlexpected INTERFACE IMPORTED) + target_include_directories(dep_tlexpected INTERFACE "${TLEXPECTED_INCLUDE_DIR}") + register_dependency(TlExpected "SYSTEM (${TLEXPECTED_INCLUDE_DIR}/tl/expected.hpp)" "${_tlexpected_version_string}") + endif() + endif() + if(NOT TARGET dep_tlexpected) + message(STATUS "Using bundled TlExpected since TlExpected>=${TlExpected_FIND_VERSION} was not found locally") + endif() +endif() diff --git a/doc/INSTALL.md b/doc/INSTALL.md index c61ea667e..0a283f23f 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -46,6 +46,7 @@ should be located or retrieved: - [hiredis](https://github.com/redis/hiredis)[^2] (optional, disable with `-D REDIS_STORAGE_BACKEND=OFF`) - [span-lite](https://github.com/martinmoene/span-lite)[^1] +- [tl-expected](https://github.com/TartanLlama/expected)[^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 4e7852146..5952e8801 100644 --- a/src/ccache/CMakeLists.txt +++ b/src/ccache/CMakeLists.txt @@ -47,6 +47,7 @@ target_link_libraries( PUBLIC dep_fmt dep_nonstdspan + dep_tlexpected third_party PRIVATE dep_cpphttplib diff --git a/src/ccache/Hash.hpp b/src/ccache/Hash.hpp index 4ece77f56..4e97b0427 100644 --- a/src/ccache/Hash.hpp +++ b/src/ccache/Hash.hpp @@ -19,9 +19,9 @@ #pragma once #include +#include #include -#include #include #include diff --git a/src/ccache/storage/remote/RemoteStorage.hpp b/src/ccache/storage/remote/RemoteStorage.hpp index b8db6b8a5..341b47bdc 100644 --- a/src/ccache/storage/remote/RemoteStorage.hpp +++ b/src/ccache/storage/remote/RemoteStorage.hpp @@ -22,8 +22,8 @@ #include #include - #include + #include #include diff --git a/src/ccache/util/file.hpp b/src/ccache/util/file.hpp index 72af09101..4707f4f58 100644 --- a/src/ccache/util/file.hpp +++ b/src/ccache/util/file.hpp @@ -24,7 +24,6 @@ #include #include - #include #include diff --git a/src/ccache/util/string.hpp b/src/ccache/util/string.hpp index c0209f89e..07f791f2b 100644 --- a/src/ccache/util/string.hpp +++ b/src/ccache/util/string.hpp @@ -22,9 +22,9 @@ #include #include +#include #include // for mode_t -#include #include #include diff --git a/src/ccache/util/zstd.hpp b/src/ccache/util/zstd.hpp index 01ab43bb2..557d9cbc6 100644 --- a/src/ccache/util/zstd.hpp +++ b/src/ccache/util/zstd.hpp @@ -21,7 +21,6 @@ #include #include - #include #include diff --git a/src/third_party/CMakeLists.txt b/src/third_party/CMakeLists.txt index 9e7d9dc97..2f28156b4 100644 --- a/src/third_party/CMakeLists.txt +++ b/src/third_party/CMakeLists.txt @@ -62,3 +62,6 @@ endif() if(NOT TARGET dep_nonstdspan) add_subdirectory(nonstd-span) endif() +if(NOT TARGET dep_tlexpected) + add_subdirectory(tl-expected) +endif() diff --git a/src/third_party/tl-expected/CMakeLists.txt b/src/third_party/tl-expected/CMakeLists.txt new file mode 100644 index 000000000..fa215e6be --- /dev/null +++ b/src/third_party/tl-expected/CMakeLists.txt @@ -0,0 +1,2 @@ +register_dependency(TlExpected BUNDLED 1.1.0) +add_header_only_library(tlexpected DIR "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/src/third_party/tl/expected.hpp b/src/third_party/tl-expected/tl/expected.hpp similarity index 100% rename from src/third_party/tl/expected.hpp rename to src/third_party/tl-expected/tl/expected.hpp diff --git a/unittest/test_util_expected.cpp b/unittest/test_util_expected.cpp index b0875750c..bd84ac612 100644 --- a/unittest/test_util_expected.cpp +++ b/unittest/test_util_expected.cpp @@ -19,7 +19,6 @@ #include #include - #include #include // macOS bug: https://github.com/onqtam/doctest/issues/126