Skip to content

Commit d5ae8ec

Browse files
authored
Merge pull request #92 from contour-terminal/improvement/cmake-presets
Add CMakePresets to conveniently build and work with the sources
2 parents a051446 + 0ee9785 commit d5ae8ec

File tree

13 files changed

+211
-171
lines changed

13 files changed

+211
-171
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ jobs:
3737
"GCC 10",
3838
"Clang 9",
3939
"Clang 10",
40-
"Clang 11",
40+
# (CI related error) "Clang 11",
4141
"Clang 12"
4242
]
4343
name: "Ubuntu Linux 20.04 (${{ matrix.compiler }})"
4444
runs-on: ubuntu-20.04
4545
steps:
46-
- uses: actions/checkout@v3
46+
- uses: actions/checkout@v4
4747
- name: ccache
4848
uses: hendrikmuhs/ccache-action@v1
4949
with:
@@ -78,14 +78,14 @@ jobs:
7878
[
7979
"GCC 10",
8080
"GCC 13",
81-
"Clang 11",
81+
# (CI related error) "Clang 11",
8282
"Clang 15"
8383
]
8484
# gcc 13 only in github runners and not inside official repo
8585
name: "Ubuntu Linux 22.04 (${{ matrix.compiler }})"
8686
runs-on: ubuntu-22.04
8787
steps:
88-
- uses: actions/checkout@v3
88+
- uses: actions/checkout@v4
8989
- name: ccache
9090
uses: hendrikmuhs/ccache-action@v1
9191
with:
@@ -113,68 +113,49 @@ jobs:
113113
- name: "benchmark"
114114
run: ./build/src/libunicode/libunicode_benchmark
115115

116-
117116
unknown_os:
118-
strategy:
119-
fail-fast: false
120117
name: "Unknown OS"
121118
runs-on: ubuntu-22.04
122119
steps:
123-
- uses: actions/checkout@v3
120+
- uses: actions/checkout@v4
124121
- name: ccache
125122
uses: hendrikmuhs/ccache-action@v1
126123
with:
127-
key: "ccache-ubuntu_2004-${{ matrix.compiler }}"
124+
key: "ccache-ubuntu_2004-unknown-os"
128125
max-size: 256M
129126
- name: "Update package database"
130127
run: sudo apt -q update
131128
- name: "install dependencies"
132-
run: OS_OVERRIDE=UNKNOWN ./scripts/install-deps.sh
133-
- name: "create build directory"
134-
run: mkdir build
135-
- name: "cmake"
136129
run: |
137-
BUILD_DIR="build" \
138-
CMAKE_BUILD_TYPE="RelWithDebInfo" \
139-
./scripts/ci-prepare.sh
130+
set -ex
131+
sudo apt install -q -y ninja-build gcc build-essential cmake debhelper dpkg-dev g++ libc6-dev
132+
OS_OVERRIDE=UNKNOWN ./scripts/install-deps.sh
133+
- name: "cmake"
134+
run: cmake --preset linux-gcc-release
140135
- name: "build"
141-
run: cmake --build build/ -- -j3
136+
run: cmake --build --preset linux-gcc-release -j3
142137
- name: "test"
143-
run: ./build/src/libunicode/unicode_test
138+
run: ctest --preset linux-gcc-release
144139

145140
windows:
146141
name: "Windows"
147142
runs-on: windows-latest
148143
steps:
149-
- uses: actions/checkout@v3
150-
- name: "Fetch embedded dependencies"
151-
shell: powershell
152-
run: |
153-
./scripts/install-deps.ps1
154-
type ./_deps/sources/CMakeLists.txt
144+
- uses: actions/checkout@v4
155145
- name: "vcpkg: Install dependencies"
156-
uses: lukka/run-vcpkg@v5
146+
uses: lukka/run-vcpkg@v11.1
157147
id: runvcpkg
158148
with:
159-
vcpkgArguments: fmt range-v3
160149
vcpkgDirectory: ${{ runner.workspace }}/vcpkg/
161-
vcpkgGitCommitId: 21fa4ccecfefd96bb16faac4af17fcb900d4f8b3
162-
vcpkgTriplet: x64-windows
163-
- name: "create build directory"
164-
shell: powershell
165-
run: |
166-
If (!(Test-Path build))
167-
{
168-
New-Item -ItemType Directory -Force -Path build
169-
}
150+
vcpkgGitCommitId: 80403036a665cb8fcc1a1b3e17593d20b03b2489
151+
- name: "List cmake presets"
152+
run: cmake --list-presets
170153
- name: "Generate build files"
171-
env:
172-
WORKSPACE: ${{ runner.workspace }}
173-
run: ./scripts/ci-prepare.ps1
154+
run: cmake --preset windows-cl-release -DCMAKE_TOOLCHAIN_FILE="${{ runner.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake"
174155
- name: "Build"
175-
run: cmake --build build/ --config Release
176-
- name: "test: libterminal"
177-
run: .\build\src\libunicode\Release\unicode_test.exe
156+
run: cmake --build --preset windows-cl-release
157+
- name: "test"
158+
run: ctest --preset windows-cl-release
178159

179160
Fedora:
180161
name: Fedora
@@ -185,12 +166,13 @@ jobs:
185166
- uses: actions/checkout@v4
186167
- name: Install build dependencies
187168
run: |
169+
dnf install -y curl
188170
PREPARE_ONLY_EMBEDS=OFF SYSDEP_ASSUME_YES=ON ./scripts/install-deps.sh
189171
dnf install -y unicode-ucd
190172
- name: CMake build
191173
run: |
192-
cmake . -G Ninja -B build -DBUILD_SHARED_LIBS=ON -DLIBUNICODE_UCD_DIR=/usr/share/unicode/ucd
193-
cmake --build build -j$(nproc)
174+
cmake --preset linux-gcc-debug -DLIBUNICODE_UCD_DIR=/usr/share/unicode/ucd
175+
cmake --build --preset linux-gcc-debug -j$(nproc)
194176
- name: test
195177
run: |
196-
ctest --test-dir build
178+
ctest --preset linux-gcc-debug

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ endif()
2222
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2323
set(CMAKE_CXX_EXTENSIONS OFF)
2424

25+
set(CMAKE_COLOR_DIAGNOSTICS ON)
26+
2527
if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
2628
add_compile_options(-Wall)
2729
add_compile_options(-Wextra)
@@ -100,6 +102,7 @@ message(STATUS "----------------------------------------------------------------
100102
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
101103
message(STATUS "Build mode: ${LIBUNICODE_BUILD_MODE}")
102104
message(STATUS "Build unit tests: ${LIBUNICODE_TESTING}")
105+
message(STATUS "Build benchmark: ${LIBUNICODE_BENCHMARK}")
103106
message(STATUS "Build tools: ${LIBUNICODE_TOOLS}")
104107
message(STATUS "Using ccache: ${USING_CCACHE_STRING}")
105108
message(STATUS "Using UCD directory: ${LIBUNICODE_UCD_DIR}")

CMakePresets.json

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,9 @@
55
"minor": 27,
66
"patch": 0
77
},
8-
"configurePresets": [
9-
{
10-
"name": "local-devel",
11-
"hidden": true,
12-
"cacheVariables": {
13-
"CMAKE_CXX_FLAGS": "-march=native"
14-
}
15-
},
16-
{
17-
"name": "libunicode-common",
18-
"hidden": true,
19-
"binaryDir": "${sourceDir}/build/${presetName}",
20-
"generator": "Ninja",
21-
"cacheVariables": {
22-
"LIBUNICODE_TESTING": "ON",
23-
"LIBUNICODE_BENCHMARK": "ON",
24-
"PEDANTIC_COMPILER": "OFF",
25-
"PEDANTIC_COMPILER_WERROR": "ON"
26-
}
27-
},
28-
{
29-
"name": "release",
30-
"hidden": true,
31-
"cacheVariables": {
32-
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
33-
}
34-
},
35-
{
36-
"name": "linux-clang-release",
37-
"displayName": "Linux 64-bit",
38-
"inherits": ["libunicode-common", "release"],
39-
"cacheVariables": {
40-
"CMAKE_CXX_COMPILER": "clang++"
41-
}
42-
},
43-
{
44-
"name": "linux-gcc-release",
45-
"displayName": "Linux 64-bit",
46-
"inherits": ["libunicode-common", "release"],
47-
"cacheVariables": {
48-
"CMAKE_CXX_COMPILER": "g++"
49-
}
50-
},
51-
{
52-
"name": "linux-devel-clang-release",
53-
"displayName": "Linux 64-bit",
54-
"inherits": ["libunicode-common", "release", "local-devel"],
55-
"cacheVariables": {
56-
"CMAKE_CXX_COMPILER": "clang++"
57-
}
58-
},
59-
{
60-
"name": "linux-devel-gcc-release",
61-
"displayName": "Linux 64-bit",
62-
"inherits": ["libunicode-common", "release", "local-devel"],
63-
"cacheVariables": {
64-
"CMAKE_CXX_COMPILER": "g++"
65-
}
66-
}
67-
],
68-
"buildPresets": [
69-
{ "name": "linux-clang-release", "configurePreset": "linux-clang-release" },
70-
{ "name": "linux-gcc-release", "configurePreset": "linux-gcc-release" },
71-
{ "name": "linux-devel-clang-release", "configurePreset": "linux-devel-clang-release" },
72-
{ "name": "linux-devel-gcc-release", "configurePreset": "linux-devel-gcc-release" }
8+
"include": [
9+
"cmake/presets/os-linux.json",
10+
"cmake/presets/os-macos.json",
11+
"cmake/presets/os-windows.json"
7312
]
7413
}

autogen.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

cmake/presets/common.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{ "name": "debug", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } },
5+
{ "name": "release", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" } },
6+
{ "name": "arch-native", "hidden": true, "cacheVariables": { "CMAKE_CXX_FLAGS": "-march=native" } },
7+
{ "name": "clang", "hidden": true, "cacheVariables": { "CMAKE_CXX_COMPILER": "clang++" } },
8+
{ "name": "gcc", "hidden": true, "cacheVariables": { "CMAKE_CXX_COMPILER": "g++" } },
9+
{
10+
"name": "libunicode-common",
11+
"hidden": true,
12+
"binaryDir": "${sourceDir}/build/${presetName}",
13+
"cacheVariables": {
14+
"LIBUNICODE_BENCHMARK": "ON",
15+
"LIBUNICODE_TESTING": "ON",
16+
"PEDANTIC_COMPILER": "ON",
17+
"PEDANTIC_COMPILER_WERROR": "ON"
18+
}
19+
}
20+
]
21+
}

cmake/presets/os-linux.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"version": 6,
3+
"include": [ "common.json" ],
4+
"configurePresets": [
5+
{
6+
"name": "linux-common",
7+
"inherits": "libunicode-common",
8+
"generator": "Ninja",
9+
"hidden": true,
10+
"condition": {
11+
"type": "equals",
12+
"lhs": "${hostSystemName}",
13+
"rhs": "Linux"
14+
}
15+
},
16+
{
17+
"name": "linux-clang-debug",
18+
"displayName": "Linux (Clang) Debug",
19+
"inherits": ["linux-common", "debug", "clang"]
20+
},
21+
{
22+
"name": "linux-clang-release",
23+
"displayName": "Linux (Clang) Release",
24+
"inherits": ["linux-common", "release", "clang"]
25+
},
26+
{
27+
"name": "linux-gcc-debug",
28+
"displayName": "Linux (GCC) Debug",
29+
"inherits": ["linux-common", "debug", "gcc"]
30+
},
31+
{
32+
"name": "linux-gcc-release",
33+
"displayName": "Linux (GCC) Release",
34+
"inherits": ["linux-common", "release", "gcc"]
35+
},
36+
{
37+
"name": "linux-native-clang-release",
38+
"displayName": "Linux (Clang, Native arch, Release)",
39+
"inherits": ["linux-common", "release", "arch-native", "clang"]
40+
},
41+
{
42+
"name": "linux-native-gcc-release",
43+
"displayName": "Linux (GCC, Native arch, Release)",
44+
"inherits": ["linux-common", "release", "arch-native", "gcc"]
45+
}
46+
],
47+
"buildPresets": [
48+
{ "name": "linux-clang-debug", "configurePreset": "linux-clang-debug" },
49+
{ "name": "linux-clang-release", "configurePreset": "linux-clang-release" },
50+
{ "name": "linux-gcc-debug", "configurePreset": "linux-gcc-debug" },
51+
{ "name": "linux-gcc-release", "configurePreset": "linux-gcc-release" },
52+
{ "name": "linux-native-clang-release", "configurePreset": "linux-native-clang-release" },
53+
{ "name": "linux-native-gcc-release", "configurePreset": "linux-native-gcc-release" }
54+
],
55+
"testPresets": [
56+
{ "name": "linux-clang-debug", "configurePreset": "linux-clang-debug", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } },
57+
{ "name": "linux-clang-release", "configurePreset": "linux-clang-release", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } },
58+
{ "name": "linux-gcc-debug", "configurePreset": "linux-gcc-debug", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } },
59+
{ "name": "linux-gcc-release", "configurePreset": "linux-gcc-release", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } }
60+
]
61+
}

cmake/presets/os-macos.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": 6,
3+
"include": [ "common.json" ],
4+
"configurePresets": [
5+
{
6+
"name": "macos-common",
7+
"inherits": "libunicode-common",
8+
"generator": "Ninja",
9+
"hidden": true,
10+
"condition": {
11+
"type": "equals",
12+
"lhs": "${hostSystemName}",
13+
"rhs": "Darwin"
14+
}
15+
},
16+
{ "name": "macos-debug", "displayName": "MacOS Debug", "inherits": ["macos-common", "debug"] },
17+
{ "name": "macos-release", "displayName": "MacOS Release", "inherits": ["macos-common", "release"] }
18+
],
19+
"buildPresets": [
20+
{ "name": "macos-debug", "configurePreset": "macos-debug" },
21+
{ "name": "macos-release", "configurePreset": "macos-release" }
22+
],
23+
"testPresets": [
24+
{ "name": "macos-debug", "configurePreset": "macos-debug", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } },
25+
{ "name": "macos-release", "configurePreset": "macos-release", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } }
26+
]
27+
}

0 commit comments

Comments
 (0)