ModernCppCI
This is an example of doing a Modern C++ project with CI
Install / Use
/learn @LearningByExample/ModernCppCIREADME
Modern C++ Continuous Integration
This project is illustrating this blog post.
| Build status | Systems / Compilers |
| ------------- | ------------------------------------------ |
| | Linux (clang38 / gcc6) OSX (XCode 8.3 clang) |
|
| Windows (Visual Studio 2017 / 2015) |
info
This is an example of doing a Modern C++ project with CI.
It use basic C++14 syntax, but nothing really complicated.
This project try to follow C++ Core Guidelines whenever its possible.
CMake is the chosen build system using ctest.
libraries used
project structure
| folder | Content | | ------------ | -------------------- | | /lib | library | | /lib/src | library sources | | /lib/include | library includes | | /lib/test | library test | | /app | application | | /app/src | application sources | | /app/test | application test | | /third_party | third party software |
Generate project
cmake -H. -BBuild
Auto detect everything.
If you like to set a implicit compiler set the variable CXX=${COMPILER}, for example COMPILER could be gcc, clang and so on.
Auto detect in Windows usually generate a Visual Studio project since msbuild require it, but in OSX does not generate and XCode project, since is not required for compiling using XCode clang.
Specify build type debug/release
# generate a debug project
cmake -H. -BBuild -DCMAKE_BUILD_TYPE=Debug
# generate a release project
cmake -H. -BBuild -DCMAKE_BUILD_TYPE=Release
Specify architecture
# 64 bits architecture
cmake -H. -BBuild -Ax64
# ARM architecture
cmake -H. -BBuild -AARM
# Windows 32 bits architecture
cmake -H. -BBuild -AxWin32
Generate different project types
# MinGW makefiles
cmake -H. -BBuild -G "MinGW Makefiles"
# XCode project
cmake -H. -BBuild -G "XCode"
# Visual Studio 15 2017 solution
cmake -H. -BBuild -G "Visual Studio 15 2017"
Build
From the Build folder
# build the default build type (in multi build types usually debug)
cmake --build .
# build a specific build type
cmake --build . --config Release
Run tests
From the Build folder
# run all test using the default build type
ctest -V
# run all test in Release build type
ctest -V -C Release
references
- https://cmake.org/
- https://docs.travis-ci.com/user/languages/cpp/
- https://www.appveyor.com/docs/lang/cpp/
- https://github.com/isocpp/CppCoreGuidelines
- https://github.com/philsquared/Catch
- https://github.com/gabime/spdlog
- https://github.com/cognitivewaves/CMake-VisualStudio-Example
- http://derekmolloy.ie/hello-world-introductions-to-cmake/
- https://cmake.org/Wiki/CMake/Testing_With_CTest
- https://www.appveyor.com/docs/lang/cpp/
- https://docs.travis-ci.com/user/languages/cpp/
- https://github.com/philsquared/Catch/blob/master/docs/build-systems.md
- https://stackoverflow.com/questions/14446495/cmake-project-structure-with-unit-tests
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
