Skip to content

Commit

Permalink
Merge pull request #36 from DeveloperPaul123/feature/build-setup-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperPaul123 authored Sep 17, 2024
2 parents 735c790 + 5d79e82 commit 9378aad
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 151 deletions.
88 changes: 82 additions & 6 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,104 @@
name: Ubuntu

on: [push]
on:
push:
branches: [ develop, main]
pull_request:
branches: [ develop, main ]

env:
CTEST_OUTPUT_ON_FAILURE: 1

jobs:
build:
build-gcc:
runs-on: ${{matrix.os}}
name: ${{ matrix.os}} ${{ matrix.version }} C++${{ matrix.cpp }}
name: ${{ matrix.os}} gcc${{ matrix.version }} C++${{ matrix.cpp }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
os: [ubuntu-latest, ubuntu-20.04]
os: [ubuntu-20.04, ubuntu-22.04]
cpp: [17]
version: [gcc7, gcc8, gcc9, clang]
version: [9, 10, 11]
include:
- os: ubuntu-22.04
version: 12
- os: ubuntu-20.04
version: 7
- os: ubuntu-20.04
version: 8
env:
CPP_STANDARD: ${{ matrix.cpp }}
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}

- name: set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: ${{matrix.version}}
platform: x64

- name: Configure
run: cmake -S . -B build

- name: Build
run: cmake --build build --config Debug -j4

- name: Run tests
run: |
cd build
ctest --build-config Debug
build-clang:
runs-on: ${{matrix.os}}
name: ${{ matrix.os}} clang${{ matrix.version }} C++${{ matrix.cpp }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
cpp: [17]
version: [14, 15, 16, 17]
include:
- os: ubuntu-22.04
version: 18
env:
CPP_STANDARD: ${{ matrix.cpp }}
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}

# clang needs GCC
- name: set up GCC
uses: egor-tensin/setup-gcc@v1
with:
version: 11
platform: x64

- name: Install libs
run: |
sudo apt-get update
sudo apt-get install build-essential -y
- name: Set up Clang
run: |
wget -O llvm.sh https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{matrix.version}}
- name: Configure
run: cmake -S . -B build
env:
CC: clang-${{matrix.version}}
CXX: clang++-${{matrix.version}}

- name: Build
run: cmake --build build --config Debug -j4
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: Windows

on:
push:
branches:
- master
- develop
branches: [ develop, main]
pull_request:
branches: [ develop ]
branches: [ develop, main ]

env:
CTEST_OUTPUT_ON_FAILURE: 1
Expand Down
25 changes: 7 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,24 @@ set(CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED ON)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

include(CPM)
option(EVENTBUS_BUILD_TESTS "Build unit tests." ON)

# set up warnings interface project to re-use
include(CompilerWarnings)
add_library(project_warnings INTERFACE)
set_project_warnings(project_warnings)

# set up options interface project to re-use
add_library(project_options INTERFACE)
# this project requires C++17
target_compile_features(project_options INTERFACE cxx_std_17)

if(EVENTBUS_BUILD_TESTS)
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM.cmake")
set(CPM_VERSION 0.27.3)

if(NOT EXISTS ${CPM_DOWNLOAD_LOCATION})
message(STATUS "Downloading CPM.cmake")
file(DOWNLOAD https://raw.githubusercontent.com/TheLartians/CPM/v${CPM_VERSION}/cmake/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
endif(NOT EXISTS ${CPM_DOWNLOAD_LOCATION})

include(${CPM_DOWNLOAD_LOCATION})

CPMAddPackage(
NAME googletest
GITHUB_REPOSITORY google/googletest
GIT_TAG release-1.8.1
VERSION 1.8.1
OPTIONS
"INSTALL_GTEST OFF"
"gtest_force_shared_crt ON"
NAME doctest
GITHUB_REPOSITORY onqtam/doctest
VERSION 2.4.11
)

# this needs to be in the top level directory
Expand Down
160 changes: 160 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"version": 3,
"configurePresets": [
{
"name": "linux-base",
"hidden": true,
"description": "Target the Windows Subsystem for Linux (WSL) or a remote Linux system.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
},
"cacheVariables": {
"EVENTBUS_BUILD_TESTS": "ON"
}
},
{
"name": "windows-base",
"description": "Target Windows with the Visual Studio development environment.",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "cl",
"CMAKE_C_COMPILER": "cl"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "gcc-base",
"hidden": true,
"inherits": "linux-base",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_C_COMPILER": "gcc"
}
},
{
"name": "gcc-debug",
"inherits": "gcc-base",
"displayName": "GCC Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "gcc-release",
"inherits": "gcc-base",
"displayName": "GCC Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "clang-base",
"hidden": true,
"inherits": "linux-base",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_C_COMPILER": "clang"
}
},
{
"name": "clang-debug",
"inherits": "clang-base",
"displayName": "Clang Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "clang-release",
"inherits": "clang-base",
"displayName": "Clang Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "clang-release-with-debug-info",
"inherits": "clang-base",
"displayName": "Clang RelWithDebInfo",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"description": "Target Windows (64-bit) with the Visual Studio development environment. (Debug)",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-debug-clang",
"displayName": "x64 Debug Clang",
"description": "Target Windows (64-bit) with Clang",
"inherits": "windows-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "x64-release-clang",
"displayName": "x64 Release Clang",
"description": "Target Windows (64-bit) with Clang (Release)",
"inherits": "windows-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"description": "Target Windows (64-bit) with the Visual Studio development environment. (Release)",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-release-with-debug",
"displayName": "x64 Release w/Debug",
"description": "Target Windows (64-bit) with the Visual Studio development environment. (RelWithDebInfo)",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
}
]
}
Loading

0 comments on commit 9378aad

Please sign in to comment.