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

Update to use cmake presets #237

Merged
merged 10 commits into from
Jul 24, 2022
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
15 changes: 8 additions & 7 deletions .doxybook/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"baseUrl": "/engine/",
"indexInFolders": false,
"linkSuffix": "/",
"mainPageInRoot": true,
"mainPageName": "index",
"foldersToGenerate": ["classes", "pages", "namespaces"]
}
"baseUrl": "/engine/",
"indexInFolders": false,
"linkSuffix": "/",
"mainPageInRoot": true,
"mainPageName": "index",
"collapse_navigation": true,
"foldersToGenerate": ["classes", "pages", "namespaces"]
}
163 changes: 84 additions & 79 deletions .github/workflows/tec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,91 +3,89 @@ name: Trillek Engine CI
on:
pull_request:
push:
tags: [ v* ]
tags: [v*]

jobs:
build:
env:
buildDir: '${{ github.workspace }}/build'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest, windows-2016, ubuntu-18.04, ubuntu-16.04, macOS-latest ]
arch: [ x86, x64 ]
os:
[
windows-latest,
windows-2019,
ubuntu-latest,
ubuntu-18.04,
macOS-latest,
]
arch: [x86, x64]
include:
- os: windows-latest
vcpkgCommitId: '5568f110b509a9fd90711978a7cb76bae75bb092'
vcpkgTripletOs: windows
- os: windows-2016
vcpkgCommitId: '5568f110b509a9fd90711978a7cb76bae75bb092'
- os: windows-2019
vcpkgTripletOs: windows
- os: ubuntu-18.04
vcpkgCommitId: '5568f110b509a9fd90711978a7cb76bae75bb092'
- os: ubuntu-latest
vcpkgTripletOs: linux
- os: ubuntu-16.04
vcpkgCommitId: '5568f110b509a9fd90711978a7cb76bae75bb092'
- os: ubuntu-18.04
vcpkgTripletOs: linux
- os: macOS-latest
vcpkgCommitId: '5568f110b509a9fd90711978a7cb76bae75bb092'
vcpkgTripletOs: osx
exclude:
- os: ubuntu-18.04
- os: ubuntu-latest
arch: x86
- os: ubuntu-16.04
- os: ubuntu-18.04
arch: x86
- os: macOS-latest
arch: x86
env:
buildDir: "${{ github.workspace }}/build"
BUILD_PRESET: release
CONFIG_PRESET: ninja-multi-vcpkg-ci
VCPKG_COMMIT_ID: 98f8d00e89fb6a8019c2045cfa1edbe9d92d3405
VCPKG_DEFAULT_TRIPLET: ${{ matrix.arch }}-${{ matrix.vcpkgTripletOs }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: lukka/get-cmake@latest
- name: Install os deps (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libgl1-mesa-dev xorg-dev libglu1-mesa-dev libxinerama-dev libxcursor-dev p7zip-full -y
- name: Set gcc-9 on Ubuntu16.04
uses: lukka/set-shell-env@v1
if: contains( matrix.os, 'ubuntu-16.04')
with:
CC: gcc-9
CXX: g++-9
- name: Restore artifacts, or run vcpkg, build and cache artifacts
uses: lukka/run-vcpkg@v6
id: runvcpkg
with:
# Cmake will do the setup using vcpkg.json
setupOnly: true
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
vcpkgTriplet: ${{ matrix.arch }}-${{ matrix.vcpkgTripletOs }}
# Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed' directory.
additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed
vcpkgGitCommitId: '${{ matrix.vcpkgCommitId }}'
- name: Configure cmake and build
uses: lukka/run-cmake@v3
id: runcmake_cmd
with:
cmakeListsOrSettingsJson: 'CMakeListsTxtBasic'
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
cmakeBuildType: 'Release'
useVcpkgToolchainFile: true
buildWithCMake: true
buildDirectory: ${{ env.buildDir }}
- name: Upload the build artifact
uses: actions/upload-artifact@v2
with:
name: 'trillek-${{ matrix.os }}'
path: |
assets/
${{ env.buildDir }}/client/trillek-client
${{ env.buildDir }}/client/trillek-client.exe
${{ env.buildDir }}/client/*.dll
${{ env.buildDir }}/server/trillek-serverd
${{ env.buildDir }}/server/trillek-server.exe
if-no-files-found: ignore
- uses: actions/checkout@v2
with:
submodules: true
- uses: lukka/get-cmake@latest
- name: Install os deps (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libgl1-mesa-dev xorg-dev libglu1-mesa-dev libxinerama-dev libxcursor-dev p7zip-full -y
- name: Set gcc-9 on Ubuntu16.04
uses: lukka/set-shell-env@v1
if: contains( matrix.os, 'ubuntu-16.04')
with:
CC: gcc-9
CXX: g++-9
- name: Restore artifacts, or run vcpkg, build and cache artifacts
uses: lukka/run-vcpkg@v10
with:
appendedCacheKey: ${{ env.VCPKG_DEFAULT_TRIPLET }}
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
- name: Configure cmake and build
uses: lukka/run-cmake@v10
with:
configurePreset: ${{ env.CONFIG_PRESET }}
buildPreset: ${{ env.CONFIG_PRESET }}-${{ env.BUILD_PRESET }}
testPreset: ${{ env.CONFIG_PRESET }}-${{ env.BUILD_PRESET }}
- name: Upload the build artifact
uses: actions/upload-artifact@v2
with:
name: "trillek-${{ matrix.os }}"
path: |
assets/
${{ env.CLIENT_BUILD_DIR }}/trillek-client
${{ env.CLIENT_BUILD_DIR }}/trillek-client.exe
${{ env.CLIENT_BUILD_DIR }}/*.dll
${{ env.SERVER_BUILD_DIR }}/trillek-serverd
${{ env.SERVER_BUILD_DIR }}/trillek-server.exe
if-no-files-found: ignore
env:
CLIENT_BUILD_DIR: ${{ github.workspace }}/builds/${{ env.CONFIG_PRESET }}/client/Release
SERVER_BUILD_DIR: ${{ github.workspace }}/builds/${{ env.CONFIG_PRESET }}/server/Release
prepublish:
runs-on: ubuntu-latest
needs: build
Expand All @@ -96,31 +94,38 @@ jobs:
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: '${{ github.ref }}'
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{ github.ref }}"
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
publish:
runs-on: ubuntu-latest
needs: prepublish
strategy:
fail-fast: false
matrix:
os: [ windows-latest, windows-2016, ubuntu-18.04, ubuntu-16.04, macOS-latest ]
arch: [ x64 ]
os:
[
windows-latest,
windows-2016,
ubuntu-18.04,
ubuntu-16.04,
macOS-latest,
]
arch: [x64]
if: startsWith(github.ref, 'refs/tags/v')
name: Upload Release Asset(s)
steps:
- name: Download a single artifact
uses: actions/download-artifact@v2
with:
name: 'trillek-${{ matrix.os }}'
name: "trillek-${{ matrix.os }}"
- name: Package release
run: |
zip --junk-paths -r -u trillek-${{ matrix.os }}.zip build/client
Expand All @@ -133,6 +138,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.prepublish.outputs.upload_url }}
asset_path: './trillek-${{ matrix.os }}.zip'
asset_name: 'trillek-${{ matrix.os }}.zip'
asset_path: "./trillek-${{ matrix.os }}.zip"
asset_name: "trillek-${{ matrix.os }}.zip"
asset_content_type: application/zip
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ temp/
.vs/
build-idea/
.idea/
doxygen/
# Created in the build pipeline don't commit them from the pipeline
doxybook2/
/doxygen/
/mkdocs/
vcpkg/
vcpkg_installed/
builds/
15 changes: 15 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/readthedocs/readthedocs.org/main/readthedocs/rtd_tests/fixtures/spec/v2/schema.json

version: 2

build:
os: ubuntu-20.04
tools:
python: "3.9"

mkdocs:
configuration: mkdocs.yml

python:
install:
- requirements: docs/requirements.txt
27 changes: 27 additions & 0 deletions .vs/launch.vs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "trillek-client.exe (client\\Debug\\trillek-client.exe)",
"name": "trillek-client.exe (client\\Debug\\trillek-client.exe)",
"currentDir": "${workspaceRoot}"
},
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "trillek-server.exe (server\\Debug\\trillek-server.exe)",
"name": "trillek-server.exe (server\\Debug\\trillek-server.exe)",
"currentDir": "${workspaceRoot}"
},
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "tests.exe (tests\\Debug\\tests.exe)",
"name": "tests.exe (tests\\Debug\\tests.exe)",
"currentDir": "${workspaceRoot}"
}
]
}
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cppvsdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"externalConsole": true,
"name": "Run Trillek Target",
"cwd": "${workspaceFolder}",
"stopAtEntry": false
}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.associations": {
"*.proto": "proto3",
"*.txt": "cmake",
"*.inc": "cpp"
}
}
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.19)
project(trillek)

option(BUILD_CLIENT "Build the client" ON)
option(BUILD_SERVER "Build the server" ON)
option(BUILD_TESTS "Build tests" OFF)
option(BUILD_DOCS "Build documentation" OFF)

# TODO: Perhaps add -pedantic -Wall -Wextra -Werror?
list(APPEND CMAKE_MODULE_PATH ${trillek_SOURCE_DIR}/deps)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_definitions(-DASIO_STANDALONE)

if (WIN32)
add_definitions(-DWIN32)
endif()

if (MSVC)
add_definitions(-DPROTOBUF_USE_DLLS -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -D_WIN32_WINNT=0x0601 -DWIN32_LEAN_AND_MEAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4125") # Auto generated protobuf gives lots of these on msvc
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") # MSVC define __cplusplus workaround

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(/EHsc)
add_definitions(-DWIN32)
endif()
# Only MSVC compiler understands these flags
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# The following turns off warnings in external libraries until the generator respects include_directories(SYSTEM ...) see https://devblogs.microsoft.com/cppblog/broken-warnings-theory/
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /experimental:external /external:anglebrackets /external:W0")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(/EHsc)
endif()
# Only MSVC compiler understands these flags
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# The following turns off warnings in external libraries until the generator respects include_directories(SYSTEM ...) see https://devblogs.microsoft.com/cppblog/broken-warnings-theory/
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /experimental:external /external:anglebrackets /external:W0")
endif()
endif()

set(BUILD_STATIC_VCOMPUTER TRUE CACHE BOOL "Build Trillek VCOMPUTER library - static version")
Expand All @@ -44,5 +47,9 @@ if (BUILD_SERVER)
add_subdirectory(server)
endif ()
if (BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif ()
if (BUILD_DOCS)
add_subdirectory(docs_targets)
endif()
Loading