Skip to content

Commit

Permalink
Merge pull request #41 from temken/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
temken authored Jan 5, 2023
2 parents bc3db0b + 4890911 commit 3b37c1b
Show file tree
Hide file tree
Showing 102 changed files with 6,928 additions and 1,440 deletions.
34 changes: 20 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build Status

on:
push:
branches: [ master , dev]
branches: [ main , dev]
pull_request:
branches: [ master , dev]
branches: [ main , dev]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -23,14 +23,6 @@ jobs:
# LCOV
- name: Install lcov
run: sudo apt-get install lcov

# LIBCONFIG
- name: Download libconfig
run: wget https://hyperrealm.github.io/libconfig/dist/libconfig-1.7.2.tar.gz
- name: Unpack libconfig
run: tar -xvzf libconfig-1.7.2.tar.gz
- name: Install libconfig
run: pushd libconfig-1.7.2 && ./configure && make && sudo make install && popd

# BOOST
- name: Install boost
Expand All @@ -42,11 +34,12 @@ jobs:
shell: bash
run: sudo pip install codecov

# BUILD
# BUILD & INSTALL
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
Expand All @@ -56,19 +49,32 @@ jobs:
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCODE_COVERAGE=ON $GITHUB_WORKSPACE

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE

# TEST
- name: Test
- name: Install
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --install .

# TESTS
- name: Test installed executable
working-directory: ${{runner.workspace}}/obscura/bin
shell: bash
# Execute the obscura executable from the /bin/ directory.
run: ./obscura config.cfg

- name: Tests
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -V
run: ctest -V

# CODE COVERAGE
- name: Code coverage - Capture coverage info
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
*
!*/
!*.*

.depend
coverage.info

build/
external/
lib/
results/
tests/*.txt

# Ignore build files
*.o

*DS_Store
*.code-workspace
.vscode/*

# Ignore codecove files
*.gcov
*.gcda
Expand Down
80 changes: 49 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,52 +1,65 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.11)

project(obscura VERSION "1.0.2")

# Use C++-11
set(CMAKE_CXX_STANDARD 11)

# Require (at least) it
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Don't use e.g. GNU extension (like -std=gnu++11) for portability
set(CMAKE_CXX_EXTENSIONS OFF)

# Build library as shared or static (default is static)
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)

set(BIN_DIR ${PROJECT_SOURCE_DIR}/bin)
set(BIN_DIR ${PROJECT_SOURCE_DIR}/bin)
set(GENERATED_DIR ${PROJECT_BINARY_DIR}/generated)
set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(LIB_DIR ${PROJECT_SOURCE_DIR}/lib)
set(SRC_DIR ${PROJECT_SOURCE_DIR}/src)
set(TESTS_DIR ${PROJECT_SOURCE_DIR}/tests)
set(EXTERNAL_DIR ${PROJECT_SOURCE_DIR}/external)

#External projects
find_package(Boost 1.65 REQUIRED )
set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(LIB_DIR ${PROJECT_SOURCE_DIR}/lib)
set(SRC_DIR ${PROJECT_SOURCE_DIR}/src)
set(TESTS_DIR ${PROJECT_SOURCE_DIR}/tests)
set(EXTERNAL_DIR ${PROJECT_SOURCE_DIR}/external)

# External projects
find_package(Boost 1.65 REQUIRED)
include(FetchContent)

# libphysica
set(LIBPHYSICA_DIR ${EXTERNAL_DIR}/libphysica)
set(LIBPHYSICA_DIR ${EXTERNAL_DIR}/libphysica)
FetchContent_Declare(libphysica
GIT_REPOSITORY https://github.com/temken/libphysica.git
GIT_TAG v0.1.4
SOURCE_DIR "${LIBPHYSICA_DIR}"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release -DCODE_COVERAGE=OFF" )
GIT_REPOSITORY https://github.com/temken/libphysica.git
GIT_TAG origin/dev
SOURCE_DIR "${LIBPHYSICA_DIR}"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release -DCODE_COVERAGE=OFF")
FetchContent_GetProperties(libphysica)

if(NOT libphysica_POPULATED)
FetchContent_Populate(libphysica)
add_subdirectory( ${libphysica_SOURCE_DIR} )
FetchContent_Populate(libphysica)
add_subdirectory(${libphysica_SOURCE_DIR})
endif()

# When installing, CMake will clear the RPATH of these targets so they are installed with an empty RPATH.
# This setting avoids the clearing of the libconfig path.
set(LIBCONFIG_DIR ${EXTERNAL_DIR}/libphysica/external/libconfig)

if(IS_DIRECTORY "${LIBCONFIG_DIR}")
message(STATUS "Libconfig was downloaded by libphysica. Setting RPATH manually for libconfig.")
list(APPEND CMAKE_INSTALL_RPATH "${LIBCONFIG_DIR}/lib")
endif()

# Googletest
set(GTEST_DIR ${EXTERNAL_DIR}/googletest)
set(GTEST_DIR ${EXTERNAL_DIR}/googletest)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
SOURCE_DIR "${GTEST_DIR}/src"
BINARY_DIR "${GTEST_DIR}/build"
GIT_TAG release-1.10.0
SOURCE_DIR "${GTEST_DIR}/src"
BINARY_DIR "${GTEST_DIR}/build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND "")
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND "")

# Version header
execute_process( # Git commit hash
Expand Down Expand Up @@ -81,41 +94,46 @@ configure_file(
)

# Source and include directories
include_directories( ${INCLUDE_DIR} )
add_subdirectory( ${SRC_DIR} )
include_directories(${INCLUDE_DIR})
add_subdirectory(${SRC_DIR})

# Code Coverage Configuration
if(NOT TARGET coverage_config)
add_library(coverage_config INTERFACE)
endif()

option(CODE_COVERAGE "Enable coverage reporting" OFF)

if(CODE_COVERAGE)
# Add required flags (GCC & LLVM/Clang)
target_compile_options(coverage_config INTERFACE
-O0 # no optimization
-g # generate debug info
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(coverage_config INTERFACE --coverage)
else()
target_link_libraries(coverage_config INTERFACE --coverage)
endif()
endif(CODE_COVERAGE)

option (BUILD_TESTING "Build the testing tree." ON)
option(BUILD_TESTING "Build the testing tree." ON)

# Only build tests if we are the top-level project
# Allows this to be used by super projects with `add_subdirectory`
if (BUILD_TESTING AND (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
if(BUILD_TESTING AND(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
enable_testing()
FetchContent_GetProperties(googletest)

if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(
${googletest_SOURCE_DIR}
${googletest_SOURCE_DIR}
${googletest_BINARY_DIR}
EXCLUDE_FROM_ALL)
endif()

add_subdirectory(${TESTS_DIR})
endif()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://github.com/temken/obscura/workflows/Build%20Status/badge.svg)](https://github.com/temken/obscura/actions)
[![codecov](https://codecov.io/gh/temken/obscura/branch/master/graph/badge.svg)](https://codecov.io/gh/temken/obscura)
[![codecov](https://codecov.io/gh/temken/obscura/branch/main/graph/badge.svg)](https://codecov.io/gh/temken/obscura)
[![Documentation Status](https://readthedocs.org/projects/obscura/badge/?version=latest)](https://obscura.readthedocs.io/en/latest/?badge=latest)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

Expand Down
Loading

0 comments on commit 3b37c1b

Please sign in to comment.