GithubHelp home page GithubHelp logo

cpp-best-practices / cmake_conan_boilerplate_template Goto Github PK

View Code? Open in Web Editor NEW
176.0 5.0 37.0 739 KB

Minimized version of cpp_starter_project

License: The Unlicense

Dockerfile 25.75% CMake 53.59% Shell 6.65% C++ 14.01%

cmake_conan_boilerplate_template's Introduction

NOTE: This Project Is Archived

All efforts to maintain "Best Practices" CMake templates are being merged into https://github.com/cpp-best-practices/cmake_template

Important the new cmake_template is simplified in many ways to make it more maintainable, and the goal will be to always keep it simple.

cmake_conan_boilerplate_template

ci codecov Language grade: C++ CodeQL

About cmake_conan_boilerplate_template

This is a C++ Best Practices GitHub template for getting up and running with C++ quickly.

By default (collectively known as ENABLE_DEVELOPER_MODE)

  • Address Sanitizer and Undefined Behavior Sanitizer enabled where possible
  • Warnings as errors
  • clang-tidy and cppcheck static analysis
  • conan for dependencies

It includes

  • a basic CLI example
  • examples for fuzz, unit, and constexpr testing
  • large github action testing matrix

It requires

  • cmake
  • conan
  • a compiler

If you want a more complex example project, check out the cpp_starter_project.

Ths Boilerplate project will merge new features first, then they will be merged (as appropriate) into cpp_starter_project.

Getting Started

Use the Github template

First, click the green Use this template button near the top of this page. This will take you to Github's 'Generate Repository' page. Fill in a repository name and short description, and click 'Create repository from template'. This will allow you to create a new repository in your Github account, prepopulated with the contents of this project.

After creating the project please wait until the cleanup workflow has finished setting up your project and commited the changes.

Now you can clone the project locally and get to work!

git clone https://github.com/<user>/<your_new_repo>.git

More Details

Testing

See Catch2 tutorial

Fuzz testing

See libFuzzer Tutorial

cmake_conan_boilerplate_template's People

Contributors

adrian5 avatar aidan-gallagher avatar aminya avatar arnemertz avatar avitase avatar caellian avatar clausklein avatar ddalcino avatar developerpaul123 avatar dk949 avatar hadrabap avatar jason5480 avatar jmarrec avatar krzmaz avatar lectem avatar lefticus avatar lesleylai avatar ltdsauce avatar madduci avatar mathewbenson avatar michael137 avatar mo-xiaoming avatar novasmoof avatar patrickelectric avatar paulbendixen avatar ralphsteinhagen avatar saimen avatar toppdev avatar valerioformato avatar vittorioromeo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cmake_conan_boilerplate_template's Issues

FuzzTest does not notice UB in given example?

The FuzzTest example provided with this project is concerned with undefined behavior due to signed integer overflow. I ran the example and got several overflows ("negative sums") but no warning or error as a result.

Should the fuzzer be able to detect this case of UB? If yes, how should one run it to make sure it does (are the newest versions required, or similar)? If no, perhaps a different fuzzing example might be more instructive?

clang-tidy version should be fixed

The version of clang-tidy should be specified in ci.yml to prevent it from changing. For example, clangtidy: 13.0.0 instead of clangtidy: true

To prevent it from being clobbered by the compiler setup, it should be the same as the clang/LLVM version.

[Feature Request] add clean-up action that triggers when template is used

Hi!

Last year i used a Kotlin project template from Jetbrains for the Advent of Code. It had a nice feature:
After creating my project from the template it automatically committed a clean-up change, that exchanged the template readme with a readme that was more tailored for the project.

Are there any plans to add such thing to this project template? Here is the workflow they used in their project template on github.

Some things are always bothering me, when i setup my project through the template:

Static changes

Following things i can think of that always have to change:

  • All Badges from the README.md are broken as they point to the project template --> that should be easily fixed with the workflow --> Fixed in #3
  • The README.md contains sections that are no longer needed when the template was created --> Fixed in #3
  • Rename the "MyProject" to the name of the new github repository --> Fixed in #3

Dynamic/User changes

Following things could be changed sometimes according to what the user wants. Those are probably not easy, maybe impossible to do:

  • Removing the unwanted examples or dependencies is sometimes anoying because removing one example cannot be done from github directly without branching or multiple commits --> Deprecated because of new template project

  • For private projects i'm sometimes not interested in MacOS. Maybe it is possible to disable one or many of the CI Matrix entries? --> not sure if this is sensibel to do

Apply for help

If this has any chances of beeing excepted i could invest some time in creating the worklfow for at least "fixing" the links of the build badges?

`-` in project name breaks the template janitor

Because the project name is used in C++ code, this becomes converted to an invalid identifier in the namespace project-name::value is not valid C++.

We should try to see if we can fix-up - to _ at template janitor time.

Re: @LtdSauce

Update this template on an existing project

Hello, I was wondering how someone that used this template to create his own project can benefit from the development of this template in the long run. For example, given that this template will handle most of the devops functionalities I would like to update/rebase my existing project one year after its creation, taking advantage of all the nifty updates that have been introduced since then. So, one solution I came up with is that this could be a submodule on the actual repository that can be updated on demand. However, I am not sure if this can work with the CI that needs a specific folder structure. Another approach would be to package the required files and modify them accordingly using a package manager like vcpkg or conan that can also leverage the python utils. I would prefer the first approach since there is no standardized package management in cpp. Any thoughts on that?

cmake presets are not usable (at leased on OSX)

bash-3.2$ cmake --preset=unixlike-gcc-release
Preset CMake variables:

  CMAKE_BUILD_TYPE="RelWithDebInfo"
  CMAKE_CXX_COMPILER="g++"
  CMAKE_C_COMPILER="gcc"
  CMAKE_INSTALL_PREFIX:PATH="/Users/clausklein/Workspace/cpp/cpp_boilerplate_project/out/install/unixlike-gcc-release"

-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- The C compiler identification is AppleClang 13.1.6.13160021
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Developer mode is ON. For production, use `-DENABLE_DEVELOPER_MODE:BOOL=OFF`. Building the project for the developer...
-- The default CMAKE_C_STANDARD used by external targets and tools is not set yet. Using the latest supported C standard that is 17
-- /usr/local/bin/ccache found and enabled
-- Downloading conan.cmake from https://github.com/conan-io/cmake-conan
-- Conan: Adding cci remote repository (https://center.conan.io) verify ssl (True)
-- Conan: Adding bincrafters remote repository (https://bincrafters.jfrog.io/artifactory/api/conan/public-conan) verify ssl (True)
-- Single configuration build!
-- Running Conan for build type 'RelWithDebInfo'
-- Conan: checking conan executable
-- Conan: Found program /usr/local/bin/conan
-- Conan: Version found Conan version 1.47.0
-- Conan executing: /usr/local/bin/conan install /Users/clausklein/Workspace/cpp/cpp_boilerplate_project --build missing --env CC=/usr/bin/gcc --env CXX=/usr/bin/g++ --settings build_type=RelWithDebInfo --settings compiler=apple-clang --settings compiler.version=13.1 --settings compiler.libcxx=libc++ --settings compiler.cppstd=20
-- Dependency fmt already found
-- Library docopt found /Users/clausklein/.conan/data/docopt.cpp/0.6.3/_/_/package/5daf637a62aba772e1702099bde4503471cf3546/lib/libdocopt.dylib
-- Found: /Users/clausklein/.conan/data/docopt.cpp/0.6.3/_/_/package/5daf637a62aba772e1702099bde4503471cf3546/lib/libdocopt.dylib
-- Library docopt found /Users/clausklein/.conan/data/docopt.cpp/0.6.3/_/_/package/5daf637a62aba772e1702099bde4503471cf3546/lib/libdocopt.dylib
-- Found: /Users/clausklein/.conan/data/docopt.cpp/0.6.3/_/_/package/5daf637a62aba772e1702099bde4503471cf3546/lib/libdocopt.dylib
CMake Warning (dev) at CMakeLists.txt:129 (message):
  Building Tests.  Be sure to check out test/constexpr_tests.cpp for
  constexpr testing
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/clausklein/Workspace/cpp/cpp_boilerplate_project/out/build/unixlike-gcc-release
bash-3.2$ cmake --build --preset=unixlike-gcc-release
CMake Error: No such build preset in /Users/clausklein/Workspace/cpp/cpp_boilerplate_project: "unixlike-gcc-release"
########################################################################################

bash-3.2$ ctest --build --preset=unixlike-gcc-release
CMake Error: No such test preset in /Users/clausklein/Workspace/cpp/cpp_boilerplate_project: "unixlike-gcc-release"
Available test presets:

  "test-windows-msvc-debug-developer-mode"   - Strict
  "test-windows-msvc-release-developer-mode" - Strict
  "test-windows-clang-debug"                 - Strict
  "test-windows-clang-release"               - Strict
  "test-unixlike-gcc-debug"                  - Strict
  "test-unixlike-gcc-release"                - Strict
  "test-unixlike-clang-debug"                - Strict
  "test-unixlike-clang-release"              - Strict
bash-3.2$ 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.