-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port project to CMake Co-authored-by: friendlyanon <friendlyanon@users.noreply.github.com>
- Loading branch information
1 parent
ed82aa7
commit 324025f
Showing
23 changed files
with
870 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
Checks: 'clang-diagnostic-*,clang-analyzer-*' | ||
WarningsAsErrors: '' | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
coverage: | ||
runs-on: ubuntu-latest | ||
|
||
# To enable coverage, go to https://codecov.io/, acquire a token, put it | ||
# into your secrets (Settings > Secrets > New repository secret) and delete | ||
# the "if" conditional below. | ||
# If you do not wish to use codecov, then simply delete this job from the | ||
# workflow. | ||
if: "false" | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Install LCov | ||
run: sudo apt-get update -q | ||
&& sudo apt-get install lcov -q -y | ||
|
||
- name: Install vcpkg | ||
uses: lukka/run-vcpkg@v7 | ||
with: | ||
setupOnly: true | ||
vcpkgGitCommitId: 7c55ecac266fc3e554bc315053dc45c11ec811af | ||
|
||
- name: Configure | ||
run: cmake --preset=ci-coverage | ||
-D "VCPKG_MANIFEST_FEATURES=test;magic-enum" | ||
|
||
- name: Build | ||
run: cmake --build build -j 2 | ||
|
||
- name: Test | ||
working-directory: build | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
PS4: "\e[36m+++\e[0m " | ||
run: | | ||
set -x | ||
ctest --output-on-failure -j 2 | ||
lcov -c -d .. -o coverage.info --include '${{ github.workspace }}/*' | ||
lcov --list coverage.info | ||
bash <(curl -s https://codecov.io/bash) -f coverage.info | ||
sanitize: | ||
name: "sanitize${{ matrix.features && ' (with magic_enum)' }}" | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
features: [";magic-enum", ""] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Install vcpkg | ||
uses: lukka/run-vcpkg@v7 | ||
with: | ||
setupOnly: true | ||
vcpkgGitCommitId: 7c55ecac266fc3e554bc315053dc45c11ec811af | ||
|
||
- name: Configure | ||
env: { CXX: clang++-11 } | ||
run: cmake --preset=ci-sanitizer | ||
-D "VCPKG_MANIFEST_FEATURES=test${{ matrix.features }}" | ||
|
||
- name: Build | ||
run: cmake --build build -j 2 | ||
|
||
- name: Test | ||
env: | ||
ASAN_OPTIONS: "strict_string_checks=1:\ | ||
detect_stack_use_after_return=1:\ | ||
check_initialization_order=1:\ | ||
strict_init_order=1:\ | ||
detect_leaks=1" | ||
UBSAN_OPTIONS: print_stacktrace=1 | ||
run: ctest --test-dir build --output-on-failure -j 2 | ||
|
||
test: | ||
name: "test (${{ matrix.os }}\ | ||
${{ matrix.features && ', with magic_enum' || '' }})" | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
os: [macos, ubuntu, windows] | ||
|
||
features: [";magic-enum", ""] | ||
|
||
runs-on: ${{ matrix.os }}-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Install static analyzers | ||
if: matrix.os == 'ubuntu' | ||
run: sudo apt-get install clang-tidy cppcheck -y -q | ||
|
||
- name: Install vcpkg | ||
uses: lukka/run-vcpkg@v7 | ||
with: | ||
setupOnly: true | ||
vcpkgGitCommitId: 7c55ecac266fc3e554bc315053dc45c11ec811af | ||
|
||
- name: Configure | ||
run: cmake --preset=ci-${{ matrix.os }} | ||
-D "VCPKG_MANIFEST_FEATURES=test${{ matrix.features }}" | ||
|
||
- name: Build | ||
run: cmake --build build --config Release -j 2 | ||
|
||
- name: Install | ||
run: cmake --install build --config Release --prefix prefix | ||
|
||
- name: Test | ||
run: ctest --test-dir build --output-on-failure -C Release -j 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
build/ | ||
prefix/ | ||
CMakeUserPresets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Building with CMake | ||
|
||
## vcpkg dependencies | ||
|
||
This project uses vcpkg to manage its dependencies, but this is optional. You | ||
may also install those dependencies manually or using any other package | ||
manager. | ||
|
||
If you have vcpkg set up, then you have to provide some extra flags to the | ||
configure command, which differs only in how you provide the paths depending on | ||
your OS: | ||
|
||
```batch | ||
rem Windows | ||
-D "CMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake" | ||
``` | ||
|
||
```sh | ||
# Unix based (Linux, macOS) | ||
-D "CMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" | ||
``` | ||
|
||
You may also set the `VCPKG_MANIFEST_FEATURES` variable to `magic-enum` if you | ||
would like to enable support for it. | ||
|
||
## Build | ||
|
||
Besides the ones for vcpkg dependencies (if you choose to provide them to the | ||
project using vcpkg), this project doesn't require any special command-line | ||
flags to build to keep things simple. | ||
|
||
Here are the steps for building in release mode with a single-configuration | ||
generator, like the Unix Makefiles one: | ||
|
||
```sh | ||
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release # vcpkg flags | ||
cmake --build build | ||
``` | ||
|
||
Here are the steps for building in release mode with a multi-configuration | ||
generator, like the Visual Studio ones: | ||
|
||
```sh | ||
cmake -S . -B build # vcpkg flags | ||
cmake --build build --config Release | ||
``` | ||
|
||
## Install | ||
|
||
This project doesn't require any special command-line flags to install to keep | ||
things simple. As a prerequisite, the project has to be built with the above | ||
commands already. | ||
|
||
The below commands require at least CMake 3.15 to run, because that is the | ||
version in which [Install a Project][1] was added. | ||
|
||
Here is the command for installing the release mode artifacts with a | ||
single-configuration generator, like the Unix Makefiles one: | ||
|
||
```sh | ||
cmake --install build | ||
``` | ||
|
||
Here is the command for installing the release mode artifacts with a | ||
multi-configuration generator, like the Visual Studio ones: | ||
|
||
```sh | ||
cmake --install build --config Release | ||
``` | ||
|
||
[1]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
include(cmake/in-source-guard.cmake) | ||
|
||
project( | ||
enum_set | ||
VERSION 0.1.0 | ||
DESCRIPTION "A library of type safe sets over fixed size collections of types or values, including methods for accessing, modifying, visiting and iterating over those." | ||
HOMEPAGE_URL "https://github.com/cdeln/cpp_enum_set" | ||
LANGUAGES CXX | ||
) | ||
|
||
include(cmake/project-is-top-level.cmake) | ||
include(cmake/variables.cmake) | ||
|
||
# ---- Declare library ---- | ||
|
||
add_library(enum_set_enum_set INTERFACE) | ||
add_library(enum_set::enum_set ALIAS enum_set_enum_set) | ||
|
||
set_property( | ||
TARGET enum_set_enum_set PROPERTY | ||
EXPORT_NAME enum_set | ||
) | ||
|
||
target_include_directories( | ||
enum_set_enum_set | ||
${enum_set_warning_guard} | ||
INTERFACE | ||
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>" | ||
) | ||
|
||
# The following properties are only applied during build time | ||
# For details, check the config file | ||
set(std cxx_std_14) | ||
if(enum_set_USE_MAGIC_ENUM) | ||
set(std cxx_std_17) | ||
find_package(magic_enum REQUIRED) | ||
target_link_libraries( | ||
enum_set_enum_set | ||
INTERFACE | ||
"$<BUILD_INTERFACE:magic_enum::magic_enum>" | ||
) | ||
endif() | ||
|
||
target_compile_features( | ||
enum_set_enum_set | ||
INTERFACE | ||
"$<BUILD_INTERFACE:${std}>" | ||
) | ||
|
||
# ---- Install rules ---- | ||
|
||
include(cmake/install-rules.cmake) | ||
|
||
# ---- Examples ---- | ||
|
||
if(PROJECT_IS_TOP_LEVEL) | ||
option(BUILD_EXAMPLES "Build examples tree." "${enum_set_DEVELOPER_MODE}") | ||
if(BUILD_EXAMPLES) | ||
add_subdirectory(example) | ||
endif() | ||
endif() | ||
|
||
# ---- Developer mode ---- | ||
|
||
if(NOT enum_set_DEVELOPER_MODE) | ||
return() | ||
elseif(NOT PROJECT_IS_TOP_LEVEL) | ||
message( | ||
AUTHOR_WARNING | ||
"Developer mode is intended for developers of enum_set" | ||
) | ||
endif() | ||
|
||
include(CTest) | ||
if(BUILD_TESTING) | ||
add_subdirectory(test) | ||
endif() | ||
|
||
option(BUILD_DOCUMENTATION "Build documentation using Doxygen and m.css" OFF) | ||
if(BUILD_DOCUMENTATION) | ||
include(cmake/docs.cmake) | ||
endif() |
Oops, something went wrong.