├── .clang-format ├── .clang-tidy ├── .gitattributes ├── .gitignore ├── .gitlab-ci.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── ClangFormat.cmake ├── StaticAnalyzers.cmake └── TestCoverage.cmake ├── docker ├── Dockerfile └── install_llvm_toolchain.sh ├── include └── lib │ └── lib.h ├── scripts ├── clang_format.sh ├── clang_tidy.sh └── test_coverage.sh ├── src ├── CMakeLists.txt ├── apps │ ├── CMakeLists.txt │ └── example.cpp └── lib │ ├── CMakeLists.txt │ ├── example_lib.cpp │ └── example_lib.hpp └── tests ├── CMakeLists.txt └── test_lib.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: Google 4 | AccessModifierOffset: -1 5 | AlignAfterOpenBracket: Align 6 | AlignConsecutiveMacros: false 7 | AlignConsecutiveAssignments: false 8 | AlignConsecutiveDeclarations: false 9 | AlignEscapedNewlines: Left 10 | AlignOperands: true 11 | AlignTrailingComments: true 12 | AllowAllArgumentsOnNextLine: true 13 | AllowAllConstructorInitializersOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AllowShortBlocksOnASingleLine: Never 16 | AllowShortCaseLabelsOnASingleLine: false 17 | AllowShortFunctionsOnASingleLine: All 18 | AllowShortLambdasOnASingleLine: All 19 | AllowShortIfStatementsOnASingleLine: WithoutElse 20 | AllowShortLoopsOnASingleLine: true 21 | AlwaysBreakAfterDefinitionReturnType: None 22 | AlwaysBreakAfterReturnType: None 23 | AlwaysBreakBeforeMultilineStrings: true 24 | AlwaysBreakTemplateDeclarations: Yes 25 | BinPackArguments: true 26 | BinPackParameters: true 27 | BraceWrapping: 28 | AfterCaseLabel: false 29 | AfterClass: false 30 | AfterControlStatement: false 31 | AfterEnum: false 32 | AfterFunction: false 33 | AfterNamespace: false 34 | AfterObjCDeclaration: false 35 | AfterStruct: false 36 | AfterUnion: false 37 | AfterExternBlock: false 38 | BeforeCatch: false 39 | BeforeElse: false 40 | IndentBraces: false 41 | SplitEmptyFunction: true 42 | SplitEmptyRecord: true 43 | SplitEmptyNamespace: true 44 | BreakBeforeBinaryOperators: None 45 | BreakBeforeBraces: Attach 46 | BreakBeforeInheritanceComma: false 47 | BreakInheritanceList: BeforeColon 48 | BreakBeforeTernaryOperators: true 49 | BreakConstructorInitializersBeforeComma: false 50 | BreakConstructorInitializers: BeforeColon 51 | BreakAfterJavaFieldAnnotations: false 52 | BreakStringLiterals: true 53 | ColumnLimit: 80 54 | CommentPragmas: '^ IWYU pragma:' 55 | CompactNamespaces: false 56 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 57 | ConstructorInitializerIndentWidth: 4 58 | ContinuationIndentWidth: 4 59 | Cpp11BracedListStyle: true 60 | DeriveLineEnding: true 61 | DerivePointerAlignment: true 62 | DisableFormat: false 63 | ExperimentalAutoDetectBinPacking: false 64 | FixNamespaceComments: true 65 | ForEachMacros: 66 | - foreach 67 | - Q_FOREACH 68 | - BOOST_FOREACH 69 | IncludeBlocks: Regroup 70 | IncludeCategories: 71 | - Regex: '^<.*\.h>' 72 | Priority: 1 73 | - Regex: '^<.*\.hpp>' 74 | Priority: 3 75 | - Regex: '^<.*' 76 | Priority: 2 77 | - Regex: '.*' 78 | Priority: 4 79 | IncludeIsMainRegex: '([-_](test|unittest))?$' 80 | IncludeIsMainSourceRegex: '' 81 | IndentCaseLabels: true 82 | IndentGotoLabels: true 83 | IndentPPDirectives: None 84 | IndentWidth: 2 85 | IndentWrappedFunctionNames: false 86 | JavaScriptQuotes: Leave 87 | JavaScriptWrapImports: true 88 | KeepEmptyLinesAtTheStartOfBlocks: false 89 | MacroBlockBegin: '' 90 | MacroBlockEnd: '' 91 | MaxEmptyLinesToKeep: 1 92 | NamespaceIndentation: None 93 | ObjCBinPackProtocolList: Never 94 | ObjCBlockIndentWidth: 2 95 | ObjCSpaceAfterProperty: false 96 | ObjCSpaceBeforeProtocolList: true 97 | PenaltyBreakAssignment: 2 98 | PenaltyBreakBeforeFirstCallParameter: 1 99 | PenaltyBreakComment: 300 100 | PenaltyBreakFirstLessLess: 120 101 | PenaltyBreakString: 1000 102 | PenaltyBreakTemplateDeclaration: 10 103 | PenaltyExcessCharacter: 1000000 104 | PenaltyReturnTypeOnItsOwnLine: 200 105 | PointerAlignment: Left 106 | RawStringFormats: 107 | - Language: Cpp 108 | Delimiters: 109 | - cc 110 | - CC 111 | - cpp 112 | - Cpp 113 | - CPP 114 | - 'c++' 115 | - 'C++' 116 | CanonicalDelimiter: '' 117 | BasedOnStyle: google 118 | - Language: TextProto 119 | Delimiters: 120 | - pb 121 | - PB 122 | - proto 123 | - PROTO 124 | EnclosingFunctions: 125 | - EqualsProto 126 | - EquivToProto 127 | - PARSE_PARTIAL_TEXT_PROTO 128 | - PARSE_TEST_PROTO 129 | - PARSE_TEXT_PROTO 130 | - ParseTextOrDie 131 | - ParseTextProtoOrDie 132 | CanonicalDelimiter: '' 133 | BasedOnStyle: google 134 | ReflowComments: true 135 | SortIncludes: true 136 | SortUsingDeclarations: true 137 | SpaceAfterCStyleCast: false 138 | SpaceAfterLogicalNot: false 139 | SpaceAfterTemplateKeyword: true 140 | SpaceBeforeAssignmentOperators: true 141 | SpaceBeforeCpp11BracedList: false 142 | SpaceBeforeCtorInitializerColon: true 143 | SpaceBeforeInheritanceColon: true 144 | SpaceBeforeParens: ControlStatements 145 | SpaceBeforeRangeBasedForLoopColon: true 146 | SpaceInEmptyBlock: false 147 | SpaceInEmptyParentheses: false 148 | SpacesBeforeTrailingComments: 2 149 | SpacesInAngles: false 150 | SpacesInConditionalStatement: false 151 | SpacesInContainerLiterals: true 152 | SpacesInCStyleCastParentheses: false 153 | SpacesInParentheses: false 154 | SpacesInSquareBrackets: false 155 | SpaceBeforeSquareBrackets: false 156 | Standard: Auto 157 | StatementMacros: 158 | - Q_UNUSED 159 | - QT_REQUIRE_VERSION 160 | TabWidth: 8 161 | UseCRLF: false 162 | UseTab: Never 163 | ... 164 | 165 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: '*, 3 | -fuchsia-*, 4 | -google-*, 5 | -zircon-*, 6 | -abseil-*, 7 | -modernize-use-trailing-return-type, 8 | -llvm-*, 9 | -cppcoreguidelines-pro-type-vararg, 10 | -hicpp-vararg, 11 | -misc-non-private-member-variables-in-classes, 12 | -cppcoreguidelines-pro-bounds-pointer-arithmetic, 13 | -cppcoreguidelines-avoid-magic-numbers, 14 | -readability-magic-numbers, 15 | ' 16 | HeaderFilterRegex: '.*' 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | **/*.jpg filter=lfs diff=lfs merge=lfs -text 2 | **/*.png filter=lfs diff=lfs merge=lfs -text 3 | **/*.bin filter=lfs diff=lfs merge=lfs -text 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/c++,cmake,python,opencv,visualstudiocode 2 | # Edit at https://www.gitignore.io/?templates=c++,cmake,python,opencv,visualstudiocode 3 | **/*build/ 4 | **/*results/ 5 | **/*.profdata 6 | **/*.profraw 7 | **/*bin/ 8 | **/*.zip 9 | **/*.tar 10 | .vscode/ 11 | 12 | ### C++ ### 13 | # Prerequisites 14 | *.d 15 | 16 | # Compiled Object files 17 | *.slo 18 | *.lo 19 | *.o 20 | *.obj 21 | 22 | # Precompiled Headers 23 | *.gch 24 | *.pch 25 | 26 | # Compiled Dynamic libraries 27 | *.so 28 | *.dylib 29 | *.dll 30 | 31 | # Fortran module files 32 | *.mod 33 | *.smod 34 | 35 | # Compiled Static libraries 36 | *.lai 37 | *.la 38 | *.a 39 | *.lib 40 | 41 | # Executables 42 | *.exe 43 | *.out 44 | *.app 45 | 46 | ### CMake ### 47 | CMakeLists.txt.user 48 | CMakeCache.txt 49 | CMakeFiles 50 | CMakeScripts 51 | Testing 52 | Makefile 53 | cmake_install.cmake 54 | install_manifest.txt 55 | compile_commands.json 56 | CTestTestfile.cmake 57 | _deps 58 | 59 | ### CMake Patch ### 60 | # External projects 61 | *-prefix/ 62 | 63 | ### OpenCV ### 64 | #OpenCV for Mac and Linux 65 | #build and release folders 66 | */CMakeFiles 67 | */CMakeCache.txt 68 | */Makefile 69 | */cmake_install.cmake 70 | .DS_Store 71 | 72 | ### Python ### 73 | # Byte-compiled / optimized / DLL files 74 | __pycache__/ 75 | *.py[cod] 76 | *$py.class 77 | 78 | # C extensions 79 | 80 | # Distribution / packaging 81 | .Python 82 | build/ 83 | develop-eggs/ 84 | dist/ 85 | downloads/ 86 | eggs/ 87 | .eggs/ 88 | lib64/ 89 | parts/ 90 | sdist/ 91 | var/ 92 | wheels/ 93 | pip-wheel-metadata/ 94 | share/python-wheels/ 95 | *.egg-info/ 96 | .installed.cfg 97 | *.egg 98 | MANIFEST 99 | 100 | # PyInstaller 101 | # Usually these files are written by a python script from a template 102 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 103 | *.manifest 104 | *.spec 105 | 106 | # Installer logs 107 | pip-log.txt 108 | pip-delete-this-directory.txt 109 | 110 | # Unit test / coverage reports 111 | htmlcov/ 112 | .tox/ 113 | .nox/ 114 | .coverage 115 | .coverage.* 116 | .cache 117 | nosetests.xml 118 | coverage.xml 119 | *.cover 120 | .hypothesis/ 121 | .pytest_cache/ 122 | 123 | # Translations 124 | *.mo 125 | *.pot 126 | 127 | # Scrapy stuff: 128 | .scrapy 129 | 130 | # Sphinx documentation 131 | docs/_build/ 132 | 133 | # PyBuilder 134 | target/ 135 | 136 | # pyenv 137 | .python-version 138 | 139 | # pipenv 140 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 141 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 142 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 143 | # install all needed dependencies. 144 | #Pipfile.lock 145 | 146 | # celery beat schedule file 147 | celerybeat-schedule 148 | 149 | # SageMath parsed files 150 | *.sage.py 151 | 152 | # Spyder project settings 153 | .spyderproject 154 | .spyproject 155 | 156 | # Rope project settings 157 | .ropeproject 158 | 159 | # Mr Developer 160 | .mr.developer.cfg 161 | .project 162 | .pydevproject 163 | 164 | # mkdocs documentation 165 | /site 166 | 167 | # mypy 168 | .mypy_cache/ 169 | .dmypy.json 170 | dmypy.json 171 | 172 | # Pyre type checker 173 | .pyre/ 174 | 175 | ### VisualStudioCode ### 176 | .vscode/* 177 | !.vscode/settings.json 178 | !.vscode/tasks.json 179 | !.vscode/launch.json 180 | !.vscode/extensions.json 181 | 182 | ### VisualStudioCode Patch ### 183 | # Ignore all local history of files 184 | .history 185 | 186 | # End of https://www.gitignore.io/api/c++,cmake,python,opencv,visualstudiocode 187 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # @file .gitlab-ci.yml 2 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | # 4 | # Copyright (c) 2019 Ignacio Vizzo, all rights reserved 5 | # 6 | # Use this file wisely: You can add more stuff on it if you want. This template 7 | # will allow you to build your project every time you push changes to the git 8 | # server. If you have any error the gitlab server will send you a notification 9 | # to your email. 10 | # You could also provide tests to your project and add a testing 11 | # stage for the CI, this will allow you to run tests for every change you make 12 | # in the code. This is the defacto standard in industry nowadays. Ask google for 13 | # more information if you are curious. 14 | 15 | # Template for all jobs 16 | default: 17 | image: some.url.of.yours 18 | artifacts: 19 | expire_in: 1 h 20 | untracked: true 21 | paths: 22 | - build/ 23 | before_script: 24 | - export TERM=xterm 25 | - export SHELL=/bin/bash 26 | tags: 27 | - docker 28 | 29 | stages: 30 | - configure 31 | - analyse 32 | - build 33 | - test 34 | - deploy 35 | 36 | configure: 37 | stage: configure 38 | script: 39 | - cmake -Bbuild/ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release 40 | 41 | clang-format: 42 | stage: analyse 43 | dependencies: 44 | - configure 45 | allow_failure: true 46 | script: 47 | - cd build/ 48 | - make clang-format 49 | 50 | clang-tidy: 51 | stage: analyse 52 | allow_failure: true 53 | dependencies: 54 | - configure 55 | script: 56 | - cd build/ 57 | - make clang-tidy 58 | 59 | build: 60 | stage: build 61 | dependencies: 62 | - configure 63 | script: 64 | - cd build/ 65 | - make -j$(nproc --all) all 66 | 67 | test: 68 | stage: test 69 | dependencies: 70 | - build 71 | script: 72 | - cd build/ 73 | - ctest -vv 74 | 75 | coverage: 76 | stage: test 77 | dependencies: 78 | - build 79 | script: 80 | - cd build/ 81 | - cmake -DENABLE_COVERAGE=ON .. 82 | - make clean 83 | - make -j$(nproc --all) all 84 | - make test-coverage 85 | coverage: '/TOTAL.*\s+(\S+\%)/' 86 | 87 | deploy: 88 | stage: deploy 89 | dependencies: 90 | - build 91 | script: 92 | - echo "Build succeeded, archiving artifacts..." 93 | - cd build/ 94 | - make -j$(nproc --all) install 95 | artifacts: 96 | name: bow_artifacts 97 | expire_in: 1 week 98 | paths: 99 | - results/ 100 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # @file CMakeLists.txt 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 6 | cmake_minimum_required(VERSION 3.1) 7 | project(starter_project) 8 | 9 | # Set build type if not set. 10 | if(NOT CMAKE_BUILD_TYPE) 11 | set(CMAKE_BUILD_TYPE Release) 12 | endif() 13 | 14 | # Build options 15 | option(ENABLE_CPPCHECK "Enable static analysis with cppcheck" ON) 16 | option(ENABLE_CLANG_TIDY "Enable static analysis with clang-tidy" ON) 17 | option(ENABLE_COVERAGE "Enable coverage reporting" OFF) 18 | 19 | # Attempt to find OpenCV4 on your system, for more details please read 20 | # /usr/share/OpenCV/OpenCVConfig.cmake 21 | find_package(OpenCV 4 REQUIRED) 22 | if(OpenCV_FOUND) 23 | message(STATUS "Found OpenCV version ${OpenCV_VERSION}") 24 | message(STATUS "OpenCV directories: ${OpenCV_INCLUDE_DIRS}") 25 | include_directories(${OpenCV_INCLUDE_DIRS}) 26 | else() 27 | message(FATAL_ERROR "OpenCV not found, please read the README.md") 28 | endif(OpenCV_FOUND) 29 | 30 | # Enable testing 31 | enable_testing() 32 | find_package(GTest REQUIRED) 33 | 34 | # Set additional flags. 35 | set(CMAKE_CXX_STANDARD 17) 36 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 37 | set(CMAKE_CXX_FLAGS "-Wall -Wextra") 38 | set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") 39 | set(CMAKE_CXX_FLAGS_RELEASE "-O3") 40 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 41 | 42 | # Code Coverage, clang-format, clan=tidy, cppcheck, Configuration: 43 | include(TestCoverage) 44 | include(ClangFormat) 45 | include(StaticAnalyzers) 46 | 47 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/) 48 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/) 49 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/) 50 | 51 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) 52 | 53 | # Use this directory to test your installation script 54 | set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/results) 55 | install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ 56 | DESTINATION ${CMAKE_INSTALL_PREFIX}/include/) 57 | 58 | # After all are setup is done, we can go to our src/ directory to build our 59 | # files 60 | add_subdirectory(src) 61 | add_subdirectory(tests) 62 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ignacio Vizzo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C++ Starter Project 2 | 3 | This project template, is, nothing but just a **template** and must used wisely. 4 | By no means you must stick to the project structure, you are **FREE** to do 5 | design how the project should be structured. 6 | 7 | ## How to start? 8 | 9 | Just fork this repository. I reccomend then spend a few minutes inspecting all 10 | the files to see what's in there, and then remove all the C++ 11 | modules/examples/tests and start from scratch. 12 | 13 | You should always remove this `README.md` and start working on your own. 14 | 15 | ## Project Structure 16 | 17 | ```sh 18 | . 19 | ├── cmake # Build configurations, like clang-tidy, clang-format, etc. 20 | ├── docker # A handy docker container has been already generated. 21 | ├── include # The final project include directory, to be exported. 22 | ├── scripts # Some script used by the CI/CD, you should check them. 23 | ├── src # Source directory. 24 | │   ├── apps # Here you could place your application(stuff with main() ). 25 | │   └── lib # Here you can put the library sources. 26 | └── tests # Here you MUST implement tests to test your code. 27 | 28 | ``` 29 | 30 | ## Utilities 31 | 32 | The build system provides 3 handy targets to help you develop your final project 33 | 34 | - `make clang-format` will check the style of your code. **NOTE:** You can 35 | adapt the [.clang-format](./.clang-format) file to fit your needs. 36 | - `make clang-tidy` will run `clang-tidy` on your project. **NOTE:** You can 37 | adapt the [.clang-tidy](./.clang-tidy) file to fit your needs. 38 | - `make test-coverage` will report how much do you cover from your project in 39 | the tests. This will generate an `HTML` report you could open on any modern 40 | browser and see what are you missing to cover: `xdg-open build/coverage/index.html` 41 | 42 | ## CI/CD (based on Gitlab CI/CD) 43 | 44 | The CI/CD is your friend, you get to change/add/disable any functionality, you 45 | are FREE to design your final project. I just place in this template what would 46 | be the bare-minimum to start working with. Make sure you allow some time to 47 | play around in the `pipelines` tab and inspect each `stage` of the pipeline. 48 | 49 | Changes to the CI/CD are done through the [.gitlab-ci.yml](./..gitlab-ci.yml) 50 | configuration file. 51 | 52 | ## Docker 53 | 54 | There is docker image provided by this template, you are also free to change 55 | it/adapt it to your needs. All the information about this docker image is in the 56 | [Dockerfile](docker/Dockerfile) script. In your repository in the `packages` tab 57 | there are instructions on how to build/deploy new versions of the image. **Make 58 | sure** you update the [.gitlab-ci.yml](./..gitlab-ci.yml) with the new docker 59 | image if you plan to change it. 60 | 61 | ## Advice 62 | 63 | Go wild! This is **YOUR** project, you can do whatever pleases you :) Spend as 64 | much time as you like on each module, improve others, change the CI/CD, 65 | disable/enable functionality, use the `Wiki`, do everything, go wild!!! 66 | 67 | Good luck! 68 | -------------------------------------------------------------------------------- /cmake/ClangFormat.cmake: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # @file ClangFormat.cmake 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 6 | find_program(CLANG_FORMAT "clang-format") 7 | if(NOT CLANG_FORMAT) 8 | message(SEND_ERROR "clang-format not found on your \$\{PATH\}") 9 | endif() 10 | 11 | add_custom_target(clang-format 12 | COMMENT "Checking clang-format changes" 13 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 14 | COMMAND ${CMAKE_SOURCE_DIR}/scripts/clang_format.sh) 15 | -------------------------------------------------------------------------------- /cmake/StaticAnalyzers.cmake: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # @file StaticAnalyzers.cmake 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 6 | if(ENABLE_CPPCHECK) 7 | find_program(CPPCHECK cppcheck) 8 | if(CPPCHECK) 9 | set(CMAKE_CXX_CPPCHECK 10 | ${CPPCHECK} 11 | --enable=all 12 | --suppress=missingInclude 13 | --suppress=unusedFunction 14 | --inconclusive) 15 | else() 16 | message(SEND_ERROR "cppcheck requested but executable not found") 17 | endif() 18 | endif() 19 | 20 | if(ENABLE_CLANG_TIDY) 21 | find_program(CLANGTIDY clang-tidy) 22 | if(NOT CLANGTIDY) 23 | message(SEND_ERROR "clang-tidy requested but executable not found") 24 | endif() 25 | 26 | add_custom_target(clang-tidy 27 | COMMENT "Running clang-tidy on all sources" 28 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 29 | COMMAND ${CMAKE_SOURCE_DIR}/scripts/clang_tidy.sh) 30 | 31 | endif() 32 | -------------------------------------------------------------------------------- /cmake/TestCoverage.cmake: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # @file TestCoverage.cmake 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 6 | # Code Coverage Configuration 7 | if(ENABLE_COVERAGE) 8 | # NOTE: Coverage only works/makes sense with debug builds 9 | set(CMAKE_BUILD_TYPE "Debug") 10 | set(CXX_COVERAGE_FLAGS "-fprofile-instr-generate -fcoverage-mapping") 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_COVERAGE_FLAGS}") 12 | message(STATUS "Enabling coverage instrumentation: ${CXX_COVERAGE_FLAGS}") 13 | 14 | add_custom_target(test-coverage 15 | COMMENT "Run test coverage for all sources expect for tests" 16 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 17 | COMMAND ${CMAKE_SOURCE_DIR}/scripts/test_coverage.sh) 18 | endif(ENABLE_COVERAGE) 19 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # @file Dockerfile 2 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | # 4 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | FROM ubuntu:bionic 6 | LABEL maintainer="Ignacio Vizzo " 7 | 8 | # setup environment 9 | CMD ["bash"] 10 | ENV OPENCV_VERSION="4.3.0" 11 | ENV DEBIAN_FRONTEND=noninteractive 12 | ENV TERM xterm 13 | ENV GTEST_COLOR 1 14 | ENV DEBIAN_FRONTEND=noninteractive 15 | ENV LLVM_VERSION=10 16 | ENV GCC_VERSION=9 17 | 18 | # setup locale 19 | RUN apt-get clean && apt-get update && apt-get install -y locales 20 | RUN locale-gen en_US.UTF-8 21 | ENV LANG en_US.UTF-8 22 | 23 | # Upgrade base image 24 | RUN apt-get update && apt-get upgrade -yqq 25 | 26 | # install essentials 27 | RUN apt-get update && apt-get install --no-install-recommends -y \ 28 | openssh-client git build-essential python3 software-properties-common \ 29 | curl rsync jq libgtest-dev libgflags-dev libeigen3-dev qtbase5-dev \ 30 | libqglviewer-headers libboost-all-dev libprotobuf-dev 31 | 32 | # install dependencies 33 | RUN apt-get update && apt-get install --no-install-recommends -y \ 34 | cppcheck wget apt-transport-https libssl-dev gpg-agent 35 | 36 | # install modern toolchains 37 | RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key --no-check-certificate | apt-key add - 38 | RUN add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${LLVM_VERSION} main" \ 39 | && apt-get update 40 | 41 | RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test && apt-get update 42 | RUN apt update && apt install -yy gcc-${GCC_VERSION} g++-${GCC_VERSION} 43 | 44 | COPY install_llvm_toolchain.sh /root 45 | RUN bash /root/install_llvm_toolchain.sh 46 | 47 | # Upgrade cmake(TODO: Use ubuntu:bionic). Build cmake with GNU GCC 48 | RUN wget https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0.tar.gz 49 | RUN tar -xf cmake-3.17.0.tar.gz && cd cmake-3.17.0/ && \ 50 | env CC=gcc CXX=g++ ./bootstrap && \ 51 | make -j && \ 52 | make -j install 53 | 54 | # Install OpenCV4 Dependencies 55 | RUN apt-get update && apt-get install -y libgtk2.0-dev pkg-config \ 56 | libavcodec-dev libavformat-dev libswscale-dev \ 57 | python3-dev python3-numpy libtbb2 libtbb-dev \ 58 | libjpeg-dev libpng-dev libpng++-dev libtiff5-dev libdc1394-22-dev \ 59 | libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common \ 60 | yasm libopencore-amrnb-dev libopencore-amrwb-dev \ 61 | libopenexr-dev libgstreamer-plugins-base1.0-dev libavutil-dev \ 62 | libavfilter-dev libavresample-dev 63 | 64 | # Build and insall libopencv + contrib packages 65 | RUN git clone https://github.com/opencv/opencv.git -b ${OPENCV_VERSION} \ 66 | && git clone https://github.com/opencv/opencv_contrib.git -b ${OPENCV_VERSION} \ 67 | && cd opencv \ 68 | && mkdir build && cd build \ 69 | && cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules .. \ 70 | && make -j && make install 71 | 72 | # Install fmt library 73 | RUN git clone --depth 1 https://github.com/fmtlib/fmt.git -b 6.2.0 \ 74 | && cd fmt \ 75 | && mkdir build && cd build \ 76 | && cmake .. && make -j all install 77 | 78 | # Install google test 79 | RUN git clone --depth 1 https://github.com/google/googletest.git \ 80 | && cd googletest \ 81 | && mkdir build && cd build \ 82 | && cmake .. && make -j all install 83 | 84 | # Install Catch2 85 | RUN git clone --depth 1 https://github.com/catchorg/Catch2.git \ 86 | && cd Catch2 \ 87 | && mkdir build && cd build \ 88 | && cmake -DBUILD_TESTING=OFF .. && make -j all install 89 | 90 | # Cleanup 91 | RUN rm -rf /googletest/ /Catch2 /fmt/ 92 | RUN rm -rf /opencv/ && rm -rf /opencv_contrib/ 93 | RUN rm -rf /cmake-3.17.0* 94 | RUN rm -rf /var/lib/apt/lists/* -------------------------------------------------------------------------------- /docker/install_llvm_toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # @file install_llvm_toolchain.sh 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2019 Ignacio Vizzo, all rights reserved 6 | 7 | # Remove all existing alternatives 8 | update-alternatives --remove-all cc 9 | update-alternatives --remove-all c++ 10 | update-alternatives --remove-all ld 11 | update-alternatives --remove-all clang 12 | update-alternatives --remove-all gcc 13 | 14 | # exit on first error 15 | set -e 16 | 17 | # Clang and co 18 | apt-get install -yy clang-${LLVM_VERSION} \ 19 | clang-tools-${LLVM_VERSION} \ 20 | clang-tidy-${LLVM_VERSION} \ 21 | clang-${LLVM_VERSION}-doc \ 22 | libclang-common-${LLVM_VERSION}-dev \ 23 | libclang-${LLVM_VERSION}-dev \ 24 | libclang1-${LLVM_VERSION} \ 25 | clang-format-${LLVM_VERSION} \ 26 | python3-clang-${LLVM_VERSION} \ 27 | clangd-${LLVM_VERSION} 28 | # lldb 29 | apt-get install -yy lldb-${LLVM_VERSION} 30 | # lld (linker) 31 | apt-get install -yy lld-${LLVM_VERSION} 32 | # OpenMP 33 | apt-get install -yy libomp-${LLVM_VERSION}-dev 34 | 35 | update-alternatives \ 36 | --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 20 \ 37 | --slave /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} \ 38 | --slave /usr/bin/lld lld /usr/bin/lld-${LLVM_VERSION} \ 39 | --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-${LLVM_VERSION} \ 40 | --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${LLVM_VERSION} \ 41 | --slave /usr/bin/clang-tidy-diff.py clang-tidy-diff.py /usr/bin/clang-tidy-diff-${LLVM_VERSION}.py \ 42 | --slave /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-${LLVM_VERSION} \ 43 | --slave /usr/bin/clang-include-fixer clang-include-fixer /usr/bin/clang-include-fixer-${LLVM_VERSION} \ 44 | --slave /usr/bin/clang-offload-bundler clang-offload-bundler /usr/bin/clang-offload-bundler-${LLVM_VERSION} \ 45 | --slave /usr/bin/clangd clangd /usr/bin/clangd-${LLVM_VERSION} \ 46 | --slave /usr/bin/clang-check clang-check /usr/bin/clang-check-${LLVM_VERSION} \ 47 | --slave /usr/bin/scan-view scan-view /usr/bin/scan-view-${LLVM_VERSION} \ 48 | --slave /usr/bin/clang-apply-replacements clang-apply-replacements /usr/bin/clang-apply-replacements-${LLVM_VERSION} \ 49 | --slave /usr/bin/clang-query clang-query /usr/bin/clang-query-${LLVM_VERSION} \ 50 | --slave /usr/bin/modularize modularize /usr/bin/modularize-${LLVM_VERSION} \ 51 | --slave /usr/bin/sancov sancov /usr/bin/sancov-${LLVM_VERSION} \ 52 | --slave /usr/bin/c-index-test c-index-test /usr/bin/c-index-test-${LLVM_VERSION} \ 53 | --slave /usr/bin/clang-reorder-fields clang-reorder-fields /usr/bin/clang-reorder-fields-${LLVM_VERSION} \ 54 | --slave /usr/bin/clang-change-namespace clang-change-namespace /usr/bin/clang-change-namespace-${LLVM_VERSION} \ 55 | --slave /usr/bin/clang-import-test clang-import-test /usr/bin/clang-import-test-${LLVM_VERSION} \ 56 | --slave /usr/bin/scan-build scan-build /usr/bin/scan-build-${LLVM_VERSION} \ 57 | --slave /usr/bin/scan-build-py scan-build-py /usr/bin/scan-build-py-${LLVM_VERSION} \ 58 | --slave /usr/bin/clang-cl clang-cl /usr/bin/clang-cl-${LLVM_VERSION} \ 59 | --slave /usr/bin/clang-rename clang-rename /usr/bin/clang-rename-${LLVM_VERSION} \ 60 | --slave /usr/bin/find-all-symbols find-all-symbols /usr/bin/find-all-symbols-${LLVM_VERSION} \ 61 | --slave /usr/bin/lldb lldb /usr/bin/lldb-${LLVM_VERSION} \ 62 | --slave /usr/bin/lldb-server lldb-server /usr/bin/lldb-server-${LLVM_VERSION} \ 63 | --slave /usr/bin/llvm-addr2line llvm-addr2line /usr/bin/llvm-addr2line-${LLVM_VERSION} \ 64 | --slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-${LLVM_VERSION} \ 65 | --slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-${LLVM_VERSION} \ 66 | --slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-${LLVM_VERSION} \ 67 | --slave /usr/bin/llvm-cat llvm-cat /usr/bin/llvm-cat-${LLVM_VERSION} \ 68 | --slave /usr/bin/llvm-cfi-verify llvm-cfi-verify /usr/bin/llvm-cfi-verify-${LLVM_VERSION} \ 69 | --slave /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${LLVM_VERSION} \ 70 | --slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-${LLVM_VERSION} \ 71 | --slave /usr/bin/llvm-c-test llvm-c-test /usr/bin/llvm-c-test-${LLVM_VERSION} \ 72 | --slave /usr/bin/llvm-cvtres llvm-cvtres /usr/bin/llvm-cvtres-${LLVM_VERSION} \ 73 | --slave /usr/bin/llvm-cxxdump llvm-cxxdump /usr/bin/llvm-cxxdump-${LLVM_VERSION} \ 74 | --slave /usr/bin/llvm-cxxfilt llvm-cxxfilt /usr/bin/llvm-cxxfilt-${LLVM_VERSION} \ 75 | --slave /usr/bin/llvm-cxxmap llvm-cxxmap /usr/bin/llvm-cxxmap-${LLVM_VERSION} \ 76 | --slave /usr/bin/llvm-diff llvm-diff /usr/bin/llvm-diff-${LLVM_VERSION} \ 77 | --slave /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-${LLVM_VERSION} \ 78 | --slave /usr/bin/llvm-dlltool llvm-dlltool /usr/bin/llvm-dlltool-${LLVM_VERSION} \ 79 | --slave /usr/bin/llvm-dwarfdump llvm-dwarfdump /usr/bin/llvm-dwarfdump-${LLVM_VERSION} \ 80 | --slave /usr/bin/llvm-dwp llvm-dwp /usr/bin/llvm-dwp-${LLVM_VERSION} \ 81 | --slave /usr/bin/llvm-elfabi llvm-elfabi /usr/bin/llvm-elfabi-${LLVM_VERSION} \ 82 | --slave /usr/bin/llvm-exegesis llvm-exegesis /usr/bin/llvm-exegesis-${LLVM_VERSION} \ 83 | --slave /usr/bin/llvm-extract llvm-extract /usr/bin/llvm-extract-${LLVM_VERSION} \ 84 | --slave /usr/bin/llvm-ifs llvm-ifs /usr/bin/llvm-ifs-${LLVM_VERSION} \ 85 | --slave /usr/bin/llvm-install-name-tool llvm-install-name-tool /usr/bin/llvm-install-name-tool-${LLVM_VERSION} \ 86 | --slave /usr/bin/llvm-jitlink llvm-jitlink /usr/bin/llvm-jitlink-${LLVM_VERSION} \ 87 | --slave /usr/bin/llvm-lib llvm-lib /usr/bin/llvm-lib-${LLVM_VERSION} \ 88 | --slave /usr/bin/llvm-link llvm-link /usr/bin/llvm-link-${LLVM_VERSION} \ 89 | --slave /usr/bin/llvm-lipo llvm-lipo /usr/bin/llvm-lipo-${LLVM_VERSION} \ 90 | --slave /usr/bin/llvm-lto llvm-lto /usr/bin/llvm-lto-${LLVM_VERSION} \ 91 | --slave /usr/bin/llvm-lto2 llvm-lto2 /usr/bin/llvm-lto2-${LLVM_VERSION} \ 92 | --slave /usr/bin/llvm-mc llvm-mc /usr/bin/llvm-mc-${LLVM_VERSION} \ 93 | --slave /usr/bin/llvm-mca llvm-mca /usr/bin/llvm-mca-${LLVM_VERSION} \ 94 | --slave /usr/bin/llvm-modextract llvm-modextract /usr/bin/llvm-modextract-${LLVM_VERSION} \ 95 | --slave /usr/bin/llvm-mt llvm-mt /usr/bin/llvm-mt-${LLVM_VERSION} \ 96 | --slave /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-${LLVM_VERSION} \ 97 | --slave /usr/bin/llvm-objcopy llvm-objcopy /usr/bin/llvm-objcopy-${LLVM_VERSION} \ 98 | --slave /usr/bin/llvm-objdump llvm-objdump /usr/bin/llvm-objdump-${LLVM_VERSION} \ 99 | --slave /usr/bin/llvm-opt-report llvm-opt-report /usr/bin/llvm-opt-report-${LLVM_VERSION} \ 100 | --slave /usr/bin/llvm-pdbutil llvm-pdbutil /usr/bin/llvm-pdbutil-${LLVM_VERSION} \ 101 | --slave /usr/bin/llvm-PerfectShuffle llvm-PerfectShuffle /usr/bin/llvm-PerfectShuffle-${LLVM_VERSION} \ 102 | --slave /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-${LLVM_VERSION} \ 103 | --slave /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-${LLVM_VERSION} \ 104 | --slave /usr/bin/llvm-rc llvm-rc /usr/bin/llvm-rc-${LLVM_VERSION} \ 105 | --slave /usr/bin/llvm-readelf llvm-readelf /usr/bin/llvm-readelf-${LLVM_VERSION} \ 106 | --slave /usr/bin/llvm-readobj llvm-readobj /usr/bin/llvm-readobj-${LLVM_VERSION} \ 107 | --slave /usr/bin/llvm-reduce llvm-reduce /usr/bin/llvm-reduce-${LLVM_VERSION} \ 108 | --slave /usr/bin/llvm-rtdyld llvm-rtdyld /usr/bin/llvm-rtdyld-${LLVM_VERSION} \ 109 | --slave /usr/bin/llvm-size llvm-size /usr/bin/llvm-size-${LLVM_VERSION} \ 110 | --slave /usr/bin/llvm-split llvm-split /usr/bin/llvm-split-${LLVM_VERSION} \ 111 | --slave /usr/bin/llvm-stress llvm-stress /usr/bin/llvm-stress-${LLVM_VERSION} \ 112 | --slave /usr/bin/llvm-strings llvm-strings /usr/bin/llvm-strings-${LLVM_VERSION} \ 113 | --slave /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-${LLVM_VERSION} \ 114 | --slave /usr/bin/llvm-symbolizer llvm-symbolizer /usr/bin/llvm-symbolizer-${LLVM_VERSION} \ 115 | --slave /usr/bin/llvm-tblgen llvm-tblgen /usr/bin/llvm-tblgen-${LLVM_VERSION} \ 116 | --slave /usr/bin/llvm-undname llvm-undname /usr/bin/llvm-undname-${LLVM_VERSION} \ 117 | --slave /usr/bin/llvm-xray llvm-xray /usr/bin/llvm-xray-${LLVM_VERSION} 118 | 119 | # Update alternatives for GCC 120 | update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 90 \ 121 | --slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} 122 | 123 | # For some reason Ubuntu 18.04 does not provide a default alternative for gcc-7 124 | update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 50 \ 125 | --slave /usr/bin/g++ g++ /usr/bin/g++-7 126 | 127 | update-alternatives --set gcc /usr/bin/gcc-${GCC_VERSION} 128 | 129 | # GCC 130 | update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 \ 131 | --slave /usr/bin/c++ c++ /usr/bin/g++ \ 132 | --slave /usr/bin/ld ld /usr/bin/x86_64-linux-gnu-ld 133 | 134 | # LLVM 135 | update-alternatives --install /usr/bin/cc cc /usr/bin/clang 40 \ 136 | --slave /usr/bin/c++ c++ /usr/bin/clang++ \ 137 | --slave /usr/bin/ld ld /usr/bin/lld 138 | 139 | # Set clang as default compiler system wide 140 | update-alternatives --set cc /usr/bin/clang 141 | -------------------------------------------------------------------------------- /include/lib/lib.h: -------------------------------------------------------------------------------- 1 | // @file lib.h 2 | // @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | // 4 | // Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | #ifndef lib_H_ 6 | #define lib_H_ 7 | 8 | #include 9 | 10 | #endif // lib_H_ 11 | -------------------------------------------------------------------------------- /scripts/clang_format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # @file clang_format.sh 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 6 | set -e 7 | sources=$(find . -regextype posix-extended -regex \ 8 | ".*\.(cpp|cxx|cc|hpp|hxx|h)" | 9 | grep -vE "^./(build)/") 10 | 11 | echo "Running clang-format on all project sources" 12 | clang-format -Werror --dry-run --ferror-limit=1 -style=file ${sources} 13 | -------------------------------------------------------------------------------- /scripts/clang_tidy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # @file clang_tidy.sh 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 6 | set -e 7 | 8 | # Don't run clang-tidy on tests/ folder, it will most likely fail 9 | sources=$(find . -regextype posix-extended -regex \ 10 | ".*\.(cpp|cxx|cc|hpp|hxx|h)" | 11 | grep -vE "^./(build|tests)/") 12 | 13 | echo "Running clang-tidy on all project sources, except for the tests/ folder" 14 | run-clang-tidy -quiet -p build/ ${sources} -j$(nproc --all) 15 | -------------------------------------------------------------------------------- /scripts/test_coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # @file test_coverage.sh 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 6 | 7 | set -e 8 | 9 | BUILD_DIR=$(pwd) 10 | TEST_DIR=$(ctest --show-only=json-v1 | jq '.tests[0].properties[0].value' | tr -d '"') 11 | TEST_COMMAND="$(ctest -V -N | grep -oP "(Test command:\s)\K([^\s]+)" | tail -n1 | tr -d '\n')" 12 | 13 | # Change directory to where ctest expect to be the running 14 | cd ${TEST_DIR} 15 | 16 | # Run the coverage profiler 17 | LLVM_PROFILE_FILE="TestCoverage.profraw" ${TEST_COMMAND} 18 | llvm-profdata merge -sparse TestCoverage.profraw -o TestCoverage.profdata 19 | 20 | # Create the html report 21 | llvm-cov show ${TEST_COMMAND} \ 22 | -instr-profile=TestCoverage.profdata \ 23 | -show-line-counts-or-regions \ 24 | -output-dir=${BUILD_DIR}/coverage/ \ 25 | -ignore-filename-regex="tests/" \ 26 | -format="html" 27 | 28 | # Print to the standrad out the coverage report summary 29 | llvm-cov report ${TEST_COMMAND} \ 30 | -instr-profile=TestCoverage.profdata \ 31 | -ignore-filename-regex="tests/" 32 | 33 | # Go back to build directory 34 | cd "${BUILD_DIR}" 35 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | # 4 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | add_subdirectory(apps) 6 | add_subdirectory(lib) 7 | -------------------------------------------------------------------------------- /src/apps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | # 4 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | add_executable(example example.cpp) 6 | target_link_libraries(example lib) 7 | install(TARGETS example 8 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin 9 | LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 10 | ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) 11 | -------------------------------------------------------------------------------- /src/apps/example.cpp: -------------------------------------------------------------------------------- 1 | // @file example.cpp 2 | // @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | // 4 | // Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | #include 6 | 7 | #include 8 | 9 | int main() { 10 | std::cout << "Write your awesome BoW Implementation on this project\n"; 11 | 12 | // Library API call 13 | delete_this_file::foo(); 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /src/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | # 4 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | add_library(lib example_lib.cpp) 6 | 7 | # Install headers 8 | install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 9 | DESTINATION "${CMAKE_INSTALL_PREFIX}/include" 10 | PATTERN "*.cpp" 11 | EXCLUDE 12 | PATTERN "*.txt" 13 | EXCLUDE) 14 | 15 | install(TARGETS lib 16 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin 17 | LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib 18 | ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) 19 | -------------------------------------------------------------------------------- /src/lib/example_lib.cpp: -------------------------------------------------------------------------------- 1 | // @file example_lib.cpp 2 | // @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | // 4 | // Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | 6 | #include "example_lib.hpp" 7 | 8 | void delete_this_file::foo() {} -------------------------------------------------------------------------------- /src/lib/example_lib.hpp: -------------------------------------------------------------------------------- 1 | // @file example_lib.hpp 2 | // @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | // 4 | // Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | #ifndef EXAMPLE_LIB_HPP_ 6 | #define EXAMPLE_LIB_HPP_ 7 | 8 | namespace delete_this_file { 9 | void foo(); 10 | } 11 | #endif // EXAMPLE_LIB_HPP_ 12 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~ 2 | # @file CMakeLists.txt 3 | # @author Ignacio Vizzo [ivizzo@uni-bonn.de] 4 | # 5 | # Copyright (c) 2020 Ignacio Vizzo, all rights reserved 6 | set(TEST_BINARY ${PROJECT_NAME}_test) 7 | add_executable(${TEST_BINARY} test_lib.cpp) 8 | target_link_libraries(${TEST_BINARY} lib GTest::Main) 9 | gtest_discover_tests(${TEST_BINARY}) 10 | -------------------------------------------------------------------------------- /tests/test_lib.cpp: -------------------------------------------------------------------------------- 1 | // @file test_lib.cpp 2 | // @author Ignacio Vizzo [ivizzo@uni-bonn.de] 3 | // 4 | // Copyright (c) 2020 Ignacio Vizzo, all rights reserved 5 | #include 6 | 7 | #include "lib/example_lib.hpp" 8 | 9 | TEST(Testlib, RemoveThisFile) { EXPECT_NO_THROW(delete_this_file::foo()); } 10 | --------------------------------------------------------------------------------