Giter VIP home page Giter VIP logo

seqan-cmake-tutorials's Introduction

PREFACE

This tutorial was written for a course named PMBS (summer 2016) for bachelor students at the Free University Berlin. In this tutorial session (2h) we looked at, what cmake is, what it does and how you use it to incoperate our library SeqAn into your own project.

Since this information is already two years old, it might be at some points out-dated, but should be in general usable as a reference.

For an up-to-date user-guide for cmake, see our docs: http://seqan.readthedocs.io/en/master/Infrastructure/Use/FindSeqAnCMake.html


seqan cmake tutorial

preliminaries

check if you have cmake installed by

cmake --version

will deliver

cmake version 3.0.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

setup tutorial

mkdir ~/tutorials
cd ~/tutorials

01 Hello world with cmake

mkdir ~/tutorials/test_hello_world
cd ~/tutorials/test_hello_world

create hello.cpp

// ~/tutorials/test_hello_world/hello.cpp
#include <iostream>

int main()
{
    std::cout << "Hello World" << std::endl;
    return 0;
}

try to compile and run it

g++ ~/tutorials/test_hello_world/hello.cpp
./a.out
Hello World

How to automate the build process?

We could use Makefiles.

#~/tutorials/test_hello_world/Makefile

all:
	mkdir build
	g++ hello.cpp -o build/hello

clean:
	rm -r build

(notice that the indention must be tabs) and use it

make
mkdir build
g++ hello.cpp -o build/hello

but Makefiles are kinda hard to maintain and to program. (also platform specific)

Using cmake as an abstraction layer

Creating a minimal cmake file.

# ~/tutorials/test_hello_world/CMakeLists.txt

cmake_minimum_required(VERSION 3.0)
project(hello CXX)

# add the executable
add_executable(hello hello.cpp)

Now, we need a build folder to build the library.

mkdir ~/tutorials/build
cd ~/tutorials/build

And now let us build the hello world program.

cmake ../test_hello_world
-- The CXX compiler identification is GNU 4.8.5
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marehr/tutorials/build

This only generated the Makefile, we will build it right now.

make
Scanning dependencies of target hello
[100%] Building CXX object CMakeFiles/hello.dir/hello.cpp.o
Linking CXX executable hello
[100%] Built target hello

Where to find the executable?

ls ~/tutorials/build
[...] hello [...]

executing the file

./hello
Hello World

next

seqan-cmake-tutorials's People

Contributors

marehr avatar

Stargazers

bobo avatar

Watchers

 avatar James Cloos avatar

Forkers

kenrickschulze

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.