mirror of
https://github.com/BlackMATov/enum.hpp.git
synced 2025-12-13 06:59:45 +07:00
initial commit
This commit is contained in:
11
.appveyor.yml
Normal file
11
.appveyor.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
version: "{build}"
|
||||
shallow_clone: true
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
- Visual Studio 2019
|
||||
platform:
|
||||
- Win32
|
||||
- x64
|
||||
build_script:
|
||||
- scripts\build_all.bat
|
||||
test: off
|
||||
4
.clang_complete
Normal file
4
.clang_complete
Normal file
@@ -0,0 +1,4 @@
|
||||
-Iheaders
|
||||
|
||||
-std=c++17
|
||||
-stdlib=libc++
|
||||
4
.codecov.yml
Normal file
4
.codecov.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
ignore:
|
||||
- "catch.hpp"
|
||||
- "catch_main.hpp"
|
||||
- "*_tests.cpp"
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
build/*
|
||||
.vscode/*
|
||||
CMakeLists.txt.user
|
||||
38
.travis.yml
Normal file
38
.travis.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
language: cpp
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-7"] } }
|
||||
env: MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-8"] } }
|
||||
env: MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-7"], packages: ["xorg-dev", "clang-7", "g++-7"] } }
|
||||
env: MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-8"], packages: ["xorg-dev", "clang-8", "g++-7"] } }
|
||||
env: MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
compiler: clang
|
||||
addons: { homebrew: { packages: ["lcov"] } }
|
||||
after_success: ./scripts/upload_coverage.sh
|
||||
before_install:
|
||||
- eval "${MATRIX_EVAL}"
|
||||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then
|
||||
brew update;
|
||||
brew upgrade cmake;
|
||||
fi
|
||||
- if [ "$TRAVIS_OS_NAME" == 'linux' ]; then
|
||||
mkdir $HOME/cmake;
|
||||
export PATH="$HOME/cmake/bin:$PATH";
|
||||
travis_retry wget -q https://cmake.org/files/v3.11/cmake-3.11.4-Linux-x86_64.sh;
|
||||
sh cmake-3.11.4-Linux-x86_64.sh --prefix=$HOME/cmake --exclude-subdir --skip-license;
|
||||
fi
|
||||
script:
|
||||
- ./scripts/build_all.sh
|
||||
20
CMakeLists.txt
Normal file
20
CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
# 3.8 version is required for `cxx_std_17`
|
||||
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
||||
|
||||
if(NOT DEFINED PROJECT_NAME)
|
||||
set(BUILD_AS_STANDALONE ON)
|
||||
endif()
|
||||
|
||||
project(enum.hpp)
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||
|
||||
if(BUILD_AS_STANDALONE)
|
||||
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
|
||||
if(BUILD_WITH_UNTESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(untests)
|
||||
endif()
|
||||
endif()
|
||||
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
41
README.md
Normal file
41
README.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# enum.hpp
|
||||
|
||||
[![travis][badge.travis]][travis]
|
||||
[![appveyor][badge.appveyor]][appveyor]
|
||||
[![codecov][badge.codecov]][codecov]
|
||||
[![language][badge.language]][language]
|
||||
[![license][badge.license]][license]
|
||||
[![paypal][badge.paypal]][paypal]
|
||||
|
||||
[badge.travis]: https://img.shields.io/travis/BlackMATov/enum.hpp/master.svg?logo=travis
|
||||
[badge.appveyor]: https://img.shields.io/appveyor/ci/BlackMATov/enum-hpp/master.svg?logo=appveyor
|
||||
[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/enum.hpp/master.svg?logo=codecov
|
||||
[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow.svg
|
||||
[badge.license]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||
[badge.paypal]: https://img.shields.io/badge/donate-PayPal-orange.svg?logo=paypal&colorA=00457C
|
||||
|
||||
[travis]: https://travis-ci.org/BlackMATov/enum.hpp
|
||||
[appveyor]: https://ci.appveyor.com/project/BlackMATov/enum-hpp
|
||||
[codecov]: https://codecov.io/gh/BlackMATov/enum.hpp
|
||||
[language]: https://en.wikipedia.org/wiki/C%2B%2B17
|
||||
[license]: https://en.wikipedia.org/wiki/MIT_License
|
||||
[paypal]: https://www.paypal.me/matov
|
||||
|
||||
[enum]: https://github.com/BlackMATov/enum.hpp
|
||||
|
||||
## Installation
|
||||
|
||||
[enum.hpp][enum] is a header-only library. All you need to do is copy the headers files from `headers` directory into your project and include them:
|
||||
|
||||
```cpp
|
||||
#include "enum.hpp/enum.hpp"
|
||||
```
|
||||
|
||||
Also, you can add the root repository directory to your [cmake](https://cmake.org) project:
|
||||
|
||||
```cmake
|
||||
add_subdirectory(external/enum.hpp)
|
||||
target_link_libraries(your_project_target enum.hpp)
|
||||
```
|
||||
|
||||
## [License (MIT)](./LICENSE.md)
|
||||
11
headers/enum.hpp/enum.hpp
Normal file
11
headers/enum.hpp/enum.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/enum.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace enum_hpp
|
||||
{
|
||||
}
|
||||
10
scripts/build_all.bat
Normal file
10
scripts/build_all.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
@echo off
|
||||
set SCRIPT_DIR=%~dp0%
|
||||
call %SCRIPT_DIR%\build_debug.bat || goto :error
|
||||
call %SCRIPT_DIR%\build_release.bat || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
5
scripts/build_all.sh
Executable file
5
scripts/build_all.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
|
||||
$SCRIPT_DIR/build_debug.sh
|
||||
$SCRIPT_DIR/build_release.sh
|
||||
14
scripts/build_debug.bat
Normal file
14
scripts/build_debug.bat
Normal file
@@ -0,0 +1,14 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\debug || goto :error
|
||||
cd %BUILD_DIR%\debug || goto :error
|
||||
cmake ../.. || goto :error
|
||||
cmake --build . --config Debug || goto :error
|
||||
ctest --verbose || goto :error
|
||||
cd ..\.. || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
9
scripts/build_debug.sh
Executable file
9
scripts/build_debug.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/debug
|
||||
cd $BUILD_DIR/debug
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ../..
|
||||
cmake --build . -- -j8
|
||||
ctest --verbose
|
||||
cd ../..
|
||||
14
scripts/build_release.bat
Normal file
14
scripts/build_release.bat
Normal file
@@ -0,0 +1,14 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\release || goto :error
|
||||
cd %BUILD_DIR%\release || goto :error
|
||||
cmake ../.. || goto :error
|
||||
cmake --build . --config Release || goto :error
|
||||
ctest --verbose || goto :error
|
||||
cd ..\.. || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
9
scripts/build_release.sh
Executable file
9
scripts/build_release.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/release
|
||||
cd $BUILD_DIR/release
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ../..
|
||||
cmake --build . -- -j8
|
||||
ctest --verbose
|
||||
cd ../..
|
||||
12
scripts/gen_msvc2017_project.bat
Normal file
12
scripts/gen_msvc2017_project.bat
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\msvc2017 || goto :error
|
||||
cd %BUILD_DIR%\msvc2017 || goto :error
|
||||
cmake -G "Visual Studio 15 2017" ..\.. || goto :error
|
||||
start enum.hpp.sln || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
12
scripts/gen_msvc2019_project.bat
Normal file
12
scripts/gen_msvc2019_project.bat
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
set BUILD_DIR=%~dp0%\..\build
|
||||
mkdir %BUILD_DIR%\msvc2019 || goto :error
|
||||
cd %BUILD_DIR%\msvc2019 || goto :error
|
||||
cmake -G "Visual Studio 16 2019" ..\.. || goto :error
|
||||
start enum.hpp.sln || goto :error
|
||||
|
||||
goto :EOF
|
||||
|
||||
:error
|
||||
echo Failed with error #%errorlevel%.
|
||||
exit /b %errorlevel%
|
||||
7
scripts/gen_xcode_project.sh
Executable file
7
scripts/gen_xcode_project.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/xcode
|
||||
cd $BUILD_DIR/xcode
|
||||
cmake -G Xcode ../..
|
||||
open enum.hpp.xcodeproj
|
||||
17
scripts/upload_coverage.sh
Executable file
17
scripts/upload_coverage.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/coverage
|
||||
cd $BUILD_DIR/coverage
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_COVERAGE=ON ../..
|
||||
cmake --build . -- -j8
|
||||
|
||||
lcov -d . -z
|
||||
ctest --verbose
|
||||
|
||||
lcov -d . -c -o "coverage.info"
|
||||
lcov -r "coverage.info" "*/usr/*" "*/catch.hpp" "*/catch_main.cpp" "*_tests.cpp" -o "coverage.info"
|
||||
lcov -l "coverage.info"
|
||||
|
||||
bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
|
||||
50
untests/CMakeLists.txt
Normal file
50
untests/CMakeLists.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
# 3.11 version is required for `FetchContent`
|
||||
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
|
||||
|
||||
project(enum.hpp.untests)
|
||||
|
||||
#
|
||||
# coverage
|
||||
#
|
||||
|
||||
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||
if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
|
||||
set(COVERAGE_FLAGS "--coverage")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
endif()
|
||||
|
||||
#
|
||||
# executable
|
||||
#
|
||||
|
||||
file(GLOB UNTESTS_SOURCES "*.cpp" "*.hpp")
|
||||
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} enum.hpp)
|
||||
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/W4>
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Wall -Wextra -Wpedantic>)
|
||||
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
|
||||
#
|
||||
# catchorg/catch2
|
||||
#
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
catchorg_catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/catch2)
|
||||
|
||||
FetchContent_GetProperties(catchorg_catch2)
|
||||
if(NOT catchorg_catch2_POPULATED)
|
||||
FetchContent_Populate(catchorg_catch2)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${catchorg_catch2_SOURCE_DIR}/single_include)
|
||||
endif()
|
||||
9
untests/catch_main.cpp
Normal file
9
untests/catch_main.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/enum.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019 Matvey Cherevko
|
||||
******************************************************************************/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#define CATCH_CONFIG_FAST_COMPILE
|
||||
#include <catch2/catch.hpp>
|
||||
13
untests/enum_tests.cpp
Normal file
13
untests/enum_tests.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/enum.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#define CATCH_CONFIG_FAST_COMPILE
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <enum.hpp/enum.hpp>
|
||||
|
||||
TEST_CASE("enum") {
|
||||
}
|
||||
Reference in New Issue
Block a user