Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
[ci/cmake] Setup CI
Browse files Browse the repository at this point in the history
  • Loading branch information
arntanguy committed Jun 19, 2020
1 parent 0fbbcea commit e00a0e9
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 32 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI of gram-savitzy-golay

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest]
build-type: [Debug, RelWithDebInfo]
compiler: [gcc, clang]
exclude:
# Only default compiler on macos-latest and windows-latest
- os: macos-latest
compiler: clang
- os: windows-latest
compiler: clang

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
uses: jrl-umi3218/github-actions/install-dependencies@master
with:
compiler: ${{ matrix.compiler }}
build-type: ${{ matrix.build-type }}
ubuntu: |
apt: libeigen3-dev doxygen doxygen-latex libboost-all-dev
macos: |
brew: eigen boost pkg-config doxygen
windows: |
github:
- path: eigenteam/eigen-git-mirror
ref: 3.3.7
- name: Build and test
uses: jrl-umi3218/github-actions/build-cmake-project@master
with:
compiler: ${{ matrix.compiler }}
build-type: ${{ matrix.build-type }}
- name: Upload documentation
# Only run on master branch and for one configuration
if: matrix.os == 'ubuntu-18.04' && matrix.build-type == 'RelWithDebInfo' && matrix.compiler == 'gcc' && github.ref == 'refs/heads/head'
uses: jrl-umi3218/github-actions/upload-documentation@master
with:
GH_USER: arntanguy
GH_PAGES_TOKEN: ${{ secrets.GH_PAGES_TOKEN }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cmake"]
path = cmake
url = https://github.com/jrl-umi3218/jrl-cmakemodules
21 changes: 10 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,28 @@ cmake_minimum_required(VERSION 3.1)

set(PROJECT_NAME gram_savitzky_golay)
set(PROJECT_DESCRIPTION "Implementation of Savitzky-Golay Filtering using Peter A. Gory Gram Polynomials method")
set(PROJECT_URL "")
set(PROJECT_URL "https://github.com/arntanguy/gram_savitzky_golay")
set(PROJECT_VERSION 1.0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(CMAKE_CXX_STANDARD 11)

option(BUILD_TESTS "Build unit tests" ON)

include(cmake/base.cmake)
include(cmake/boost.cmake)
include(cmake/eigen.cmake)

project(${PROJECT_NAME} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)

enable_testing()

find_package(Eigen3 REQUIRED)
find_package(Boost 1.54 COMPONENTS unit_test_framework REQUIRED)

include_directories(include)
add_project_dependency(Eigen3 REQUIRED)
add_subdirectory(src)

if(BUILD_TESTS)
find_package(Boost 1.54 COMPONENTS unit_test_framework REQUIRED)
enable_testing()
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
add_subdirectory(tests)
endif()

install(
FILES "${CMAKE_SOURCE_DIR}/cmake/gram_savitzky_golayConfig.cmake"
DESTINATION lib/cmake/gram_savitzky_golay
)
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ How to include in your projects?
This package uses a modern cmake approach and exports its targets. To include in your own project, simply use:

```cmake
cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 11)
project(Example LANGUAGES CXX)
# Find the state-observation package and all its dependencies (Eigen)
find_package(gram_savitzky_golay REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test gram_savitzky_golay)
# Creates a new executable and link it with the `gram_savitzky_golay` target
add_executable(Example example.cpp)
target_link_libraries(Example PUBLIC gram_savitzky_golay::gram_savitzky_golay)
```

Example
Expand All @@ -36,19 +44,17 @@ const size_t n = 2;
// Initial Point Smoothing (ie evaluate polynomial at first point in the window)
// Points are defined in range [-m;m]
const size_t t = m;
// Derivate? 0: no derivation, 1: first derivative...
// Derivation order? 0: no derivation, 1: first derivative, 2: second derivative...
const int d = 0;



// Real-time filter (filtering at latest data point)
gram_sg::SavitzkyGolayFilter filter(m, t, n, d);
// Filter some data
std::vector<double> data = {.1, .7, .9, .7, .8, .5, -.3};
double result = filter.filter(data);



// Real-time derivative filter (filtering at latest data point)
// Use first order derivative
// NOTE that the derivation timestep is assumed to be 1. If this is not the case,
Expand Down
1 change: 1 addition & 0 deletions cmake
Submodule cmake added at 272d64
2 changes: 0 additions & 2 deletions cmake/gram_savitzky_golayConfig.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion include/gram_savitzky_golay/gram_savitzky_golay.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct SavitzkyGolayFilter
assert(v.size() == weights_.size() && v.size() > 0);
using T = typename ContainerT::value_type;
T res = weights_[0] * v[0];
for(int i = 1; i < v.size(); ++i)
for(size_t i = 1; i < v.size(); ++i)
{
res += weights_[i] * v[i];
}
Expand Down
26 changes: 13 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@
# You should have received a copy of the GNU Lesser General Public License
# along with robcalib. If not, see <http://www.gnu.org/licenses/>.

add_library(gram_savitzky_golay SHARED
gram_savitzky_golay.cpp
spatial_filters.cpp

set(SRC
gram_savitzky_golay.cpp
spatial_filters.cpp
)

set(HEADERS
../include/gram_savitzky_golay/gram_savitzky_golay.h
../include/gram_savitzky_golay/spatial_filters.h
)

add_library(gram_savitzky_golay SHARED ${SRC} ${HEADERS})
target_include_directories(gram_savitzky_golay PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
if(TARGET Eigen3::Eigen)
target_link_libraries(gram_savitzky_golay PUBLIC Eigen3::Eigen)
else()
target_include_directories(gram_savitzky_golay
PUBLIC
${EIGEN3_INCLUDE_DIRS})
target_include_directories(gram_savitzky_golay PUBLIC ${EIGEN3_INCLUDE_DIRS})
endif()
set_target_properties(gram_savitzky_golay PROPERTIES SOVERSION ${PROJECT_VERSION})

install(TARGETS gram_savitzky_golay
EXPORT gram_savitzky_golayTargets
EXPORT "${TARGETS_EXPORT_NAME}"
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

install(EXPORT gram_savitzky_golayTargets
FILE gram_savitzky_golayTargets.cmake
NAMESPACE gram_savitzky_golay::
DESTINATION lib/cmake/gram_savitzky_golay
)

install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include)

0 comments on commit e00a0e9

Please sign in to comment.