Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMakePresets to conveniently build and work with the sources #92

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 26 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ jobs:
"GCC 10",
"Clang 9",
"Clang 10",
"Clang 11",
# (CI related error) "Clang 11",
"Clang 12"
]
name: "Ubuntu Linux 20.04 (${{ matrix.compiler }})"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
Expand Down Expand Up @@ -78,14 +78,14 @@ jobs:
[
"GCC 10",
"GCC 13",
"Clang 11",
# (CI related error) "Clang 11",
"Clang 15"
]
# gcc 13 only in github runners and not inside official repo
name: "Ubuntu Linux 22.04 (${{ matrix.compiler }})"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
Expand Down Expand Up @@ -113,68 +113,49 @@ jobs:
- name: "benchmark"
run: ./build/src/libunicode/libunicode_benchmark


unknown_os:
strategy:
fail-fast: false
name: "Unknown OS"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: "ccache-ubuntu_2004-${{ matrix.compiler }}"
key: "ccache-ubuntu_2004-unknown-os"
max-size: 256M
- name: "Update package database"
run: sudo apt -q update
- name: "install dependencies"
run: OS_OVERRIDE=UNKNOWN ./scripts/install-deps.sh
- name: "create build directory"
run: mkdir build
- name: "cmake"
run: |
BUILD_DIR="build" \
CMAKE_BUILD_TYPE="RelWithDebInfo" \
./scripts/ci-prepare.sh
set -ex
sudo apt install -q -y ninja-build gcc build-essential cmake debhelper dpkg-dev g++ libc6-dev
OS_OVERRIDE=UNKNOWN ./scripts/install-deps.sh
- name: "cmake"
run: cmake --preset linux-gcc-release
- name: "build"
run: cmake --build build/ -- -j3
run: cmake --build --preset linux-gcc-release -j3
- name: "test"
run: ./build/src/libunicode/unicode_test
run: ctest --preset linux-gcc-release

windows:
name: "Windows"
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: "Fetch embedded dependencies"
shell: powershell
run: |
./scripts/install-deps.ps1
type ./_deps/sources/CMakeLists.txt
- uses: actions/checkout@v4
- name: "vcpkg: Install dependencies"
uses: lukka/run-vcpkg@v5
uses: lukka/run-vcpkg@v11.1
id: runvcpkg
with:
vcpkgArguments: fmt range-v3
vcpkgDirectory: ${{ runner.workspace }}/vcpkg/
vcpkgGitCommitId: 21fa4ccecfefd96bb16faac4af17fcb900d4f8b3
vcpkgTriplet: x64-windows
- name: "create build directory"
shell: powershell
run: |
If (!(Test-Path build))
{
New-Item -ItemType Directory -Force -Path build
}
vcpkgGitCommitId: 80403036a665cb8fcc1a1b3e17593d20b03b2489
- name: "List cmake presets"
run: cmake --list-presets
- name: "Generate build files"
env:
WORKSPACE: ${{ runner.workspace }}
run: ./scripts/ci-prepare.ps1
run: cmake --preset windows-cl-release -DCMAKE_TOOLCHAIN_FILE="${{ runner.workspace }}\vcpkg\scripts\buildsystems\vcpkg.cmake"
- name: "Build"
run: cmake --build build/ --config Release
- name: "test: libterminal"
run: .\build\src\libunicode\Release\unicode_test.exe
run: cmake --build --preset windows-cl-release
- name: "test"
run: ctest --preset windows-cl-release

Fedora:
name: Fedora
Expand All @@ -185,12 +166,13 @@ jobs:
- uses: actions/checkout@v4
- name: Install build dependencies
run: |
dnf install -y curl
PREPARE_ONLY_EMBEDS=OFF SYSDEP_ASSUME_YES=ON ./scripts/install-deps.sh
dnf install -y unicode-ucd
- name: CMake build
run: |
cmake . -G Ninja -B build -DBUILD_SHARED_LIBS=ON -DLIBUNICODE_UCD_DIR=/usr/share/unicode/ucd
cmake --build build -j$(nproc)
cmake --preset linux-gcc-debug -DLIBUNICODE_UCD_DIR=/usr/share/unicode/ucd
cmake --build --preset linux-gcc-debug -j$(nproc)
- name: test
run: |
ctest --test-dir build
ctest --preset linux-gcc-debug
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_COLOR_DIAGNOSTICS ON)

if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
add_compile_options(-Wall)
add_compile_options(-Wextra)
Expand Down Expand Up @@ -100,6 +102,7 @@ message(STATUS "----------------------------------------------------------------
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Build mode: ${LIBUNICODE_BUILD_MODE}")
message(STATUS "Build unit tests: ${LIBUNICODE_TESTING}")
message(STATUS "Build benchmark: ${LIBUNICODE_BENCHMARK}")
message(STATUS "Build tools: ${LIBUNICODE_TOOLS}")
message(STATUS "Using ccache: ${USING_CCACHE_STRING}")
message(STATUS "Using UCD directory: ${LIBUNICODE_UCD_DIR}")
Expand Down
69 changes: 4 additions & 65 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,9 @@
"minor": 27,
"patch": 0
},
"configurePresets": [
{
"name": "local-devel",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-march=native"
}
},
{
"name": "libunicode-common",
"hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}",
"generator": "Ninja",
"cacheVariables": {
"LIBUNICODE_TESTING": "ON",
"LIBUNICODE_BENCHMARK": "ON",
"PEDANTIC_COMPILER": "OFF",
"PEDANTIC_COMPILER_WERROR": "ON"
}
},
{
"name": "release",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "linux-clang-release",
"displayName": "Linux 64-bit",
"inherits": ["libunicode-common", "release"],
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "linux-gcc-release",
"displayName": "Linux 64-bit",
"inherits": ["libunicode-common", "release"],
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "linux-devel-clang-release",
"displayName": "Linux 64-bit",
"inherits": ["libunicode-common", "release", "local-devel"],
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "linux-devel-gcc-release",
"displayName": "Linux 64-bit",
"inherits": ["libunicode-common", "release", "local-devel"],
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++"
}
}
],
"buildPresets": [
{ "name": "linux-clang-release", "configurePreset": "linux-clang-release" },
{ "name": "linux-gcc-release", "configurePreset": "linux-gcc-release" },
{ "name": "linux-devel-clang-release", "configurePreset": "linux-devel-clang-release" },
{ "name": "linux-devel-gcc-release", "configurePreset": "linux-devel-gcc-release" }
"include": [
"cmake/presets/os-linux.json",
"cmake/presets/os-macos.json",
"cmake/presets/os-windows.json"
]
}
31 changes: 0 additions & 31 deletions autogen.sh

This file was deleted.

21 changes: 21 additions & 0 deletions cmake/presets/common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": 6,
"configurePresets": [
{ "name": "debug", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "release", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" } },
{ "name": "arch-native", "hidden": true, "cacheVariables": { "CMAKE_CXX_FLAGS": "-march=native" } },
{ "name": "clang", "hidden": true, "cacheVariables": { "CMAKE_CXX_COMPILER": "clang++" } },
{ "name": "gcc", "hidden": true, "cacheVariables": { "CMAKE_CXX_COMPILER": "g++" } },
{
"name": "libunicode-common",
"hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"LIBUNICODE_BENCHMARK": "ON",
"LIBUNICODE_TESTING": "ON",
"PEDANTIC_COMPILER": "ON",
"PEDANTIC_COMPILER_WERROR": "ON"
}
}
]
}
61 changes: 61 additions & 0 deletions cmake/presets/os-linux.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"version": 6,
"include": [ "common.json" ],
"configurePresets": [
{
"name": "linux-common",
"inherits": "libunicode-common",
"generator": "Ninja",
"hidden": true,
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "linux-clang-debug",
"displayName": "Linux (Clang) Debug",
"inherits": ["linux-common", "debug", "clang"]
},
{
"name": "linux-clang-release",
"displayName": "Linux (Clang) Release",
"inherits": ["linux-common", "release", "clang"]
},
{
"name": "linux-gcc-debug",
"displayName": "Linux (GCC) Debug",
"inherits": ["linux-common", "debug", "gcc"]
},
{
"name": "linux-gcc-release",
"displayName": "Linux (GCC) Release",
"inherits": ["linux-common", "release", "gcc"]
},
{
"name": "linux-native-clang-release",
"displayName": "Linux (Clang, Native arch, Release)",
"inherits": ["linux-common", "release", "arch-native", "clang"]
},
{
"name": "linux-native-gcc-release",
"displayName": "Linux (GCC, Native arch, Release)",
"inherits": ["linux-common", "release", "arch-native", "gcc"]
}
],
"buildPresets": [
{ "name": "linux-clang-debug", "configurePreset": "linux-clang-debug" },
{ "name": "linux-clang-release", "configurePreset": "linux-clang-release" },
{ "name": "linux-gcc-debug", "configurePreset": "linux-gcc-debug" },
{ "name": "linux-gcc-release", "configurePreset": "linux-gcc-release" },
{ "name": "linux-native-clang-release", "configurePreset": "linux-native-clang-release" },
{ "name": "linux-native-gcc-release", "configurePreset": "linux-native-gcc-release" }
],
"testPresets": [
{ "name": "linux-clang-debug", "configurePreset": "linux-clang-debug", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } },
{ "name": "linux-clang-release", "configurePreset": "linux-clang-release", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } },
{ "name": "linux-gcc-debug", "configurePreset": "linux-gcc-debug", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } },
{ "name": "linux-gcc-release", "configurePreset": "linux-gcc-release", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } }
]
}
27 changes: 27 additions & 0 deletions cmake/presets/os-macos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": 6,
"include": [ "common.json" ],
"configurePresets": [
{
"name": "macos-common",
"inherits": "libunicode-common",
"generator": "Ninja",
"hidden": true,
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{ "name": "macos-debug", "displayName": "MacOS Debug", "inherits": ["macos-common", "debug"] },
{ "name": "macos-release", "displayName": "MacOS Release", "inherits": ["macos-common", "release"] }
],
"buildPresets": [
{ "name": "macos-debug", "configurePreset": "macos-debug" },
{ "name": "macos-release", "configurePreset": "macos-release" }
],
"testPresets": [
{ "name": "macos-debug", "configurePreset": "macos-debug", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } },
{ "name": "macos-release", "configurePreset": "macos-release", "output": {"outputOnFailure": true}, "execution": { "noTestsAction": "error", "stopOnFailure": true } }
]
}
Loading
Loading