GithubHelp home page GithubHelp logo

yggdrasil_demo's Introduction

Yggdrasil Demo

Yggdrasil is a C++ oriented cmake-based build infrastructure adapted from https://github.com/yandex/balancer. This project is an usage example of Yggdrasil.

Quick Guide

For using Yggdrasil in your C++ repository you need to add the main Yggdrasil repo as a submodule (or just put the code into the subdirectory yggdrasil) and create a very simple root CMakeLists.txt (example). ROOT_PROJECTS specify a list of projects that will be built by default (without specifying BUILD_ONLY).

In most cases you will need only three basic templates: for executable programs, static/dynamic libraries and for specifying subprojects in subdirectories. Here is a basic template for executable targets:

PROGRAM()

# specify all project .cpp files here
SRCS (
    a.cpp
    b.cpp
    c.cu # Yggdrasil supports CUDA
    main.cpp
)

# dependencies
PEERDIR (
    libs/x
    libs/y
    
    # add ADDINCL if you don't want to build a library
    #    (only modify include paths)
    ADDINCL libs/z
)

END()

Static library template is very similar to PROGRAM (see library/sum/CMakeLists.txt):

LIBRARY()

SRCS (
    ...
)

PEERDIR (
    ...
)

END()

And if you just want to list subprojects: (see library/CMakeLists.txt)

RECURSE (
    subprojects
)

local.cmake

You can create the local.cmake file in the build directory to control generation process using predefined options. For example:

SET(MY_GCC gcc-5.0)
SET(MY_GPP g++-5.0)
SET(USE_STATIC_CPP_RUNTIME no)
ENABLE(NOSSE)

Quick Examples

Build and run unit tests from library/x:

$ cmake -DUT_PERDIR ../
$ make library-x_ut
$ bin/library-x_ut

Release build (default is Debug):

$ cmake -DCMAKE_BUILD_TYPE=Release ../

Build only the project projects/xproj

$ cmake -DCMAKE_BUILD_ONLY=projects/xproj ../

CUDA

See projects/cudatest

Unit Testing

For each project Yggdrasil automatically discovers all files with the _ut.cpp prefix and creates a special executable target from these files and gtest/src/gtest_main.cc (see ut_template.cmake).

Here is an example of code for testing our outstanding summation library:

#include "sum.h"

#include <yggdrasil/contrib/gtest/include/gtest/gtest.h>


TEST(TestSum, MyTestSum) {
    EXPECT_EQ(sum(3, 2), 5);
}
$ cd build
$ cmake -DUT_PERDIR=yes ../
$ make library-sum_ut

yggdrasil_demo's People

Watchers

Dmitry Kuznetsov avatar James Cloos 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.