Using Generated Projects¶
Here we illustrate how to use the generated projects created by mkg.
Currently, mkg supports either flat or nested project structure. The former
is suitable for simple projects while the latter fits more complex ones. All the
projects created by mkg are ready as Git repos.
Implicitly, mkg users need some knowledge to GNU Make to smoothly use these
generated projects.
System Requirements¶
A recent C or C++ compiler
GNU Make
Bats (Bash Automated Testing System) on Unix-like systems
We assume the default compiler on each platform, namely
Visual C++ on Windows
Clang on Mac
GCC on other Unix-like systems such as GNU/Linux
For Windows users, you may get a port of GNU Make at MSYS2 or GnuWin32. Besides, MinGW, a Windows port of GCC, is supported in these projects as well.
Flat Console Application Projects for C¶
Let’s say that we want to create such a project myapp:
$ mkg --flat myapp
$ cd myap
You may invoke these commands at the root of the project:
makecompiles the main applicationmake testcompiles the main application and run a test against itmake cleancleans generated files such as executable and objects
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CC=gccmake CC=gcc testmake CC=gcc clean
Nested Console Application Projects for C¶
Let’s say that we want to create such a project myapp:
$ mkg myapp
$ cd myapp
You may invoke these commands at the root of the project:
makecompiles the main applicationmake testcompiles the main application and run a test against itmake cleancleans generated files such as executable and objects
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CC=gccmake CC=gcc testmake CC=gcc clean
myapp owns a nested project structure like this:
$ tree
.
├── dist
├── examples
├── include
├── Makefile
├── README.md
├── src
│ ├── Makefile
│ ├── Makefile.win
│ └── myapp.c
└── tests
├── myapp.bash
└── myapp.vbs
dist for generated executable
examples for example code
include for headers
src for application source code
tests for test programs
All these directory destinations are customizable.
Flat Console Application Projects for C++¶
Let’s say that we want to create such a project myapp:
$ mkg -cxx --flat myapp
$ cd myap
You may invoke these commands at the root of the project:
makecompiles the main applicationmake testcompiles the main application and run a test against itmake cleancleans generated files such as executable and objects
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CXX=g++make CXX=g++ testmake CXX=g++ clean
Nested Console Application Projects for C++¶
Let’s say that we want to create such a project myapp:
$ mkg -cxx myapp
$ cd myapp
You may invoke these commands at the root of the project:
makecompiles the main applicationmake testcompiles the main application and run a test against itmake cleancleans generated files such as executable and objects
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CXX=g++make CXX=g++ testmake CXX=g++ clean
myapp owns a nested project structure like this:
$ tree
.
├── dist
├── examples
├── include
├── Makefile
├── README.md
├── src
│ ├── Makefile
│ ├── Makefile.win
│ └── myapp.cpp
└── tests
├── myapp.bash
└── myapp.vbs
dist for generated executable
examples for example code
include for headers
src for application source code
tests for test programs
All these directory destinations are customizable.
Flat Library Projects for C¶
Let’s say that we want to create such a project mylib:
$ mkg --library --flat mylib
$ cd mylib
You may invoke these commands at the root of the project:
makeormake dynamiccompiles the dynamic librarymake staticcompiles the static librarymake testcompiles and tests against the dynamic librarymake testStaticcompiles and tests against the static librarymake cleancleans generated files
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CC=gccormake CC=gcc dynamicmake CC=gcc staticmake CC=gcc testmake CC=gcc testStaticmake CC=gcc clean
Nested Library Projects for C¶
Let’s say that we want to create such a project mylib:
$ mkg --library mylib
$ cd mylib
You may invoke these commands at the root of the project:
makeormake dynamiccompiles the dynamic librarymake staticcompiles the static librarymake testcompiles and tests against the dynamic librarymake testStaticcompiles and tests against the static librarymake cleancleans generated files
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CC=gccormake CC=gcc dynamicmake CC=gcc staticmake CC=gcc testmake CC=gcc testStaticmake CC=gcc clean
mylib owns a nested project structure like this:
$ tree
.
├── dist
├── examples
├── include
│ └── mylib.h
├── Makefile
├── README.md
├── src
│ ├── Makefile
│ ├── Makefile.win
│ └── mylib.c
└── tests
├── Makefile
├── Makefile.win
└── mylib_test.c
dist for generated executable
examples for example code
include for headers
src for application source code
tests for test programs
All these directory destinations are customizable.
Flat Library Projects for C++¶
Let’s say that we want to create such a project mylib:
$ mkg --library -cxx --flat mylib
$ cd mylib
You may invoke these commands at the root of the project:
makeormake dynamiccompiles the dynamic librarymake staticcompiles the static librarymake testcompiles and tests against the dynamic librarymake testStaticcompiles and tests against the static librarymake cleancleans generated files
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CXX=g++ormake CC=g++ dynamicmake CXX=g++ staticmake CXX=g++ testmake CXX=g++ testStaticmake CXX=g++ clean
Nested Library Projects for C++¶
Let’s say that we want to create such a project mylib:
$ mkg --library -cxx mylib
$ cd mylib
You may invoke these commands at the root of the project:
makeormake dynamiccompiles the dynamic librarymake staticcompiles the static librarymake testcompiles and tests against the dynamic librarymake testStaticcompiles and tests against the static librarymake cleancleans generated files
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CXX=g++ormake CC=g++ dynamicmake CXX=g++ staticmake CXX=g++ testmake CXX=g++ testStaticmake CXX=g++ clean
mylib owns a nested project structure like this:
$ tree
.
├── dist
├── examples
├── include
│ └── mylib.hpp
├── Makefile
├── README.md
├── src
│ ├── Makefile
│ ├── Makefile.win
│ └── mylib.cpp
└── tests
├── Makefile
├── Makefile.win
└── mylib_test.cpp
dist for generated executable
examples for example code
include for headers
src for application source code
tests for test programs
All these directory destinations are customizable.