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:
make
compiles the main applicationmake test
compiles the main application and run a test against itmake clean
cleans generated files such as executable and objects
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CC=gcc
make CC=gcc test
make 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:
make
compiles the main applicationmake test
compiles the main application and run a test against itmake clean
cleans generated files such as executable and objects
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CC=gcc
make CC=gcc test
make 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:
make
compiles the main applicationmake test
compiles the main application and run a test against itmake clean
cleans 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++ test
make 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:
make
compiles the main applicationmake test
compiles the main application and run a test against itmake clean
cleans 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++ test
make 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:
make
ormake dynamic
compiles the dynamic librarymake static
compiles the static librarymake test
compiles and tests against the dynamic librarymake testStatic
compiles and tests against the static librarymake clean
cleans generated files
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CC=gcc
ormake CC=gcc dynamic
make CC=gcc static
make CC=gcc test
make CC=gcc testStatic
make 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:
make
ormake dynamic
compiles the dynamic librarymake static
compiles the static librarymake test
compiles and tests against the dynamic librarymake testStatic
compiles and tests against the static librarymake clean
cleans generated files
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CC=gcc
ormake CC=gcc dynamic
make CC=gcc static
make CC=gcc test
make CC=gcc testStatic
make 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:
make
ormake dynamic
compiles the dynamic librarymake static
compiles the static librarymake test
compiles and tests against the dynamic librarymake testStatic
compiles and tests against the static librarymake clean
cleans generated files
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CXX=g++
ormake CC=g++ dynamic
make CXX=g++ static
make CXX=g++ test
make CXX=g++ testStatic
make 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:
make
ormake dynamic
compiles the dynamic librarymake static
compiles the static librarymake test
compiles and tests against the dynamic librarymake testStatic
compiles and tests against the static librarymake clean
cleans generated files
On Windows, the projects assume MSVC; however, MinGW is supported as well:
make CXX=g++
ormake CC=g++ dynamic
make CXX=g++ static
make CXX=g++ test
make CXX=g++ testStatic
make 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.