Commit 2d5e29c6 authored by Evili del Rio i Silvan's avatar Evili del Rio i Silvan
Browse files

Initial creation

parents
Pipeline #445 failed with stages
in 43 seconds
Build
doc
doc/*
*~
*.o
*.bakcoverage.xml
cpplint.xml
valgrind.xml
coverage.xml
image: docker.io/evili/labrobotica
cmake-build:
stage: build
script:
- mkdir -pv Build
- cd Build
- cmake -D CMAKE_BUILD_TYPE=Debug ..
- make
artifacts:
paths:
- Build/
unit-test:
stage: test
script:
- cd Build
- ctest --timeout 15 --verbose -T test
- ctest --timeout 15 --verbose -T memcheck
artifacts:
paths:
- Build/
coverage:
stage: deploy
script:
- cd Build
- ctest --timeout 15 --verbose -T coverage
doc:
stage: deploy
script:
- cd doc
- pdflatex *.tex
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Added
- Initial import.
cmake_minimum_required(VERSION 2.8.8)
set(PROJECT_NAME_STR ExampleProject)
project(${PROJECT_NAME_STR} C CXX)
set (${PROJECT_NAME_STR}_VERSION_MAJOR 1)
set (${PROJECT_NAME_STR}_VERSION_MINOR 0)
#
# We need Threads for gtest
#
find_package(Threads REQUIRED)
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-Wall -ansi -Wno-deprecated -pthread)
endif()
set(EXT_PROJECTS_DIR ${PROJECT_SOURCE_DIR}/ext)
#
# Add ctest
#
include (CTest)
#
# Coverage options
#
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D_REENTRANT")
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -D_REENTRAND -O0 --coverage -fprofile-arcs")
set(CMAKE_LINK_FLAGS_DEBUG "--coverage -fprofile-arcs")
#-------------------
# Module source
#-------------------
add_subdirectory(${EXT_PROJECTS_DIR}/gtest)
add_subdirectory(src)
add_subdirectory(tests)
# Contributing
By contributing you agree to the [LICENSE](LICENSE) of this repository.
By contributing you agree to respect the [Code of Conduct](http://todogroup.org/opencodeofconduct/) of this repository.
## Issue Tracker
- before submitting a new issue, please:
- check for existing related issues
- check the issue tracker for a specific upstream project that may be more appropriate
- check against supported versions of this project (i.e. the latest)
- please comment with a "+1" to help vote for issues that are important to you
- please DO NOT comment with a "+1", use the Subscribe button instead
- please keep discussions on-topic, and respect the opinions of others
- please report urgent issues, or issues with confidential details, via our commercial support channels
### Security Vulnerabilities
- please contact us privately to discuss security vulnerabilities as part of our [responsible disclosure](https://en.wikipedia.org/wiki/Responsible_disclosure) approach
### Bug Reports
- please report bugs in the issue tracker
- ideally provide a [reduced test case](https://css-tricks.com/reduced-test-cases/) and a live example on http://codepen.io/ , http://jsbin.com/ , https://jsfiddle.net/ , or similar
- please provide detailed steps to reproduce
### Feature Requests
- please suggest new features and improvements in the issue tracker
- suggestions for new features and improvements belong in Get Satisfaction
### Personal Support Requests
- requests for help are welcome in the issue tracker
- requests for help belong on Stack Overflow, Gitter, Slack or IRC
- please submit requests for help via our commercial support channels
- requests for help in the issue tracker receive lower priority than commercial support requests
## Pull Requests / Merge Requests
- please explicitly sign our Contributor License Agreement before submitting code for review and inclusion
- by submitting code for review and inclusion, we assume you have read and agree to our Contributor License Agreement
- **IMPORTANT**: by submitting a patch, you agree to allow the project owners to license your work under our this [LICENSE](LICENSE)
- please do not submit code for review and inclusion here
- provide tests for all features or bug fixes
- provide documentation for all public API methods
- Pull / Merge Request descriptions should include a change summary that matches the [Keep a CHANGELOG](http://keepachangelog.com/) format
- this project uses the [Git Flow](http://nvie.com/posts/a-successful-git-branching-model/) branching scheme, so changes should target the "develop" branch
- this project uses the [GitHub Flow](https://guides.github.com/introduction/flow/) branching scheme, so changes should target the "master" branch
- this project uses the [GitLab Flow](https://about.gitlab.com/2014/09/29/gitlab-flow/) branching scheme, so changes should target the "master" branch
- this project uses Atlassian's [Simple Git](http://blogs.atlassian.com/2014/01/simple-git-workflow-simple/) branching scheme, so changes should target the "master" branch
- please squash your commits if there is more than one
- feel free to submit un-squashed commits provided tests pass for all commits
- feel free to submit un-squashed commits
## Code Style and Code Quality
- adhere to our code style guides
- C++
- http://wiki.ros.org/CppStyleGuide
## Version Control
- this project adheres to [Semantic Versioning](http://semver.org/)
- ideally, highlight when work would change the API surface in ways that break compatibility with existing consumers
- compose meaningful version control comments: http://alistapart.com/article/the-art-of-the-commit
## Development
### Prerequisites
__coming soon__
### Getting Started
__coming soon__
GNU Lesser General Public License
=================================
_Version 3, 29 June 2007_
_Copyright © 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;_
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
### 0. Additional Definitions
As used herein, “this License” refers to version 3 of the GNU Lesser
General Public License, and the “GNU GPL” refers to version 3 of the GNU
General Public License.
“The Library” refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An “Application” is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A “Combined Work” is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the “Linked
Version”.
The “Minimal Corresponding Source” for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The “Corresponding Application Code” for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
### 1. Exception to Section 3 of the GNU GPL
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
### 2. Conveying Modified Versions
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
* **a)** under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
* **b)** under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
### 3. Object Code Incorporating Material from Library Header Files
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
* **a)** Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
* **b)** Accompany the object code with a copy of the GNU GPL and this license
document.
### 4. Combined Works
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
* **a)** Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license
document.
* **c)** For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
* **d)** Do one of the following:
- **0)** Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
- **1)** Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that **(a)** uses at run time
a copy of the Library already present on the user's computer
system, and **(b)** will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
* **e)** Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option **4d0**, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option **4d1**, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
### 5. Combined Libraries
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
* **a)** Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
* **b)** Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
### 6. Revised Versions of the GNU Lesser General Public License
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License “or any later version”
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
[![build status](https://gitlab.iri.upc.edu/erio/cmake_gtest/badges/master/build.svg)](https://gitlab.iri.upc.edu/erio/cmake_gtest/commits/master)
# cmake_gtest
This is a toy CMake project to start using GitLab and CI
with GoogleTest, valgrind, and coverage ready to use.
Just copy (or clone) the contents of this repo and then:
* Edit CMakeLists.txt and src/CMakeLists.txt to your taste.
* Edit/replace src/main.cpp.
* Remove dummy source files like src/SomeHeader.h, tests/silly_test.cpp, etc.
cmake_minimum_required(VERSION 2.8.8)
project(gtest_builder C CXX)
include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
-DCMAKE_CXX_FLAGS=${MSVC_COMPILER_DEFS}
-Dgtest_force_shared_crt=ON
-DBUILD_GTEST=ON
PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
# Disable install step
INSTALL_COMMAND ""
)
# Specify include dir
ExternalProject_Get_Property(googletest source_dir)
set(GTEST_INCLUDE_DIRS ${source_dir}/googletest/include PARENT_SCOPE)
# Specify MainTest's link libraries
ExternalProject_Get_Property(googletest binary_dir)
set(GTEST_LIBS_DIR ${binary_dir}/googlemock/gtest PARENT_SCOPE)
set(sources SomeClassDefinition.cpp)
set(headers SomeHeaderFile.h)
ADD_LIBRARY(${PROJECT_NAME_STR} SHARED ${sources} ${headers})
add_executable(${PROJECT_NAME_STR}_Main main.cpp)
target_link_libraries (${PROJECT_NAME_STR}_Main LINK_PUBLIC ${PROJECT_NAME_STR})
install (TARGETS ${PROJECT_NAME_STR}_Main ${PROJECT_NAME_STR}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib)
int main(int argc, char **argv){}
include_directories(
${GTEST_INCLUDE_DIRS}
${GMOCK_INCLUDE_DIRS}
)
# Include main source dir
include_directories (${${PROJECT_NAME_STR}_SOURCE_DIR}/src ${GTEST_INCLUDE_DIRS} )
# Exclude tests from coverage
set(CTEST_CUSTOM_COVERAGE_EXCLUDE *)
# Add main library
link_libraries(${PROJECT_NAME_STR})
file(GLOB SRCS *.cpp)
# Add test executables
add_executable(unit_test ${SRCS})
add_dependencies(unit_test googletest)
target_link_libraries(unit_test
${GTEST_LIBS_DIR}/libgtest.a ${GTEST_LIBS_DIR}/libgtest_main.a
${CMAKE_THREAD_LIBS_INIT})
# Add tests...
add_test(NAME Unit_Test COMMAND unit_test)
#include "gtest/gtest.h"
// Just a dummy test that it will fail!
TEST(silly_test, silly_test) {
int a = 0;
int b = 1;
EXPECT_EQ(a, b) << "a ("<<a<<") should be equal to b ("<<b<<")";
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment