Simple tool to configure project-template for small or medium sized C++ project.
- g++ or clang++
- make
- cmake
- git
$ make all
$ sudo make install
The program should be installed on $PATH. It works with current directory. It is expected that current directory is the root of a project
$ mkdir project
$ cd project
$ cxxproject <commands>
Creates project skeleton to build executable. You just supply name of the executable
/build
/build/debug
/build/release
/conf
/src
/src/name
/src/name/<name>.cpp
/src/name/<name>.h
/src/name/CMakeLists.txt
.gitignore
CMakeLists.txt
Makefile
- The main file is
<name>.cpp
, contains main() - Creates configuration for debug and releae
- Creates Makefile on root - which compiles both builds
- Output is put to
/build/<configuration/bin/<name>
- Automatically adds files project to git index
/build
/build/debug
/build/release
/conf
/src
/src/name
/src/name/<name>.cpp
/src/name/<name>.h
/src/name/CMakeLists.txt
/src/tests/compile_test.cpp
/src/tests/CMakeLists.txt
.gitignore
CMakeLists.txt
Makefile
- Builds a library
lib<name>.a
as target<name>
- Headers are accessible through
#include <name/header.h>
- Source file
<name>.cpp
and<name>.h
containsnamespace <name> { }
- The directory tests should be used for unit tests
- The compile_test.cpp just tests, whether library can be compiled
- Adds empty library to existing project
- You need to manually add the library to executable target
- Headers are accessible through
#include <name/header.h>
- Source file
<name>.cpp
and<name>.h
contains namespace<name>
{ }
- Adds submodule as library
<name>
- Searches for
library.cmake
- if such file exists, it is included to root CMakeLists.txt (see Notes) - You need to manually add the library to executable target
- Same as above, but you can specify branch
- **Directory
src**
- The folder contains all the source files. These should be organized into named subfolders according to meaning. Typically a library can be placed in the 'src/libname' sub. Imported libraries and submodules are placed there as well - Directory
build
- The folder is created during the first build and contains the files required to build and the resulting executable files or libraries - Directory
build/debug
- Contains files built in debug mode - Directory
build/release
- Contains files built in release mode - Directory
build/debug/bin
andbuild/release/bin
- It contains compiled executable programs. It is recommended to run and debug these programs from this directory - Directory
build/debug/lib
andbuild/release/lib
- Contains compiled libraries - Directory
build/debug/log
andbuild/release/log
- A free folder for compiled executable programs where they can log their activity while running or debugging - Directory
conf
- Place the files needed to configure the compiled executables in this folder. This folder is then linked into each build configuration (build/debug/conf
andbuild/release/conf
) to make it available to executable programs. - Directory
data
- In this folder, place files representing data sources, or even output files generated by compiled executable programs. This folder is then linked into each build configuration (build/debug/data
andbuild/release/data
) to make it available to executable programs - File
CMakeLists.txt
- Contains project settings for CMake - File
Makefile
- Helper script to simplify work for convenience, which can run the preparation and build of the entire project with the "make all" command - File
default_build_profile.conf
- Contains additional CMake parameters that are used when building automatically by themake all
command in the root of the project. It is possible to define additional profiles and use "make allBUILD_PROFILE=profile_name
to build for a different profile. - File: library.cmake - The file is only generated for the library project and contains a cmake script that makes it easier to set up the parent project so that the library is easily available in that project. If this library is imported into another project, cxxproject looks for a
library.cmake
file in the imported repository, and if such a file exists, it is automatically inserted into the rootCMakeLists.txt