Skip to content

Commit

Permalink
Initialized repo from GitLab edition
Browse files Browse the repository at this point in the history
Signed-off-by: Colin McAllister <[email protected]>
  • Loading branch information
colin-pm committed Dec 7, 2020
0 parents commit 1debace
Show file tree
Hide file tree
Showing 19 changed files with 2,855 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/cmake-build-debug/
/build/
/.idea/
/.vscode/
/docs/html
/docs/latex
51 changes: 51 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This file is a template, and might need editing before it works on your project.
# use the official gcc image, based on debian
# can use verions as well, like gcc:5.2
# see https://hub.docker.com/_/gcc/
image: conanio/gcc49

build:
stage: build
before_script:
# Upgrade Conan version
- sudo pip install --upgrade conan
# Install dependencies to generate documentation
- sudo apt-get -qq update
- sudo apt-get install -y --force-yes --no-install-recommends doxygen
- sudo pip install breathe
- sudo pip install sphinx
# Automatic detection of your arch, compiler, etc.
- conan user

script:
# Download dependencies, build, test and create package
- conan install . -if build -b missing
- conan build . -bf build

artifacts:
paths:
- build

# run tests using the binary built before
test:
stage: test
script:
- sudo pip install gcovr
- ./build/fibonacci/bin/fibonacci_test --gtest_output="xml:testing-report.xml"
- gcovr . build/ --xml-pretty -o coverage-report.xml
artifacts:
when: always
reports:
junit: testing-report.xml
cobertura: coverage-report.xml

# Deploy documentation to pages
pages:
stage: deploy
script:
- mv ./build/docs/sphinx public
artifacts:
paths:
- public
only:
- master
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.13)

project(fibonacci LANGUAGES CXX)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

add_subdirectory("fibonacci")
add_subdirectory("docs")
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2020 Colin McAllister

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.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Fibonacci
Test C++ library
11 changes: 11 additions & 0 deletions cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Look for an executable called sphinx-build
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
DOC "Path to sphinx-build executable")

include(FindPackageHandleStandardArgs)

#Handle standard arguments to find_package like REQUIRED and QUIET
find_package_handle_standard_args(Sphinx
"Failed to find sphinx-build executable"
SPHINX_EXECUTABLE)
70 changes: 70 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""
Conan file responsible for installing dependencies, building, testing, and packaging a project.
conanfile.py docs: https://docs.conan.io/en/latest/reference/conanfile.html
"""

from conans import ConanFile, CMake, tools


class FibonacciConanFile(ConanFile):
name = "fibonacci"
version = "0.0.1"
license = "MIT"
author = "Colin McAllister <[email protected]>"
url = "https://github.com/colin-pm/fibonacci"
description = "Test library for evaluating version control"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [False, True]}
default_options = "shared=False"
generators = "cmake"
exports_sources = "CMakeLists.txt", "include/*", "src/*", "test/*"

def build_requirements(self):
if not tools.cross_building(self.settings):
self.build_requires("gtest/1.8.1@bincrafters/stable")

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions['CONAN_SPECIFIED_VERSION'] = "{} version v{}".format(self.name, self.version)
if tools.cross_building(self.settings):
cmake.definitions["BUILD_TESTING"] = "NO"
if not tools.cross_building(self.settings):
cmake.definitions["CODE_COVERAGE"] = "YES"
cmake.definitions["CMAKE_BUILD_TYPE"] = "Debug"
cmake.configure()
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def test(self):
cmake = self._configure_cmake()
cmake.test(args=['--', 'gtest_output="xml:report.xml"'], output_on_failure=True)

def package(self):
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.libs = [self.name]

def package(self):
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.dll", dst="bin", keep_path=False)
self.copy("*.dylib*", dst="lib", keep_path=False)
self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)

def deploy(self):
self.copy("*", src="bin", dst="bin")
self.copy("*", src="sbin", dst="sbin")
self.copy("*", src="lib", dst="lib")
self.copy("*", src="include", dst="include")

def deploy(self):
self.copy("*", src="bin", dst="bin")
self.copy("*", src="sbin", dst="sbin")
self.copy("*", src="lib", dst="lib")
self.copy("*", src="include", dst="include")

53 changes: 53 additions & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)

# Find all the public headers
get_target_property(FIBONACCI_PUBLIC_HEADER_DIR fibonacci INTERFACE_INCLUDE_DIRECTORIES)
file(GLOB_RECURSE FIBONACCI_PUBLIC_HEADERS ${FIBONACCI_PUBLIC_HEADER_DIR}/*.h)

set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/fibonacci)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/docs/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/html/index.html)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

#Replace variables inside @@ with the current values
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)

file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR}) #Doxygen won't create this for us
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
DEPENDS ${FIBONACCI_PUBLIC_HEADERS}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating docs")

add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})

set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR})
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
set(SPHINX_INDEX_FILE ${SPHINX_BUILD}/index.html)

# Only regenerate Sphinx when:
# - Doxygen has rerun
# - Our doc files have been updated
# - The Sphinx config has been updated
add_custom_command(OUTPUT ${SPHINX_INDEX_FILE}
COMMAND
${SPHINX_EXECUTABLE} -b html
# Tell Breathe where to find the Doxygen output
-Dbreathe_projects.Fibonacci=${DOXYGEN_OUTPUT_DIR}/xml
${SPHINX_SOURCE} ${SPHINX_BUILD}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
# Other docs files you want to track should go here (or in some variable)
${CMAKE_CURRENT_SOURCE_DIR}/index.rst
${DOXYGEN_INDEX_FILE}
MAIN_DEPENDENCY ${SPHINX_SOURCE}/conf.py
COMMENT "Generating documentation with Sphinx")

# Nice named target so we can run the job easily
add_custom_target(Sphinx ALL DEPENDS ${SPHINX_INDEX_FILE})

include(GNUInstallDirs)
install(DIRECTORY ${SPHINX_BUILD}
DESTINATION ${CMAKE_INSTALL_DOCDIR})
Loading

0 comments on commit 1debace

Please sign in to comment.