ondra-novak / cxxproject

Simple tool to configure project-template for small and medium sized C++ project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CXXPROJECT

Simple tool to configure project-template for small or medium sized C++ project.

Dependencies

  • g++ or clang++
  • make
  • cmake
  • git

Compile and install

$ make all
$ sudo make install

Command line

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>

cxxproject create executable <name>

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

cxxproject create library <name>

/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 contains namespace <name> { }
  • The directory tests should be used for unit tests
  • The compile_test.cpp just tests, whether library can be compiled

cxxproject add library <name>

  • 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> { }

cxxproject add library <name> <git-url>

  • 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

cxxproject add library <name> <git-url> <branch>

  • Same as above, but you can specify branch

Notes

Description of the project skeleton

  • **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 and build/release/bin - It contains compiled executable programs. It is recommended to run and debug these programs from this directory
  • Directory build/debug/lib and build/release/lib - Contains compiled libraries
  • Directory build/debug/log and build/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 and build/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 and build/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 the make all command in the root of the project. It is possible to define additional profiles and use "make all BUILD_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 root CMakeLists.txt

About

Simple tool to configure project-template for small and medium sized C++ project.

License:MIT License


Languages

Language:C++ 99.0%Language:Makefile 1.0%