Coder Social home page Coder Social logo

harrisonkaiser / cmake-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gokhanettin/cmake-example

0.0 0.0 0.0 72 KB

A simple yet effective CMake example for large scale projects

License: MIT License

C++ 51.81% C 2.09% CMake 46.10%

cmake-example's Introduction

CMake Example

An example cmake project to demonstrate relations between cmake targets.

We have libraries for sum, multiplication, factorial, and substraction. The multiplcation library uses the sum library to implement multiplication operation. The factorial library uses the multiplication library to compute the factorial of a given integer. CMake regulates the relations between these libraries without exposing more than their public interfaces. For example, the factorial library doesn't know about the implementation details of the multiplication library. If we change the the multiplication library to simply use multiplication operator rather than utilizing the sum library, the factorial library doesn't need any change at all. Each of these libraries are also tested using GTest. GTest dependency is managed by conan, C/C++ package manager. We have two client applications, app1 and app2. These applications use our highly-modular, reusable, well-tested libraries.

As a summary, we divide each functional component into a library. We define interfaces for these libraries in their header files. As we implement these interfaces, we either write unit tests or alternatively, go for Test Driven Development. We can also start writing applications when the library interfaces reach to a certain level of stabilization. If applications are simple CLI apps, CTest is enough to test their outputs with specified inputs. Otherwise, they may require different integration testing strategies.

graph

Build

Assuming you have cmake and conan installed, run the following commands.

mkdir build
cd build
conan install ..
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON ..
cmake --build ..

Test

ctest --verbose

Run

./bin/app1
./bin/app2

cmake-example's People

Contributors

gokhanettin avatar

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.