Skip to content

Commit

Permalink
Merge pull request #9 from contour-terminal/improvements/build-process
Browse files Browse the repository at this point in the history
Build & install process improvements
  • Loading branch information
christianparpart authored Oct 25, 2023
2 parents a4feadd + f120901 commit 7f86c88
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 92 deletions.
87 changes: 16 additions & 71 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,28 @@ on:
- '*.sh'
branches:
- master
- feature/**
- fix/**
- improvement/**
pull_request:
branches:
- master

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
CTEST_OUTPUT_ON_FAILURE: 1
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules

jobs:
ubuntu_2004:
name: "Ubuntu Linux 20.04"
runs-on: ubuntu-20.04
ubuntu_linux:
name: "Ubuntu Linux 22.04"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: "**/cpm_modules"
key: ${{github.workflow}}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
- name: set environment variables
id: set_vars
run: ./scripts/ci-set-vars.sh
env:
REPOSITORY: ${{ github.event.repository.name }}
- name: "install dependencies"
run: |
set -ex
sudo apt -q update
sudo ./scripts/install-deps.sh
- name: "create build directory"
run: mkdir build
- name: "cmake"
run: |
BUILD_DIR="build" \
CMAKE_BUILD_TYPE="RelWithDebInfo" \
CXX="g++-9" \
EXTRA_CMAKE_FLAGS="" \
./scripts/ci-prepare-contour.sh
- name: "build"
run: cmake --build build/ -- -j3

ubuntu1804:
name: "Ubuntu Linux 18.04"
runs-on: ubuntu-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
path: "**/cpm_modules"
key: ${{github.workflow}}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
key: "ccache-ubuntu_2204"
max-size: 256M
- name: set environment variables
id: set_vars
run: ./scripts/ci-set-vars.sh
Expand All @@ -74,17 +43,8 @@ jobs:
set -ex
sudo apt -q update
sudo ./scripts/install-deps.sh
- name: "Get specific version CMake, v3.18.3"
uses: lukka/[email protected]
- name: "create build directory"
run: mkdir build
- name: "cmake"
run: |
BUILD_DIR="build" \
CMAKE_BUILD_TYPE="Release" \
CXX="g++-8" \
EXTRA_CMAKE_FLAGS="-DCONTOUR_BLUR_PLATFORM_KWIN=ON -DUSE_BOOST_FILESYSTEM=ON" \
./scripts/ci-prepare-contour.sh
run: cmake -S . -B build -DCMAKE_BUILD_TYPE="RelWithDebInfo"
- name: "build"
run: cmake --build build/ -- -j3

Expand All @@ -110,14 +70,7 @@ jobs:
- name: "Create build directory"
run: mkdir build
- name: "Generate build files"
run: |
cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DYAML_BUILD_SHARED_LIBS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF \
-DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF \
-DYAML_CPP_INSTALL=OFF \
-DQt5_DIR="$(brew --prefix qt5)/lib/cmake/Qt5" \
-B build/
run: cmake -S . -B build -DCMAKE_BUILD_TYPE="RelWithDebInfo"
- name: "Build"
run: cmake --build build/

Expand All @@ -126,26 +79,18 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: "**/cpm_modules"
key: ${{github.workflow}}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
- name: setup environment
shell: powershell
id: set_vars
run: .\scripts\ci-set-vars.ps1
env:
REPOSITORY: ${{ github.event.repository.name }}
- name: Install Qt
uses: jurplel/install-qt-action@v2
- name: "vcpkg: Install dependencies"
uses: lukka/run-vcpkg@v5
uses: lukka/run-vcpkg@v11.1
id: runvcpkg
with:
vcpkgArguments: freetype fontconfig harfbuzz
vcpkgDirectory: ${{ runner.workspace }}/vcpkg/
vcpkgGitCommitId: b063d0cee7389514a0841cf1e2e055d6466fe4b8
vcpkgTriplet: x64-windows
vcpkgGitCommitId: 3e93bb69a1cadeb36fe9eca3b6f3912d84f618d5
- name: "create build directory"
shell: powershell
run: |
Expand All @@ -154,6 +99,6 @@ jobs:
New-Item -ItemType Directory -Force -Path build
}
- name: "Generate build files"
run: cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows -DYAML_BUILD_SHARED_LIBS=OFF -DCONTOUR_EXAMPLES=OFF -DLIBTERMINAL_TESTING=ON -DLIBUNICODE_TESTING=ON -DYAML_CPP_BUILD_CONTRIB=OFF -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF -DYAML_CPP_INSTALL=OFF -B build .
run: cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows -B build .
- name: "Build"
run: cmake --build build/ --config Release
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

project(termbench-pro VERSION "${CONTOUR_VERSION}" LANGUAGES CXX)
project(termbench VERSION "0.2.0" LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand All @@ -14,6 +14,11 @@ if(NOT WIN32 AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo)
endif()

set(MASTER_PROJECT OFF)
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
set(MASTER_PROJECT ON)
endif()

include(EnableCcache)
include(ClangTidy)
include(PedanticCompiler)
Expand All @@ -28,4 +33,4 @@ if(NOT TARGET fmt)
endif()

add_subdirectory(libtermbench)
add_subdirectory(termbenchpro)
add_subdirectory(tb)
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# termbench-pro
# termbench

Termbench Pro is the interim name for a project to benchmark
the terminal emulators backend bandwidth throughput.
Termbench is a project to benchmark the terminal emulators backend bandwidth throughput.

Therefore not just a CLI executable will be provided but also a library
Therefore not just a CLI executable (`tb`) will be provided but also a library
that one can link against to test against your own terminal emulator backend
without being affected by your rendering pipeline.

Expand Down
66 changes: 58 additions & 8 deletions libtermbench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,62 @@
add_library(termbench
termbench.cpp termbench.h
)
include(GNUInstallDirs)

set(_TERMBENCH_LIB_BUILD_MODE)
if(MASTER_PROJECT)
set(_TERMBENCH_LIB_BUILD_MODE "SHARED")
else()
set(_TERMBENCH_LIB_BUILD_MODE "STATIC")
endif()

set(TERMBENCH_LIB_BUILD_MODE ${_TERMBENCH_LIB_BUILD_MODE} CACHE STRING "Choose the build mode." FORCE)
set_property(CACHE TERMBENCH_LIB_BUILD_MODE PROPERTY STRINGS "STATIC" "SHARED")
message(STATUS "termbench library build mode: ${TERMBENCH_LIB_BUILD_MODE}")

set(_PUBLIC_HEADERS termbench.h)
add_library(termbench ${TERMBENCH_LIB_BUILD_MODE} termbench.cpp)
add_library(termbench::termbench ALIAS termbench)
target_compile_features(termbench PUBLIC cxx_std_20)
set_target_properties(termbench PROPERTIES
PUBLIC_HEADER "${_PUBLIC_HEADERS}"
)
set_target_properties(termbench PROPERTIES
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
)
target_link_libraries(termbench PUBLIC fmt::fmt-header-only)

target_compile_features(termbench PUBLIC cxx_std_17)
target_include_directories(termbench PUBLIC
${CMAKE_SOURCE_DIR}
$<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>
target_include_directories(termbench PUBLIC $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

install(TARGETS termbench
EXPORT termbench-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/termbench"
PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/termbench"
FRAMEWORK DESTINATION "."
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# {{{ Generate the version, config and target files
include(CMakePackageConfigHelpers)

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/termbench-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)

configure_package_config_file(termbench-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/termbench-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/termbench
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/termbench-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/termbench-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/termbench
)

install(EXPORT termbench-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/termbench
NAMESPACE termbench::
)
# }}}
8 changes: 8 additions & 0 deletions libtermbench/termbench-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@PACKAGE_INIT@

# prevent repeatedly including the targets
if(NOT TARGET termbench::termbench)
include(${CMAKE_CURRENT_LIST_DIR}/termbench-targets.cmake)
endif()

message(STATUS "Found @PROJECT_NAME@, version: ${@PROJECT_NAME@_VERSION}")
2 changes: 1 addition & 1 deletion libtermbench/termbench.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of the "termbench-pro" project
* This file is part of the "termbench" project
* Copyright (c) 2021 Christian Parpart <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion libtermbench/termbench.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of the "termbench-pro" project
* This file is part of the "termbench" project
* Copyright (c) 2021 Christian Parpart <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
3 changes: 2 additions & 1 deletion scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ install_deps_ubuntu()
cmake
g++
make
libfmt-dev
)

if [[ "${RELEASE}" < "19.04" ]]; then
Expand All @@ -37,7 +38,7 @@ main_linux()
main_darwin()
{
# brew install cmake clang?
return
brew install fmt
}

main()
Expand Down
14 changes: 14 additions & 0 deletions tb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include(GNUInstallDirs)

add_executable(tb main.cpp)
target_link_libraries(tb PRIVATE termbench fmt::fmt-header-only)

# Set the RPATH so that the executable can find the shared libraries
# when installed in a non-standard location
set_target_properties(tb PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
INSTALL_RPATH_USE_LINK_PATH TRUE
)

install(TARGETS tb RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

2 changes: 1 addition & 1 deletion termbenchpro/main.cpp → tb/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file is part of the "termbench-pro" project
* This file is part of the "termbench" project
* Copyright (c) 2021 Christian Parpart <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 0 additions & 2 deletions termbenchpro/CMakeLists.txt

This file was deleted.

7 changes: 7 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"catch2",
"fmt"
]
}

0 comments on commit 7f86c88

Please sign in to comment.