Skip to content

Your first build with maker

Alexander Schrab edited this page Feb 4, 2015 · 2 revisions

Start by checking out the maker repo:

git clone git@github.com:meros/cpp-maker.git

This will give you maker, and a test project:

cpp-maker/
├── maker
└── testproject

maker is the maker system, and is normally not edited (unless you want to improve maker itself)

testproject is a test project, it is normal, but not required (it can be configured) for maker and testproject to reside side by side in the same folder.

To run cmake on the testproject, first make sure you have a recent cmake installed and do:

mkdir testproject-build && cd testproject-build
cmake ../testproject

This will give you a default cmake build folder (normally Makefile based with no special project files), you can of course choose the cmake generator that suites your needs best. If this is your first out of source build (running make, building binaries is done in a completely different folder structure than the source) I suggest you take 5 minutes to google the subject. Short story is that it makes a lot of issues go away and makes source control issues much easier in the source tree.

To build:

make
Scanning dependencies of target app_app2
[ 11%] Building CXX object CMakeFiles/app_app2.dir/apps/app2/test.cpp.o
Linking CXX executable app_app2
[ 11%] Built target app_app2
Scanning dependencies of target lib_testlib2
[ 22%] Building CXX object CMakeFiles/lib_testlib2.dir/libs/testlib2/test2.cpp.o
Linking CXX static library liblib_testlib2.a
[ 22%] Built target lib_testlib2
Scanning dependencies of target lib_testlib
[ 33%] Building CXX object CMakeFiles/lib_testlib.dir/libs/testlib/test.cpp.o
Linking CXX static library liblib_testlib.a
[ 33%] Built target lib_testlib
Scanning dependencies of target app_testapp
[ 44%] Building CXX object CMakeFiles/app_testapp.dir/apps/testapp/main.cpp.o
[ 55%] Building CXX object CMakeFiles/app_testapp.dir/apps/testapp/another.cpp.o
Linking CXX executable app_testapp
[ 55%] Built target app_testapp
Scanning dependencies of target gtest
[ 66%] Building CXX object gtest-1.6.0/CMakeFiles/gtest.dir/src/gtest-all.cc.o
Linking CXX static library libgtest.a
[ 66%] Built target gtest
Scanning dependencies of target gtest_main
[ 77%] Building CXX object gtest-1.6.0/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
Linking CXX static library libgtest_main.a
[ 77%] Built target gtest_main
Scanning dependencies of target lib_testlib_test
[ 88%] Building CXX object CMakeFiles/lib_testlib_test.dir/libs/testlib/gtests/testone.cpp.o
[100%] Building CXX object CMakeFiles/lib_testlib_test.dir/libs/testlib/gtests/testtwo.cpp.o
Linking CXX executable lib_testlib_test
[100%] Built target lib_testlib_test

This will compile all libraries, compile and link all applications. The binary results will be available as app_ for applications and lib_.a for libraries. In the case of testproject we get applications:

ls ./app*
./app_app2  ./app_testapp

Testing is done like this:

make test
Running tests...
Test project /home/meros/github/makertest/cpp-maker/testproject-build
    Start 1: lib_testlib_test
1/1 Test #1: lib_testlib_test .................   Passed    0.00 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.01 sec

Unit tests can be added to libraries and applications, testproject/libs/testlib/gtests contains examples of these. Tests are written using google unit test framework

Clone this wiki locally