cpppm

CPP Package Manager


Keywords
c++, project-manager, build-management, build-tool, cmake, conan, cpp, package-manager, python
License
MIT
Install
pip install cpppm==0.2.0

Documentation

cpppm

CPP Project Manager

Please note that I reference python as python3, python2 is dead and buried... RIP

What is that

cpppm is a C/C++ project manager that focus on flexibility.

A basic example

Consider following code:

  • main.cpp:
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>
#include <fmt/format.h>

TEST_CASE("cpppm loves conan") {
    CHECK(fmt::format("{1} loves {0} !!!", "conan", "cpppm") == "cpppm loves conan !!!");
}
  • project.py:
from cpppm import Project, main

project = Project('conan_requires')
project.requires = 'fmt/6.1.2', 'doctest/2.3.6'
exe = project.main_executable()
exe.sources = 'src/main.cpp'
exe.link_libraries = 'fmt', 'doctest'
main()

At this point you'll be able to run:

$ python ./project.py run hello cpppm

# Build output ommitted...

[doctest] doctest version is "2.3.6"
[doctest] run with "--help" for options
===============================================================================
[doctest] test cases:      1 |      1 passed |      0 failed |      0 skipped
[doctest] assertions:      1 |      1 passed |      0 failed |
[doctest] Status: SUCCESS!

Amazing, no ?

How it works

It is nothing more that a project file generator, with embedded conan package management. It creates CMakeLists.txt file for you, calls the build commands and runs the target(s).

Why should I use it

I was writing CMakeLists.txt files for decades, and I have been bored of doing:

configure_file(my_cool_stuff_to_do.py.in my_cool_stuff_to_do.py)
find_package(PythonInterp REQUIRED)
function(my_cool_stuff_to_do)
    custom_command(${PYTHON_EXECUTABLE} my_cool_stuff_to_do.py ARGS ${ARGN})
endfunction()
...

And running many commands conan, cmake, make, ctest... So, I wanted to turn the process from conan, cmake with cool python stuff, make, ctest into cool python stuff.

So, If you feel doing such stuff often, give it a try 😘.

Installation

  • By cloning this repository:
git clone https://github.com/Garcia6l20/cpppm.git
cd cpppm
python setup.py install --user
  • Available on PyPi:
pip install --user cpppm

Commands

Default commands can be listed with a regular help request:

$ python project.py --help
Usage: project.py [OPTIONS] COMMAND [ARGS]...

Options:
  -v, --verbose  Let me talk about me.
  --help         Show this message and exit.

Commands:
  build      Builds the project.
  configure  Configures CMake stuff.
  generate   Generates conan/CMake stuff.
  run        Runs the given TARGET with given ARGS.
  test       Runs the unit tests.

Documentation

No documentation yet... For API, check the examples (Im trying to demonstrate all uses cases), use IDE to edit your project script (eg.: Pycharm).

Features

  • CMakeProject generation
  • Project compilation
  • Conan package management (not yet, but soon)
  • Executables invocation (automatically added to cli interface)
  • Customizable (you can do anything you can do with python)
  • Cli customization (cou can add any @cpppm.cli.command that you want to add, see click)

Contributing

Would be appreciated, no contribution guide, just PEP-8 codding style and smart codding, fork/PR.