Skip to content

Commit 7300364

Browse files
committed
chore: add dependencies vendor
Signed-off-by: ComixHe <heyuming@deepin.org>
1 parent 0fab576 commit 7300364

File tree

263 files changed

+106943
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+106943
-54
lines changed

.github/workflows/checks.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ jobs:
1717
runs-on: "ubuntu-latest"
1818
strategy:
1919
matrix:
20-
type: [Debug, Release, RelWithDebInfo]
20+
type: [Debug, Release]
21+
dependency: [Vendor, Online]
2122
cxx: [g++, clang++]
2223
steps:
2324
- name: Checkout project
@@ -49,8 +50,8 @@ jobs:
4950
export CFLAGS="$CFLAGS -Wno-extra-semi -Wno-unused-command-line-argument -Wno-gnu-zero-variadic-macro-arguments" &&
5051
export CFLAGS="$CFLAGS -fsanitize=address,undefined" &&
5152
export CXXFLAGS="$CFLAGS" &&
52-
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.type }}&&
53-
cmake --build build -j
53+
cmake --preset ${{ matrix.dependency }}${{ matrix.type }} &&
54+
cmake --build --preset ${{ matrix.dependency }}${{ matrix.type }} -j
5455
- name: Run tests
5556
if: ${{ false }} # This project has no tests for now.
5657
run: |

CMakeLists.txt

Lines changed: 78 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.23)
1+
cmake_minimum_required(VERSION 3.25)
22

33
project(
44
ocppi
@@ -16,71 +16,98 @@ option(OCPPI_BUILD_SHARED_LIBRARY "Build a shared library or not"
1616

1717
option(OCPPI_INSTALL "Enable install target or not" ${PROJECT_IS_TOP_LEVEL})
1818

19+
option(OCPPI_USE_VENDOR_EXPECTED
20+
"Use tl::expected which from vendor of project." OFF)
21+
22+
option(OCPPI_USE_VENDOR_SEMVER "Use semver which from vendor of project." OFF)
23+
24+
option(OCPPI_USE_VENDOR_JSON "Use nlohmann_json which from vendor of project."
25+
OFF)
26+
27+
option(OCPPI_USE_VENDOR_SPDLOG "Use spdlog which from vendor of project." OFF)
28+
29+
option(OCPPI_USE_VENDOR_ALL
30+
"Use all external dependencies which from vendor of project." OFF)
31+
1932
include(./cmake/CPM.cmake)
2033

21-
CPMFindPackage(
22-
NAME expected
23-
VERSION 1.0.0
24-
GITHUB_REPOSITORY TartanLlama/expected
25-
GIT_TAG v1.1.0
26-
GIT_SHALLOW ON
27-
OPTIONS "EXPECTED_BUILD_TESTS OFF"
28-
FIND_PACKAGE_ARGUMENTS "NAMES tl-expected"
29-
EXCLUDE_FROM_ALL ON)
34+
if(OCPPI_USE_VENDOR_ALL)
35+
36+
set(OCPPI_USE_VENDOR_EXPECTED ON)
37+
set(OCPPI_USE_VENDOR_SEMVER ON)
38+
set(OCPPI_USE_VENDOR_JSON ON)
39+
set(OCPPI_USE_VENDOR_SPDLOG ON)
3040

31-
if(NOT TARGET tl::expected)
32-
# NOTE: v1.0.0 version of tl::expected doesn't have a namespaced alias so we
33-
# have to add it here.
34-
add_library(tl::expected ALIAS expected)
3541
endif()
3642

37-
CPMFindPackage(
38-
NAME semver
39-
VERSION 0.3.0
40-
GITHUB_REPOSITORY Neargye/Semver
41-
GIT_TAG v0.3.0
42-
GIT_SHALLOW ON
43-
GIT_PROGRESS ON
44-
EXCLUDE_FROM_ALL ON)
43+
if(OCPPI_USE_VENDOR_EXPECTED)
44+
add_subdirectory(external/expected EXCLUDE_FROM_ALL)
45+
set_target_properties(expected PROPERTIES EXPECTED_BUILD_TESTS OFF)
46+
else()
47+
CPMFindPackage(
48+
NAME expected
49+
VERSION 1.1.0
50+
GITHUB_REPOSITORY TartanLlama/expected
51+
GIT_TAG v1.1.0
52+
GIT_SHALLOW ON
53+
OPTIONS "EXPECTED_BUILD_TESTS OFF"
54+
FIND_PACKAGE_ARGUMENTS "NAMES tl-expected"
55+
EXCLUDE_FROM_ALL ON)
56+
endif()
4557

46-
CPMFindPackage(
47-
NAME nlohmann_json
48-
VERSION 3.11.2
49-
URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz"
50-
EXCLUDE_FROM_ALL ON
51-
OPTIONS "JSON_Install ON")
58+
if(OCPPI_USE_VENDOR_SEMVER)
59+
add_subdirectory(external/semver EXCLUDE_FROM_ALL)
60+
else()
61+
CPMFindPackage(
62+
NAME semver
63+
VERSION 0.3.1
64+
GITHUB_REPOSITORY Neargye/Semver
65+
GIT_TAG v0.3.1
66+
GIT_SHALLOW ON
67+
GIT_PROGRESS ON
68+
EXCLUDE_FROM_ALL ON)
69+
endif()
70+
71+
if(OCPPI_USE_VENDOR_JSON)
72+
set(JSON_Install ON)
73+
add_subdirectory(external/json EXCLUDE_FROM_ALL)
74+
else()
75+
CPMFindPackage(
76+
NAME nlohmann_json
77+
VERSION 3.11.3
78+
URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz"
79+
EXCLUDE_FROM_ALL ON
80+
OPTIONS "JSON_Install ON")
81+
endif()
82+
83+
if(OCPPI_USE_VENDOR_SPDLOG)
84+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
85+
add_subdirectory(external/spdlog EXCLUDE_FROM_ALL)
86+
else()
87+
CPMFindPackage(
88+
NAME spdlog
89+
VERSION 1.13.0
90+
GITHUB_REPOSITORY "gabime/spdlog"
91+
GIT_TAG "v1.13.0"
92+
GIT_SHALLOW ON
93+
EXCLUDE_FROM_ALL ON
94+
OPTIONS
95+
"CMAKE_POSITION_INDEPENDENT_CODE ON" # NOTE:
96+
# https://github.com/gabime/spdlog/issues/1190
97+
)
98+
99+
endif()
52100

53101
CPMFindPackage(
54102
NAME Boost COMPONENTS headers
55-
VERSION 1.64.0
56-
URL "https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.7z"
103+
VERSION 1.83.0
104+
URL "https://github.com/boostorg/boost/releases/download/boost-1.83.0/boost-1.83.0.7z"
57105
EXCLUDE_FROM_ALL ON)
58106

59107
if(NOT TARGET Boost::process)
60108
add_library(Boost::process ALIAS Boost::headers)
61109
endif()
62110

63-
CPMFindPackage(
64-
NAME fmt
65-
VERSION 9.1.0
66-
GITHUB_REPOSITORY "fmtlib/fmt"
67-
GIT_TAG "10.2.1"
68-
GIT_SHALLOW ON
69-
EXCLUDE_FROM_ALL ON
70-
OPTIONS "CMAKE_POSITION_INDEPENDENT_CODE ON")
71-
72-
CPMFindPackage(
73-
NAME spdlog
74-
VERSION 1.10.0
75-
GITHUB_REPOSITORY "gabime/spdlog"
76-
GIT_TAG "v1.13.0"
77-
GIT_SHALLOW ON
78-
EXCLUDE_FROM_ALL ON
79-
OPTIONS
80-
"CMAKE_POSITION_INDEPENDENT_CODE ON" # NOTE:
81-
# https://github.com/gabime/spdlog/issues/1190
82-
"SPDLOG_FMT_EXTERNAL ON")
83-
84111
include(./cmake/GitSemver.cmake)
85112

86113
set(OCPPI_SEMVER ${PROJECT_VERSION})

CMakePresets.json

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"version": 6,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 25,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "OnlineRelease",
11+
"displayName": "Default configuration",
12+
"description": "Configure ocppi for installing from source.",
13+
"binaryDir": "${sourceDir}/build-release",
14+
"cacheVariables": {
15+
"CPM_DOWNLOAD_ALL": true,
16+
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -O2",
17+
"CMAKE_COLOR_DIAGNOSTICS": true
18+
}
19+
},
20+
{
21+
"name": "VendorRelease",
22+
"displayName": "Default configuration with vendor dependencies",
23+
"description": "Configure ocppi for installing from source.",
24+
"binaryDir": "${sourceDir}/build-vendorRelease",
25+
"cacheVariables": {
26+
"OCPPI_USE_VENDOR_ALL": true,
27+
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -O2",
28+
"CMAKE_COLOR_DIAGNOSTICS": true
29+
}
30+
},
31+
{
32+
"name": "OnlineDebug",
33+
"displayName": "Debug configuration",
34+
"description": "Configure ocppi for development and debugging.",
35+
"binaryDir": "${sourceDir}/build-debug",
36+
"cacheVariables": {
37+
"CPM_DOWNLOAD_ALL": true,
38+
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Og -g -fsanitize=address,undefined",
39+
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
40+
"CMAKE_COLOR_DIAGNOSTICS": true
41+
}
42+
},
43+
{
44+
"name": "VendorDebug",
45+
"displayName": "Debug configuration with vendor dependencies",
46+
"description": "Configure ocppi for development and debugging.",
47+
"binaryDir": "${sourceDir}/build-vendorDebug",
48+
"cacheVariables": {
49+
"OCPPI_USE_VENDOR_ALL": true,
50+
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Og -g -fsanitize=address,undefined",
51+
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
52+
"CMAKE_COLOR_DIAGNOSTICS": true
53+
}
54+
}
55+
],
56+
"buildPresets": [
57+
{
58+
"name": "OnlineRelease",
59+
"displayName": "Default build",
60+
"description": "Build ocppi for installing from source.",
61+
"configurePreset": "OnlineRelease"
62+
},
63+
{
64+
"name": "VendorRelease",
65+
"displayName": "Default build with vendor dependencies",
66+
"description": "Build ocppi for installing from source.",
67+
"configurePreset": "VendorRelease"
68+
},
69+
{
70+
"name": "OnlineDebug",
71+
"displayName": "Debug build",
72+
"description": "Build ocppi for development and debugging.",
73+
"configurePreset": "OnlineDebug"
74+
},
75+
{
76+
"name": "VendorDebug",
77+
"displayName": "Debug build",
78+
"description": "Build ocppi for development and debugging with vendor dependencies",
79+
"configurePreset": "VendorDebug"
80+
}
81+
],
82+
"workflowPresets": [
83+
{
84+
"name": "OnlineRelease",
85+
"displayName": "Default workflow",
86+
"description": "Configure, build then test for installing ocppi from source.",
87+
"steps": [
88+
{
89+
"type": "configure",
90+
"name": "OnlineRelease"
91+
},
92+
{
93+
"type": "build",
94+
"name": "OnlineRelease"
95+
}
96+
]
97+
},
98+
{
99+
"name": "VendorRelease",
100+
"displayName": "Default workflow with vendor dependencies",
101+
"description": "Configure, build then test for installing ocppi from source.",
102+
"steps": [
103+
{
104+
"type": "configure",
105+
"name": "VendorRelease"
106+
},
107+
{
108+
"type": "build",
109+
"name": "VendorRelease"
110+
}
111+
]
112+
},
113+
{
114+
"name": "OnlineDebug",
115+
"displayName": "Workflow for developers",
116+
"description": "Configure, build then test for developing and debuging ocppi.",
117+
"steps": [
118+
{
119+
"type": "configure",
120+
"name": "OnlineDebug"
121+
},
122+
{
123+
"type": "build",
124+
"name": "OnlineDebug"
125+
}
126+
]
127+
},
128+
{
129+
"name": "VendorDebug",
130+
"displayName": "Workflow for developers with vendor dependencies",
131+
"description": "Configure, build then test for developing and debuging ocppi.",
132+
"steps": [
133+
{
134+
"type": "configure",
135+
"name": "VendorDebug"
136+
},
137+
{
138+
"type": "build",
139+
"name": "VendorDebug"
140+
}
141+
]
142+
}
143+
]
144+
}

external/.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DisableFormat: true

external/.cmake-format.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# -----------------------------
2+
# Options affecting formatting.
3+
# -----------------------------
4+
with section("format"):
5+
6+
# Disable formatting entirely, making cmake-format a no-op
7+
disable = True

external/expected/.appveyor.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
os:
2+
- Visual Studio 2015
3+
- Visual Studio 2017
4+
- Visual Studio 2019
5+
- Visual Studio 2022
6+
7+
build_script:
8+
- cmake -Bbuild -S.
9+
- cmake --build build
10+
- cmake --build build --target RUN_TESTS

external/expected/.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BasedOnStyle: LLVM

0 commit comments

Comments
 (0)