Skip to content

Commit

Permalink
Modernise project and rename to Observe (#21)
Browse files Browse the repository at this point in the history
* modernize project and rename to Observe

* apply clang-format

* remove standalone test

* remove examples

* use g++-8
  • Loading branch information
TheLartians authored Apr 23, 2020
1 parent e219c74 commit 983b4e8
Show file tree
Hide file tree
Showing 27 changed files with 1,010 additions and 698 deletions.
16 changes: 16 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
BasedOnStyle: Google
AccessModifierOffset: '-2'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AlwaysBreakTemplateDeclarations: 'No'
BreakBeforeBraces: Attach
ColumnLimit: '100'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
IncludeBlocks: Regroup
IndentPPDirectives: AfterHash
IndentWidth: '2'
NamespaceIndentation: All
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: 'true'
...
31 changes: 31 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Install

on: [push]

env:
CTEST_OUTPUT_ON_FAILURE: 1

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: build and install library
run: |
CXX=g++-8 cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
sudo cmake --build build --target install
rm -rf build
- name: configure
run: CXX=g++-8 cmake -Htest -Bbuild -DTEST_INSTALLED_VERSION=1

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

- name: test
run: |
cd build
ctest --build-config Debug
25 changes: 25 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: MacOS

on: [push]

env:
CTEST_OUTPUT_ON_FAILURE: 1

jobs:
build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v1

- name: configure
run: cmake -Htest -Bbuild

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

- name: test
run: |
cd build
ctest --build-config Debug
20 changes: 20 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Style

on: [push]

jobs:
build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v1

- name: Install clang-format
run: brew install clang-format

- name: configure
run: cmake -Htest -Bbuild

- name: check style
run: cmake --build build --target check-format
38 changes: 38 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Ubuntu

on: [push]

env:
CTEST_OUTPUT_ON_FAILURE: 1
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: configure
run: CXX=g++-8 cmake -Htest -Bbuild -DENABLE_TEST_COVERAGE=1

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

- name: test
run: |
cd build
ctest --build-config Debug
- name: install code coverage tools
run: |
wget https://github.com/linux-test-project/lcov/releases/download/v1.14/lcov-1.14.tar.gz
tar xvfz lcov-1.14.tar.gz;
sudo make install -C lcov-1.14
- name: collect code coverage
run: |
lcov --gcov-tool $(which gcov-8) --directory . --capture --no-external --exclude "*tests*" --exclude "*_deps*" --quiet --output-file coverage.info
lcov --gcov-tool $(which gcov-8) --list coverage.info
bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports"
25 changes: 25 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Windows

on: [push]

env:
CTEST_OUTPUT_ON_FAILURE: 1

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v1

- name: configure
run: cmake -Htest -Bbuild

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

- name: test
run: |
cd build
ctest --build-config Debug
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build*
/.vscode
.DS_Store
69 changes: 0 additions & 69 deletions .travis.yml

This file was deleted.

110 changes: 37 additions & 73 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,99 +1,63 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

# ---- Project ----

project(LarsEvent
VERSION 2.1
# Note: update this to your new project's name and version
project(Observe
VERSION 3.0
LANGUAGES CXX
)

# ---- Configuration variables ----

option(LARS_EVENT_ENABLE_TESTS "Enable tests" OFF)
option(LARS_EVENT_BUILD_EXAMPLES "Enable examples" OFF)

# ---- Include guards ----

if(TARGET LarsEvent)
return()
endif()

if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.")
endif()

# ---- Header target ----
# --- Import tools ----

FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/include/lars/*.h")
add_library(LarsEvent-headers EXCLUDE_FROM_ALL ${headers})
SET_TARGET_PROPERTIES(LarsEvent-headers PROPERTIES LINKER_LANGUAGE CXX)
include(cmake/tools.cmake)

# ---- Create library ----
# ---- Add dependencies via CPM ----
# see https://github.com/TheLartians/CPM.cmake for more info

add_library(LarsEvent INTERFACE)
include(cmake/CPM.cmake)

target_include_directories(LarsEvent
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
# PackageProject.cmake will be used to make our target installable
CPMAddPackage(
NAME PackageProject.cmake
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
VERSION 1.2
)

include(CMakePackageConfigHelpers)
# ---- Add source files ----
FILE(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")

write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/LarsEventConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# ---- Create library ----

# ---- Install ----
add_library(ObserveHeaders EXCLUDE_FROM_ALL ${headers})
set_target_properties(ObserveHeaders PROPERTIES LINKER_LANGUAGE CXX)

install(
TARGETS LarsEvent
EXPORT LarsEventTargets
LIBRARY DESTINATION lib COMPONENT Runtime
ARCHIVE DESTINATION lib COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Runtime
PUBLIC_HEADER DESTINATION include COMPONENT Development
BUNDLE DESTINATION bin COMPONENT Runtime
)
add_library(Observe INTERFACE)
set_target_properties(Observe PROPERTIES INTERFACE_COMPILE_FEATURES cxx_std_17)

include(CMakePackageConfigHelpers)
# beeing a cross-platform target, we enforce enforce standards conformance on MSVC
target_compile_options(Observe INTERFACE "$<$<BOOL:${MSVC}>:/permissive->")

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/LarsEventConfig.cmake.in"
"${PROJECT_BINARY_DIR}/LarsEventConfig.cmake"
INSTALL_DESTINATION lib/cmake/LarsEvent
)

install(
EXPORT LarsEventTargets
DESTINATION lib/cmake/LarsEvent
target_include_directories(Observe
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)

install(
FILES
"${PROJECT_BINARY_DIR}/LarsEventConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/LarsEventConfig.cmake"
DESTINATION
lib/cmake/LarsEvent
)
# ---- Create an installable target ----
# this allows users to install and find the library via `find_package()`.

install(
DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION include
packageProject(
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
DEPENDENCIES ""
)

# ---- Examples ----

IF(${LARS_EVENT_BUILD_EXAMPLES})
add_subdirectory(examples)
ENDIF()

# ---- Test ----

if(${LARS_EVENT_ENABLE_TESTS})
ENABLE_TESTING()
add_subdirectory(tests)
endif()

Loading

0 comments on commit 983b4e8

Please sign in to comment.