Package: cpp-project-framework
C++ Project FrameworkC++ Project Framework is a framework for creating C++ project.Canonical Project Structure for C++Canonical Project Structure:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1204r0.htmlThe Pitchfork Layout:https://api.csswg.org/bikeshed/?force=1&url=https://raw.githubusercontent.com/vector-of-bool/pitchfork/develop/data/spec.bs<name>/├──<name>/│└──...├──<module>/│├──<module>.h// header file containing mainly module declarations│├──<module>.hpp// header file containing module declarations and/or definitions│├──<module>.cpp// source file containing module definitions│├──<module>.test.cpp// source file containing module unit tests│└──main.cpp// source file containing the main function for exe├──...└──tests/// functional/integration tests├──benchmarks/// benchmark/performance tests│├──<benchmark>/││└──<benchmark>.benchmark.cpp// source file containing module benchmark tests│└──...└──...PrerequisitesBuild System Generator:CMake >= 3.10Build System:GNU Make >= 4.2 (Linux), MSBuild >= 14.0 (Visual Studio 2015) (Windows)Compiler:g++ >= 9.1 (Linux), MSVC >= 14.0 (Visual Studio 2015) (Windows)Version Control System (VCS):Git >= 2.16Package Manager Scripting:Python >= 3.6C++ Standard:>= C++14Optional PrerequisitesIntegrated Development Environment (IDE):Visual Studio Code >= 1.49Visual Studio Code Extensions:C/C++ >= 1.0.1C++ Intellisense >= 0.2.2Clang-Format >= 1.9.0CMake >= 0.0.17CMake Tools >= 1.4.2Python >= 2020.8Remote - SSH >= 0.55.0Remote Development >= 0.20.0GitLens >= 10.2.2Doxygen Documentation Generator >= 1.1.0C++ TestMate >= 3.6.23Five Server (Live Server) >= 0.0.34Continous Integration (CI):Jenkins >= 2.319.1Jenkins Running:Java 8 or 11 (OpenJDK JDK/JRE 8 or 11) >= 1.8.0Jenkins Plugins:Locale >= 1.4Pipeline >= 2.6Git >= 4.10.1Blue Ocean >= 1.25.2xUnit >= 3.0.5Recommended C++ Development Environmenthttps://www.reddit.com/r/cpp/comments/af74l1/recommendations_for_setting_up_a_modern_c_dev/build system generator:CMakebuild system:Ninjacompiler:clang++ (cross-platform), MSBuild/MSVC (Windows), g++ (Linux)Integrated Development Environment (IDE):Visual Studio Code, Qt Creatorstatic code analyzers:clang-tidy, Cppcheck, Clazysource code formatter:clang-formatsource code documentation generator:Doxygensoftware distribution packaging system:CPackC++ libraries:general-purpose:C++ Standard Librarygeneral-purpose:Boost C++ Librariesstring formatting:fmtlogging:spdlogautomated testing:Google Test / Google Mockgraphical user interface (GUI):Qtpackage manager:Conan, vcpkgcontinuous integration (CI):Jenkins, CDashversion control system (VCS):Gitcode coverage:OpenCppCoverage (Windows), gcov + gcovr (Linux)Chosen C++ Development Environmenthttps://en.cppreference.com/w/cpp/compiler_support# Required (manual install)Build System Generator:CMake >= 3.10Build System:GNU Make >= 4.2 (Linux), MSBuild >= 14.0 (Visual Studio 2015) (Windows)Compiler:g++ >= 9.1 (Linux), MSVC >= 14.0 (Visual Studio 2015) (Windows)Version Control System (VCS):Git >= 2.16Package Manager Scripting:Python >= 3.6 (or Anaconda3 on Windows)C++ Standard:>= C++14# Required (distributed with manual installed tools)Testing Tool:CTest (CMake)Software Distribution Packaging System:CPack (CMake)Python Package Installer:pip >= 9.0 (Python)# Required (auto installed by C++ Project Framework)Package Manager:Conan (pip)Code Coverage Report:gcovr (pip), OpenCppCoverage (Windows)# C++ LibrariesGeneral Purpose:C++ Standard Library (compiler included)General Purpose:Boost (boost)Unit Test Framework:Google Test (gtest)Logging:Boost Log (boost::log)Embedded Local Key-Value Store:RocksDB (rocksdb)Embedded Local SQL Database:SQLite (sqlite)# OptionalIntegrated Development Environment (IDE):Visual Studio Code >= 1.49Source Code Documentation Generator:Doxygen >= 1.8Graphical User Interface:QtContinous Integration (CI):Jenkins >= 2.319.1Debugger:gdb (Linux), WinDbg (Windows), Visual Studio Debugger (Windows)Performance Profiler:perf (Linux), gprof (Linux), orbit (Linux, Windows)Source Code Formatter:ClangFormat (clang-format)Similar Projects Creating C++ Project FrameworkPitchforkhttps://github.com/vector-of-bool/pitchforkPitchfork is a set of conventions for native C and C++ projects. The most prominent being the project layout conventions.Boiler plate for C++ projectshttps://github.com/bsamseth/cpp-projectThis is a boiler plate for C++ projects. What you get:Sources, headers and mains separated in distinct foldersUse of modern CMake for much easier compilingSetup for tests using doctestContinuous testing with Travis-CI and Appveyor, with support for C++17.Code coverage reports, including automatic upload to Coveralls.io and/or Codecov.ioCode documentation with Doxygencpp-project-templatehttps://github.com/Bo-Yuan-Huang/cpp-starterThis is a starting template for C++ projects that supports:Hierarchical sources and headersAccess to Google TestsUse of CMake for much easier compilingCode documentation with DoxygenContinuous testing with Travis-CICode coverage with Coveralls.ioStatic analysis with Coverity SacnC++ Project Templatehttps://github.com/TimothyHelton/cpp_project_templateWhen setting out on a new project in C++ there are a few configuration steps which need to be completed prior to actually getting down to writing code. This repository is going to be a C++ project template that already has the following components:Directory StructureMake Build (CMake)Unit Test Framework (Google Test)API Documentation (Doxygen)moderncpp-project-templatehttps://github.com/madduci/moderncpp-project-templateThis repository aims to represent a template for Modern C++ projects, including static analysis checks, autoformatting, a BDD/TDD capable test-suite and packagingRequirementsa modern C++17 compiler (gcc-8, clang-6.0, MSVC 2017 or above)cmake 3.10+conan 1.4+conan_package_tools (optional)cppcheck (optional)clang-format (optional)clang-check (optional)FeaturesCMake-based project management, including dependenciesConan support for dependency management in CMake, completely optionalAdditional tools such as clang-format and cppcheckSupport for shared/static libraries, including generation of export informationBasic CPack configuration for redistributablesGitHub ActionsCMake-Jenkins-CPP Frameworkhttps://github.com/planetpratik/CMake-Jenkins-CPPA Cross-Platform Modern C++ Project Framework Set Up Using CMake, Jenkins & VcpkgGoals :-To create a Cross-Platform C++ project framework using CMake which follows same project structure as FieaGameEngine Project ( originally developed using Visual Studio 2017 ).To support Continuous Integration using Jenkins.To support better dependency management using Vcpkg as a package manager.To be easily able to bootstrap cross-platform C++ project using CMake & Jenkins with minimum efforts.Useful Resources for C++cppreferencehttp://www.cppreference.com/Our goal is to provide programmers with a complete online reference for the C and C++ languages and standard libraries, i.e. a more convenient version of the C and C++ standards.cplusplushttps://www.cplusplus.com/Description of the most important classes, functions and objects of the Standard Language Library, with descriptive fully-functional short programs as examplesC++ Papyrus - C++ Annotations about Modern C++https://github.com/caiorss/C-Cpp-NotesThis repository contains annotations and examples about moodern C++, system programming and building systems for C and C++.Awesome C++https://github.com/fffaraz/awesome-cpphttps://awesome-cpp.readthedocs.io/en/latest/README.htmlA curated list of awesome C++ (or C) frameworks, libraries, resources, and shiny things. Inspired by awesome-... stuff.Package C++ Project Framework Python ProjectHow To Package Your Python CodePackaging Python ProjectsBuilding and Distributing Packages with SetuptoolsWhat Are Python WheelsGo tocpp_project_frameworkroot folder first, activate python virtual evironment (create it if not yet created), then follow below procedures:Install C++ Project Framework Python Package Locally# Upgrade pip to latest versionpython-mpipinstall--upgradepip# Install the package locallypython-mpipinstall.Generate C++ Project Framework Python Distribution Archives# Upgrade PyPA's build to latest versionpython-mpipinstall--upgradebuild# Generate distribution archives in dist directorypython-mbuild# Check the generated archiveslsdist
cpp_project_framework-1.0.0-py3-none-any.whl
cpp_project_framework-1.0.0.tar.gzThetar.gzfile is a source archive whereas the.whlfile is a built distribution.Upload Generated C++ Project Framework Python Distribution Archives to Test Python Package Index (TestPyPI)# Upgrade PyPI's twine to latest versionpython-mpipinstall--upgradetwine# Upload all of the arhives under dist directory to TestPyPIpython-mtwineupload--repositorytestpypidist/*Install C++ Project Framework Python Package from TestPyPI# Upgrade pip to latest versionpython-mpipinstall--upgradepip# Install the package from TestPyPIpython-mpipinstall--index-urlhttps://test.pypi.org/simple/--no-depscpp_project_frameworkCreate New C++ Project by Python Script with TemplateAfter installed the C++ project framework python package (namelycpp_project_framework), input the required parameters as prompted in below python script and a new C++ project withC++ Project Frameworkproject structure will be created:Method 1 (by calling C++ project framework python module):python-mcpp_project_framework.create_new_projectMethod 2 (by running C++ project framework python script):create_new_cpp_projectVisual Studio Code CMake Tools SettingsConfiguring CMake ToolsAllow Building in Different Directories per Build Typehttps://github.com/microsoft/vscode-cmake-tools/issues/151File > Preferences > Settings > Extensions > CMake Tools > Cmake: Build Directory.vscode/settings.json{"cmake.buildDirectory":"${workspaceFolder}/${buildType}"}Visual Studio Code C++ Include Path Setting.vscode/c_cpp_properties.json{"configurations":[{"includePath":["${workspaceFolder}/**","~/.conan/data/**"],"windowsSdkVersion":"10.0.10240.0"}]}Manually Specify a Python Interpreterhttps://code.visualstudio.com/docs/python/environments#_manually-specify-an-interpreterFile > Preferences > Settings > Extensions > Python > Python: Default Interpreter Path.vscode/settings.json{"python.defaultInterpreterPath":"./.venv/bin/python"}C++ TestMate Visual Studio Code Extension for Test Explorer SettingFile > Preferences > Settings > Extensions > C++ TestMate > TestMate > Cpp > Tests: Executables.vscode/settings.json{"testMate.cpp.test.executables":"{build,Build,BUILD,out,Out,OUT,Debug,Release}/**/*{test,Test,TEST}*"}C++ Code Formatting using Visual Studio Code with ClangFormathttps://code.visualstudio.com/docs/cpp/cpp-ide#_code-formattinghttps://clang.llvm.org/docs/ClangFormatStyleOptions.htmlFormat an entire file with Format Document (Shift+Alt+F) or just the current selection with Format Selection (Ctrl+K Ctrl+F) in right-click context menu.Create ClangFormat File inside Visual Studio Code Workspace# .clang-formatUseTab:NeverIndentWidth:4BreakBeforeBraces:AllmanAllowShortIfStatementsOnASingleLine:falseIndentCaseLabels:falseColumnLimit:0PointerAlignment:LeftAccessModifierOffset:-4Setup Remote SSH for Visual Studio Codehttps://code.visualstudio.com/docs/remote/sshStart by selectingRemote-SSH: Add New SSH Host...from the Command Palette (F1,Ctrl+Shift+P) or clicking on theAdd Newicon in the SSHRemote Explorerin the Activity Bar.%USERPROFILE%/.ssh/configHost curtis@127.0.0.1:10022
  HostName ubuntu
  User curtis
  Port 10022
  IdentityFile %USERPROFILE%\\.ssh\\id_rsaGenerate SSH Key Pairhttps://code.visualstudio.com/docs/remote/troubleshooting#_quick-start-using-ssh-keysOn Linux SSH Server Side:# Linuxcd~/.ssh
ssh-keygen-trsa-b4096catid_rsa.pub>>authorized_keys
chmod644authorized_keysid_rsa.pubis thepublickey generated andid_rsais theprivatekey generated.authorized_keysis the file with keys that SSH server accepted for.On Windows SSH Client Side:Copyid_rsafrom~/.ssh/id_rsaon Linux SSH server side to%USERPROFILE%/.ssh/id_rsaon Windows SSH client side.Setup Githttps://stackoverflow.com/questions/68775869/support-for-password-authentication-was-removed-please-use-a-personal-access-toConfigure Git Client Usergitconfig--globaluser.name"Curtis Lo"gitconfig--globaluser.email"github_email"gitconfig-lClone Git Repositorygitclonehttps://github.com/sheepgrass/cpp_project_framework.gitRemember Git Credentialgitconfig--globalcredential.helpercacheInstall Build Essential (GCC, Make)# Linux (Ubuntu)sudoaptinstallbuild-essentialInstall CMake# Linux (Ubuntu)sudoapt-getinstallcmakeCreate Python Virtual Environment under Current Project# Linuxpython3-mvenv.venvsource.venv/bin/activate
...
deactivate# Windows
%LOCALAPPDATA%\Continuum\anaconda3\python.exe -m venv .venv
.venv\Scripts\activate
...
deactivateInstall Conanhttps://docs.conan.io/en/latest/installation.htmlsource.venv/bin/activate
pipinstall-Uconan
conanSearch for Repository (Package Recipes) in ConanCenterhttps://conan.io/centerconansearch--remote=conan-centerg3log
conaninspectg3log/1.3.3Create Conan Filehttps://docs.conan.io/en/latest/getting_started.html# conanfile.txt[requires][generators]cmake_multiConan Multi-configuration Generatorhttps://docs.conan.io/en/latest/integrations/build_system/cmake/cmake_multi_generator.htmlConan for New GCC ABIHow to manage the GCC >= 5 ABIWhen Conan creates the default profile the first time it runs, it adjusts thecompiler.libcxxsetting tolibstdc++for backwards compatibility. However, if you are using GCC >= 5 your compiler is likely to be using the new CXX11 ABI by default (libstdc++11).If you want Conan to use the new ABI, edit the default profile at~/.conan/profiles/defaultadjustingcompiler.libcxx=libstdc++11or override this setting in the profile you are using.# Linuxvim~/.conan/profiles/default[settings]os=Linuxos_build=Linuxarch=x86_64arch_build=x86_64compiler=gcccompiler.version=9compiler.libcxx=libstdc++11build_type=ReleaseCMake Build TypesCMAKE_BUILD_TYPE=[Debug|Release|MinSizeRel|RelWithDebInfo]Install Required Dependencies by Conanhttps://docs.conan.io/en/latest/reference/commands/consumer/install.htmlconaninstall.-bmissing-sbuild_type={CMAKE_BUILD_TYPE}-if{CMAKE_BUILD_TYPE}Conan Package Location# Linux~/.conan/data# Windows
%USERPROFILE%\.conan\dataGenerate CMake Projecthttps://cmake.org/cmake/help/latest/manual/cmake.1.html#generate-a-project-buildsystemcmake-S.-B{CMAKE_BUILD_TYPE}-DCMAKE_BUILD_TYPE={CMAKE_BUILD_TYPE}[-G"Visual Studio 14 2015"-Ax64]Build CMake Projecthttps://cmake.org/cmake/help/v3.14/manual/cmake.1.html#build-a-projectcmake--build{CMAKE_BUILD_TYPE}[--clean-first-j4-v]Build Specific Target of CMake Projecthttps://cmake.org/cmake/help/v3.14/manual/cmake.1.html#build-a-projectcmake--build{CMAKE_BUILD_TYPE}--target{CMAKE_BUILD_TARGET}[-j4-v]Open CMake Generated Projecthttps://cmake.org/cmake/help/latest/manual/cmake.1.html#open-a-projectcmake--open{CMAKE_BUILD_TYPE}Generate CMake Installer by CPackhttps://cmake.org/cmake/help/latest/manual/cpack.1.html#manual:cpack(1)cd{CMAKE_BUILD_TYPE}&&cpack-C{CMAKE_BUILD_TYPE}[-GZIP]Create Conan Package Recipehttps://docs.conan.io/en/latest/creating_packages/getting_started.htmlmkdirpackage&&cdpackage
conannew{CMAKE_PROJECT_NAME}/{CMAKE_PROJECT_VERSION}-tCreate Conan Packagehttps://docs.conan.io/en/latest/creating_packages/getting_started.htmlconancreate.demo/testingDownload Existing Package Recipehttps://docs.conan.io/en/latest/reference/commands/misc/download.htmlconandownloadg3log/1.3.3@-reCopy Existing Recipe and Package to Another User Channelhttps://docs.conan.io/en/latest/reference/commands/misc/copy.htmlconancopyg3log/1.3.3@sheepgrass/modifiedConan Center Index Recipeshttps://github.com/conan-io/conan-center-index/tree/master/recipesModify Existing Package Recipehttps://docs.conan.io/en/latest/howtos/collaborate_packages.htmlhttps://dmerej.info/blog/post/chuck-norris-part-4-python-ctypes/https://stackoverflow.com/questions/63670642/cant-create-boost-conan-package-from-conan-center-index-conanfile-didnt-spec# Linuxmkdirg3log&&cdg3log
conandownloadg3log/1.3.3@-re
cp-rv~/.conan/data/g3log/1.3.3/_/_/export/*.
cp-rv~/.conan/data/g3log/1.3.3/_/_/export_source/*.
conancreate.1.3.3@sheepgrass/modified
conanuploadg3log/1.3.3@sheepgrass/modified--all-r=local# Windows
mkdir g3log && cd g3log
conan download g3log/1.3.3@ -re
xcopy %USERPROFILE%\.conan\data\g3log\1.3.3\_\_\export\* . /E
xcopy %USERPROFILE%\.conan\data\g3log\1.3.3\_\_\export_source\* . /E
conan create . 1.3.3@sheepgrass/modified
conan upload g3log/1.3.3@sheepgrass/modified --all -r=localCreate Patch File in Unified Diff Format for Existing Package using WinMergehttps://docs.conan.io/en/latest/reference/tools.html#tools-patchSet original source file as 1st fileSet modified source file as 2nd fileCompare themIn menu, select "Tools > Generate Patch..."Set "Result" to target patch file path and name with extension *.patchSet "Format > Style:" to "Unified"Set "Format > Context:" to "3"Set "Whitespaces" to "Compare"Uncheck "Ignore blank lines"Check "Case sensitive"Check "Ignore carriage return differences (Windows/Unix/Mac)"Click "OK" to generate patch fileModify patch file to make diff path relative to "source_subfolder"Add patch file to conandata.yml:patches:[version]:-base_path:source_subfolderpatch_file:patches/?.patchCalculate MD5 checksum for the patch file:certutil -hashfile ?.patch md5Add patch file to conanmanifest.txt:export_source/patches/?.patch: [md5]Add patch files to export sources of conan recipe file conanfile.py:exports_sources=["CMakeLists.txt","patches/*"]Add patch snippet to conan recipe file conanfile.py:if"patches"inself.conan_dataandself.versioninself.conan_data["patches"]:forpatchinself.conan_data["patches"][self.version]:tools.patch(**patch)Get List of Conan Repository Servers (Remotes) in Usehttps://docs.conan.io/en/latest/uploading_packages/uploading_to_remotes.htmlconanremotelistAdd Conan Repository Server (Remote)conanremoteaddlocalhttp://localhost:9300Search Conan Packageconansearch{PACKAGE_NAME}-r=localUpload Conan Package to Conan Repository Server (Remote)https://docs.conan.io/en/latest/uploading_packages/uploading_to_remotes.htmlconanupload{CMAKE_PROJECT_NAME}/{CMAKE_PROJECT_VERSION}@demo/testing--all-r=localRemove Local Conan Package Cacheconanremove{CMAKE_PROJECT_NAME}*Run Simple Open Source Conan Repository Serverhttps://docs.conan.io/en/latest/uploading_packages/running_your_server.htmlconan_serverSimple Open Source Conan Repository Server Config File Location# Linux~/.conan_server/server.conf# Windows
%USERPROFILE%\.conan_server\server.confSimple Open Source Conan Repository Server Package Location# Linux~/.conan_server/data# Windows
%USERPROFILE%\.conan_server\dataSet BUILD_TYPE Environment Variable# LinuxexportBUILD_TYPE=Debug# Windows
set BUILD_TYPE=DebugActivate Python Virtual Environment# Linux`makevenv_activate`# Windows
make venv_activateMake Steps# Set Build TypeexportBUILD_TYPE=Debug# Create Virtual Environmentmakevenv_create# Activate Virtual Environmentmakevenv_activate# Install Conan Package Managermakepip_install_conan# Install Project Dependenciesmakeconan_install# Create CMake Projectmakecmake_project# Open Generated Project in Default IDEmakecmake_open# List of CMake Build Targetsmakehelp# Build Specific CMake TargetmaketargetCMAKE_BUILD_TARGET=<target># Build Projectmakebuild# Test Projectmaketest# Create Code Coverage Reportmakecoverage# Create Package/Installermakepackage# Create New Conan Package Recipemakerecipe_create# Create Conan Test Packagemakeconan_package_test# Create Conan Packagemakeconan_package# Start Local Conan Repository Servermakeconan_start_local# Add Local Conan Repository Server to Remote Listmakeconan_add_local# Upload Conan Test Package to Local Conan Repository Servermakeconan_upload_local_test# Upload Conan Package to Local Conan Repository Servermakeconan_upload_local# Generate Source Code DocumentationmakedoxygenRemove Steps# Remove Source Code Documentationmakedoxygen_delete# Remove Conan Package from Local Conan Repository Servermakeconan_remove_local# Remove Conan Package from Cachemakeconan_remove_cache# Clean Projectmakeclean# Delete Whole Build Foldermakedelete# Deactivate Virtual Environmentmakevenv_deactivate# Delete Whole Virtual Environmentmakevenv_deleteSupport Google Testhttps://github.com/google/googletesthttps://raymii.org/s/tutorials/Cpp_project_setup_with_cmake_and_unit_tests.htmlhttps://gitlab.kitware.com/cmake/community/-/wikis/doc/ctest/Testing-With-CTest# conanfile.txt[build_requires]gtest/1.10.0# CMakeLists.txt (root project)enable_testing()...add_subdirectory(${SUB_PROJECT_PATH})# CMakeLists.txt (subdirectory project)enable_testing()set(TEST_EXE${PROJECT_NAME}.test)set(TEST_SRC_FILES${PROJECT_NAME}.test.cpp)add_executable(${TEST_EXE}${TEST_SRC_FILES})conan_target_link_libraries(${TEST_EXE})add_test(NAME${TEST_EXE}COMMAND${TEST_EXE})Run CMake Tests by CTesthttps://cmake.org/cmake/help/latest/manual/ctest.1.htmlcd{CMAKE_BUILD_TYPE}&&ctest-C{CMAKE_BUILD_TYPE}Generate Unit Test Code Coverage Report by gcov and lcovhttps://jhbell.com/using-cmake-and-gcovhttps://github.com/jhbell/cmake-gcovhttps://dr-kino.github.io/2019/12/22/test-coverage-using-gtest-gcov-and-lcov/https://github.com/dr-kino/BraveCoveragehttps://stackoverflow.com/questions/37978016/cmake-gcov-c-creating-wrong-gcno-fileshttps://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmakehttps://stackoverflow.com/questions/13116488/detailed-guide-on-using-gcov-with-cmake-cdashhttps://medium.com/@naveen.maltesh/generating-code-coverage-report-using-gnu-gcov-lcov-ee54a4de3f11http://ltp.sourceforge.net/coverage/lcov.php# Generate gcov info file with g++ compiler flags "-fprofile-arcs -ftest-coverage" or simply "--coverage"g++-omain-fprofile-arcs-ftest-coveragemain_test.cpp-L/usr/lib-I/usr/include
g++-omain--coveragemain_test.cpp-L/usr/lib-I/usr/include# Generate gcov data file from generated gcov info filegcov-b${CMAKE_CURRENT_SOURCE_DIR}/*.cpp-o${GCOV_OBJECT_DIR}lcov--capture--directory${GCOV_OBJECT_DIR}--output-filecoverage.info
genhtmlcoverage.info--output-directory.Generate Unit Test Code Coverage Report by gcovrhttps://gcovr.com/en/stable/guide.htmlhttps://github.com/gcovr/gcovr# Compile and generate binary object files with debug info and coverage info without optimizationg++--coverage-g-O0-omainmain_test.cpp-L/usr/lib-I/usr/include# Install gcovrsource.venv/bin/activate
pipinstall-Ugcovr# Generate coverage report by gcovr (tabular report on console)gcovr-r${CMAKE_CURRENT_SOURCE_DIR}--object-directory${CMAKE_CURRENT_BINARY_DIR}# Generate coverage report by gcovr (text file output)gcovr-r${CMAKE_CURRENT_SOURCE_DIR}--object-directory${CMAKE_CURRENT_BINARY_DIR}-ogcov_report.txt# Generate coverage report by gcovr (html file output)gcovr-r${CMAKE_CURRENT_SOURCE_DIR}--object-directory${CMAKE_CURRENT_BINARY_DIR}--html-detailsgcov_report.htmlGenerate Unit Test Code Coverage Report by OpenCppCoverage for Windowshttps://github.com/OpenCppCoverage/OpenCppCoverage# Generate coverage report by OpenCppCoverageOpenCppCoverage.exe--sources"${NATIVE_CURRENT_SOURCE_DIR}"--"${NATIVE_UNIT_TEST_EXE_PATH}"--working_dir"${NATIVE_UNIT_TEST_EXE_DIR}"--export_typehtml:"${NATIVE_COVERAGE_TARGET_DIR}"Generate Source Code Documentation by Doxygenhttps://www.doxygen.nl/manual/starting.htmlhttps://github.com/doxygen/doxygen# conanfile.txt[build_requires]doxygen/1.8.20# Generate Doxygen Config Filedoxygen-g# Generate Source Code DocumentationdoxygenView Test Coverage Report or Doxygen Documentation by Five Server Visual Studio Code Extensionhttps://marketplace.visualstudio.com/items?itemName=yandeu.five-serverRight-Click a File in the Explorer > Open with Five ServerExample Test Coverage Report Path:Debug/cpp_project_framework/coverage/CoverageReport-2020-01-01-01h01m01s/CoverageReport.htmlExample Doxygen Documentation Path:doxygen/html/index.htmlPreferred Doxygen Documentation RulesOverall styles: C++ style /// > Javadoc style /**/, (Qt style /! */ or //! not preferred)File documentation: Javadoc style/*** @file    cpp_project_framework.h* @author  Curtis Lo* @brief   This file is just a dummy header file*/Single line brief description: C++ style/// Get the test case name of current test case#define GET_TEST_CASE_NAME() ((test_info_->test_suite_name() + std::string(".") + test_info_->name()).c_str())Brief description with other documenation: C++ style with @brief command/// @brief Execute the code block with scoped trace/// @param code code to be executed with scoped trace#define SCOPED_TRACE_CODE_BLOCK(code) { SCOPED_TRACE(GET_TEST_CASE_NAME()); code; }Brief description after member: C++ stylestd::map<std::string/* name */,ObjectPtr>objects;///< objects to be managedParemeter inline documentation: Javadoc stylevirtualObjectPtrGet(conststd::string&name/**< [in] name of the object */)Brief description for variablesBrief description sentence for variables must start with lowercase wordstd::map<std::string/* name */,ObjectPtr>objects;///< objects to be managedvirtualObjectPtrGet(conststd::string&name/**< [in] name of the object */)Brief description for files, classes, functions, methodsBrief description sentence for files, classes, functions, methods, macro functions must start with captalized word/*** @file    cpp_project_framework.h* @author  Curtis Lo* @brief   This file is just a dummy header file*//// Get the test case name of current test case#define GET_TEST_CASE_NAME() ((test_info_->test_suite_name() + std::string(".") + test_info_->name()).c_str())Preferred C++ Programming StylesGoogle C++ Style Guidehttps://google.github.io/styleguide/cppguide.htmlGROMACS Style Guidehttp://manual.gromacs.org/current/dev-manual/style.htmlISO C++ Coding Standardshttps://isocpp.org/wiki/faq/coding-standardsC++ Naming StylesC++ General Naming RulesFor the purposes of the naming rules below, a "word" is anything that you would write in English without internal spaces. This includes abbreviations, such as acronyms and initialisms. For names written in mixed case (also sometimes referred to as "camel case" or "Pascal case"), in which the first letter of each word is capitalized, prefer to capitalize abbreviations as single words, e.g., StartRpc() rather than StartRPC(), Id rather than ID, UtcTimestamp rather than UTCTimestamp.C++ Variable Names (all kinds of variables including but not limited to followings: global, local, const, static, member, parameters)The names of variables (including function parameters) and data members are all lowercase, with underscores between words, i.e. snake case => snake_caseFor simplicity and easy memorization of the naming rule, prefix or suffix should not be added to the variable names for different type of variables. For examples, the followings naming styles are not preferred: leading "k" in constant variables, prefix "g_" in global variables, trailing underscore in data member variables. This also makes easier to move variables to different scopes without renaming them.C++ Type Names (all kinds of types including but not limited to followings: struct, class, enum, typedef, using alias)Type names start with a capital letter and have a capital letter for each new word, with no underscores, i.e. camel case => CamelCaseC++ Function Names (function and member method)Function names start with a capital letter and have a capital letter for each new word, with no underscores, i.e. camel case => CamelCaseC++ Namespace Names (namespace)The names of namespaces are all lowercase, with underscores between words, i.e. snake case => snake_caseC++ Macro Names (#define, including but not limited to followings: macro constant, macro function)Macros should not be used. However, if they are absolutely needed, then they should be named with all capitals and underscores, i.e. macro case => MACRO_CASEC++ Enumerator Member Names (enum member)The names of enumerator members are all lowercase, with underscores between words, i.e. snake case => snake_caseC++ Main File Name (file containing the main() entry function)Main file name must have the same name as the final program binary name which should be all lowercase, with underscores between words, i.e. snake case => snake_caseC++ Class File Names (file containing a single class declaration and/or definition)Class file names must have the same name as the single class name it contains which should start with a capital letter and have a capital letter for each new word, with no underscores, i.e. camel case => CamelCaseC++ Template Parameter NamesTemplate parameters should follow the naming style for their category: type template parameters should follow the rules for type names, and non-type template parameters should follow the rules for variable names.C++ Unit Test Test Suite NamesUnit test test suite names must follow the nameing convention of type/class names with "Test" as postfix, i.e. camel case => CamelCaseTestC++ Unit Test Test Case NamesUnit test test case names must follow the nameing convention of function names, i.e. camel case => CamelCaseC++ Benchmark Function NamesBenchmark Function names must follow the nameing convention of function names with "Benchmark" as postfix, i.e. camel case => CamelCaseBenchmarkC++ Code Formatting StylesC++ IndentationUse 4 spaces at a time for indentation. Do not use tabs in code. You should set your editor to emit spaces when you hit the tab key.C++ CommentsOffset by exactly 1 space from the comment mark (e.g. //, /// or /*)./// Structure representing a UTC datestructUtcDateC++ Alignment of CommentsOffset by exactly 1 space from the end of longest line to be aligned.constexpruint32_tutc_date_null_value=UINT32_MAX;///< null value for UtcDateconstexpruint16_tyear_null_value=UINT16_MAX;///< null value for yearconstexpruint8_tmonth_null_value=UINT8_MAX;///< null value for monthconstexpruint8_tday_null_value=UINT8_MAX;///< null value for dayC++ Integer LiteralInteger literalhttps://en.cppreference.com/w/cpp/language/integer_literalFundamental typeshttps://en.cppreference.com/w/cpp/language/typesSigned 8-bit integer (int8_t or char): 0 (no suffix)
Unsigned 8-bit integer (uint8_t or unsigned char): 0U (suffix with U)
Signed 16-bit integer (int16_t or short): 0 (no suffix)
Unsigned 16-bit integer (uint16_t or unsigned short): 0U (suffix with U)
Signed 32-bit integer (int32_t or long): 0L (suffix with L)
Unsigned 32-bit integer (uint32_t or unsigned long): 0UL (suffix with UL)
Signed 64-bit integer (int64_t or long long): 0LL (suffix with LL)
Unsigned 64-bit integer (uint64_t or unsigned long long): 0ULL (suffix with ULL)C++ Include Header OrderingGoogle C++ Style Guide: Names and Order of Includeshttps://google.github.io/styleguide/cppguide.html#Names_and_Order_of_IncludesInclude header ordering should follow above "Google C++ Style Guide: Names and Order of Includes".
Except "All of a project's header files should be listed as descendants of the project's source directory without use of UNIX directory aliases . (the current directory) or .. (the parent directory)." as its useful for identifying same project headers.Include headers in the following order: Related header, C system headers, C++ standard library headers, other libraries' headers, your project's headers.
Separate each non-empty group with one blank line.
Within each section the includes should be ordered alphabetically.C system headers (e.g. <stdlib.h>) and C++ standard library headers (e.g. <cstdlib>) must be enclosed by angle brackets
Other headers (e.g. "boost/asio.hpp") must be enclosed by double quotesIn dir/foo.cc or dir/foo_test.cc, whose main purpose is to implement or test the stuff in dir2/foo2.h, order your includes as follows:dir2/foo2.h.
A blank line
C system headers (more precisely: headers in angle brackets with the .h extension), e.g., <unistd.h>, <stdlib.h>.
A blank line
C++ standard library headers (without file extension), e.g., <algorithm>, <cstddef>.
A blank line
Other libraries' .h files.
A blank line
Your project's .h files.For example, the includes in google-awesome-project/src/foo/internal/fooserver.cc might look like this:#include"foo/server/fooserver.h"#include<sys/types.h>#include<unistd.h>#include<string>#include<vector>#include"base/basictypes.h"#include"base/commandlineflags.h"#include"foo/server/bar.h"Support Microbenchmark Performance TestMicro benchmarking libraries for C++https://www.bfilipek.com/2016/01/micro-benchmarking-libraries-for-c.htmlGoogle Benchmarkhttps://github.com/google/benchmarksltbenchhttps://github.com/ivafanas/sltbenchSkyPathttps://github.com/skymizer/SkyPat# conanfile.txt[build_requires]benchmark/1.5.1Use Git SubmodulesGit Tools - Submoduleshttps://www.git-scm.com/book/en/v2/Git-Tools-Submodulesgit-submodule - Initialize, update or inspect submoduleshttps://git-scm.com/docs/git-submodulegitsubmoduleadd<repositoryurl>[<submodulename>]List GCC Default Include and Library PathsLibrary path in gcc:https://transang.me/library-path-in-gcc/List GCC Default Include PathsWhat are the GCC default include directories?:https://stackoverflow.com/questions/4980819/what-are-the-gcc-default-include-directoriesecho|gcc-xc++-E-Wp,-v-2>&1|grep'^[[:space:]]*/'|sed's/^[[:space:]]*//'List GCC Default Library PathsHow to print the ld(linker) search path:https://stackoverflow.com/questions/9922949/how-to-print-the-ldlinker-search-pathgcc-print-search-dirs|sed'/^lib/b 1;d;:1;s,/[^/.][^/]*/\.\./,/,;t 1;s,:[^=]*=,:;,;s,;,;  ,g'|tr\;\\012|tr:\\012|grep'^[[:space:]]*/'|sed's/^[[:space:]]*//'Bash Auto Completion of Makefile Targetsbash completion of makefile target:https://stackoverflow.com/questions/4188324/bash-completion-of-makefile-targetHow to add bash auto completion in Ubuntu Linux:https://www.cyberciti.biz/faq/add-bash-auto-completion-in-ubuntu-linux/Add below line to~/.bashrcfile to enable auto completion of CMake build targets usingbash-completionLinux package:complete-W"\`make help 2>/dev/null | grep -oE '^\.\.\. [a-zA-Z0-9_.-]+' | sed 's/\.\.\. //'\`"cmakeAdd below line to~/.bashrcfile to enable auto completion of Makefile targets usingbash-completionLinux package:complete-W"\`grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' ?akefile | sed 's/[^a-zA-Z0-9_.-]*$//'\`"makeAdd below line instead of above one to~/.bashrcfile to enable auto completion of Makefile targets with CMake build targets usingbash-completionLinux package:complete-W"\`grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' ?akefile | sed 's/[^a-zA-Z0-9_.-]*$//'\` \`make help 2>/dev/null | grep -oE '^\.\.\. [a-zA-Z0-9_.-]+' | sed 's/\.\.\. /CMAKE_BUILD_TARGET-/'\`"makeSource~/.bashrcfile after making the change to make it take effect:source~/.bashrcInstall JenkinsInstalling Jenkins - WAR files:https://www.jenkins.io/doc/book/installing/war-file/python-c"import os, requests; os.makedirs(os.path.expanduser(r'$(JENKINS_HOME)'), mode=0o755, exist_ok=True); open(os.path.join(os.path.expanduser(r'$(JENKINS_HOME)'), 'jenkins.war'), 'wb').write(requests.get('https://get.jenkins.io/war-stable/latest/jenkins.war', allow_redirects=True).content)"Start Jenkins Web Applicationjava-jar$(JENKINS_HOME)/jenkins.war--httpPort=8080Jenkins Home Folder Location# Linux~/.jenkins# Windows
%USERPROFILE%\.jenkinsContinuous Integration for C++ Projects with JenkinsJenkins - Pipeline:https://www.jenkins.io/doc/book/pipeline/Continuous Integration for C/C++ Projects with Jenkins and Conan:https://www.jenkins.io/blog/2017/07/07/jenkins-conan/Introduction into an Automated C++ Build Setup with Jenkins and CMake:https://thoughts-on-coding.com/2019/03/27/introduction-into-build-automation-setup-with-jenkins-and-cmake/Jenkins - Blue Ocean:https://www.jenkins.io/doc/book/blueocean/Visual Pipeline Creation in Blue Ocean:https://www.youtube.com/watch?v=LzFmTiH8nosGather Test Results with xUnit Plugin for JenkinsJenkins - Recording tests and artifacts:https://www.jenkins.io/doc/pipeline/tour/tests-and-artifacts/xUnit plugin - step([$class: 'XUnitPublisher']): Publish xUnit test result report:https://www.jenkins.io/doc/pipeline/steps/xunit/Jenkins Core - archiveArtifacts: Archive the artifacts:https://www.jenkins.io/doc/pipeline/steps/core/#archiveartifacts-archive-the-artifactsApache Ant - Directory-based Tasks - Patterns:https://ant.apache.org/manual/dirtasks.html#patternsGather CTest Results with xUnit Plugin for JenkinsProducing CTest results in Jenkins (xUnit >= 1.58):https://stackoverflow.com/questions/21633716/producing-ctest-results-in-jenkins-xunit-1-58ctest(1):https://cmake.org/cmake/help/latest/manual/ctest.1.htmlJenkinsfilepipeline{agentanystages{stage('Test'){steps{sh"cd ${env.BUILD_TYPE} && ctest -C ${env.BUILD_TYPE} -T Test --no-compress-output"}post{always{archiveArtifactsartifacts:"${env.BUILD_TYPE}/Testing/**/*.xml",fingerprint:truexunit(thresholds:[skipped(failureThreshold:'0'),failed(failureThreshold:'0')],tools:[CTest(pattern:"${env.BUILD_TYPE}/Testing/**/*.xml",deleteOutputFiles:true,failIfNotNew:false,skipNoTestFiles:true,stopProcessingIfError:true)])}}}}}Gather Google Test Results with xUnit Plugin for JenkinsUsing gtest in jenkins:https://stackoverflow.com/questions/11540633/using-gtest-in-jenkinsAdvanced googletest Topics - Generating an XML Report:https://google.github.io/googletest/advanced.html#generating-an-xml-reportJenkinsfilepipeline{agentanystages{stage('Test'){environment{GTEST_OUTPUT='xml:../gtest/'}steps{sh"cd ${env.BUILD_TYPE} && ctest -C ${env.BUILD_TYPE} -T Test --no-compress-output"}post{always{archiveArtifactsartifacts:"${env.BUILD_TYPE}/gtest/**/*.xml",fingerprint:truexunit(thresholds:[skipped(failureThreshold:'0'),failed(failureThreshold:'0')],tools:[GoogleTest(pattern:"${env.BUILD_TYPE}/gtest/**/*.xml",deleteOutputFiles:true,failIfNotNew:false,skipNoTestFiles:true,stopProcessingIfError:true)])}}}}}Cross Platform Pipeline Support in JenkinsConditionals in a Declarative Pipeline Jenkinsfile:https://michakutz.medium.com/conditionals-in-a-declarative-pipeline-jenkinsfile-d1a4a44e93bbScripted Pipeline - Flow Control:https://www.jenkins.io/doc/book/pipeline/syntax/#flow-controlHow to determine the current operating system in a Jenkins pipeline:https://stackoverflow.com/questions/44105814/how-to-determine-the-current-operating-system-in-a-jenkins-pipelineisUnix: Checks if running on a Unix-like node:https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#isunix-checks-if-running-on-a-unix-like-nodeJenkinsfilepipeline{agentanystages{stage('Test'){environment{GTEST_OUTPUT='xml:../gtest/'}parallel{stage('Unix'){when{expression{isUnix()}}steps{sh"cd ${env.BUILD_TYPE} && ctest -C ${env.BUILD_TYPE} -T Test --no-compress-output"}}stage('Windows'){when{expression{!isUnix()}}steps{bat"""make venv_activatecd ${env.BUILD_TYPE} && ctest -C ${env.BUILD_TYPE} -T Test --no-compress-output"""}}}}}}Dynamic Stage Name Support in JenkinsStage name must be a string literal - Solution:https://issues.jenkins.io/browse/JENKINS-43820?focusedCommentId=397048&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-397048pipeline{agentanystages{stage('Init'){steps{script{env.BUILD_TYPE=inputmessage:'Set parameters:',parameters:[choice(name:'BUILD_TYPE',choices:['Debug','Release','MinSizeRel','RelWithDebInfo'],description:'Build Type')]parallel("${env.BUILD_TYPE}":{stage('Build Type'){echo"Build Type: ${env.BUILD_TYPE}"}})}}}}}Run Multiple Configurations in Parallel using Declarative Pipeline Matrix in JenkinsWelcome to the Matrix:https://www.jenkins.io/blog/2019/11/22/welcome-to-the-matrix/Specifying a matrix of one or more dimensions:https://docs.cloudbees.com/docs/admin-resources/latest/pipelines/matrixPipeline Syntax - when:https://www.jenkins.io/doc/book/pipeline/syntax/#whenpipeline{agentnonestages{stage('Pipeline'){matrix{when{allOf{anyOf{expression{env.BUILD_AGENT_FILTER=='All'}expression{env.BUILD_AGENT_FILTER==env.BUILD_AGENT}}anyOf{expression{env.BUILD_TYPE_FILTER=='All'}expression{env.BUILD_TYPE_FILTER==env.BUILD_TYPE}allOf{expression{env.BUILD_TYPE_FILTER=='Debug and Release'}anyOf{expression{env.BUILD_TYPE=='Debug'}expression{env.BUILD_TYPE=='Release'}}}not{allOf{expression{env.BUILD_TYPE_FILTER=='All'}expression{env.BUILD_TYPE=='Any'}}}}}axes{axis{name'BUILD_AGENT'values'Any','Linux','Windows','Docker'}axis{name'BUILD_TYPE'values'Debug','Release','MinSizeRel','RelWithDebInfo'}}stages{stage('Check'){options{timeout(time:5,unit:'SECONDS')}agent{node{labelenv.BUILD_AGENT=='Any'?'':env.BUILD_AGENTcustomWorkspace"${env.JOB_NAME}/${env.BUILD_AGENT}/${env.BUILD_TYPE}"}}steps{echo"Build Agent: ${env.BUILD_AGENT}"echo"Build Type: ${env.BUILD_TYPE}"echo"Build Workspace: ${env.JOB_NAME}/${env.BUILD_AGENT}/${env.BUILD_TYPE}"}}}}}}}Trigger Jenkins Parameterized Build Using APIJenkins : Parameterized Build:https://wiki.jenkins.io/display/JENKINS/Parameterized+BuildHow to remotely trigger Jenkins multibranch pipeline project build?:https://stackoverflow.com/questions/39490150/how-to-remotely-trigger-jenkins-multibranch-pipeline-project-buildjenkins rest api returns 400 nothing is submitted:https://stackoverflow.com/questions/52101155/jenkins-rest-api-returns-400-nothing-is-submittedAdd New User API TokenDashboard > Manage Jenkins > Manager Users > <user_name> > Configure > API Token > Add new TokenParameterized Build HTTP Post Requestcurl--location--requestPOST'http://localhost:18080/job/cpp_project_framework/job/master/buildWithParameters?BUILD_AGENT=Any&BUILD_TYPE=Debug&ENABLE_DEPLOY_STAGE=true'--user<user_name>:<api_token>Publish HTML Report (Coverage, Doxygen) in JenkinsHTML Publisher:https://plugins.jenkins.io/htmlpublisher/Declarative Pipeline: Publishing HTML Reports:https://www.jenkins.io/blog/2017/02/10/declarative-html-publisher/post{success{archiveArtifactsartifacts:"doxygen/",fingerprint:truepublishHTMLtarget:[allowMissing:false,alwaysLinkToLastBuild:false,keepAll:true,reportDir:'doxygen/html/',reportFiles:'index.html',reportName:'Doxygen']}}Start Jenkins Web Application with No Content Security Policy (CSP)Configuring Content Security Policy:https://www.jenkins.io/doc/book/security/configuring-content-security-policy/Jenkins - HTML Publisher Plugin - No CSS is displayed when report is viewed in Jenkins Server:https://stackoverflow.com/questions/35783964/jenkins-html-publisher-plugin-no-css-is-displayed-when-report-is-viewed-in-jRun Jenkins with no CSP header value to allow JavaScript and CSS (for HTML Publisher Plugin):java-Dhudson.model.DirectoryBrowserSupport.CSP=-jar$(JENKINS_HOME)/jenkins.war--httpPort=8080