Skip to main content

CMake Class Creator

A script that inserts a new c++ class in an existing CMake configuration.

A class is composed of a header file and a source file. That's two files! And sometimes they have to be added to different folders as well! Adding classes and files can be tedious when using CMake. This project automates adding classes or single files to a cmake configuration.

How to install

The recommended way is to use pip: pip install CMake-Class-Creator

Please note that this module depends on a release candidate version op pyparsing, 3.0.0b1. So it is also recommended to install this in a virtual environment.

Optionally you can alias this command: alias cmcc=cmake_create_class

Easy insertion using references

There are (too many) ways to specify source files for CMake. Usually the sources are list variables defined with the set keyword. Sometimes the sources are defined directly in add_library or add_executable. In modern CMake there is also a target_sources statement.

So, you want to insert a new class, CMake Class Creator somehow must know how to insert it. The easiest way is to define a reference class.

Adding a class using a reference class

Suppose you want to insert a new class 'NewClass' next to 'ExistingClass':

$>cmcc <cmakelists> NewClass -rc ExistingClass

Executing this command will dump the updated cmakelists content to stdout, here you can check if the result is what you expect it to be.

When you approve of the changes, run the same command again with the -i option:

$>cmcc <cmakelists> NewClass -rc ExistingClass -i

Now the file contents of the cmakelists are updated. Your new class has been inserted!

Adding a single file using a reference file

It is also possible to add a single file using the -s option.

When you want to make a header only class for instance:

$>cmcc <cmakelists> New.hpp -s -rc Existing.hpp

Note that since we're dealing with single files, specifying the complete filename including the extension is required. But it is not required to specify the full path. In this example, Existing.hpp may be defined as <path>/Existing.hpp or just Existing.hpp. In case there is a path prefix, this will also be used for New.hpp.

When you approve of the changes, run the same command again with the -i option:

$>cmcc <cmakelists> New.hpp -s -rc Existing.hpp -i

Now the file contents of the cmakelists are updated. Your new file has been inserted!

Metadata

Release files for CMake-Class-Creator 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CMake-Class-Creator 0.1.6
File Size Uploaded
CMake-Class-Creator-0.1.6.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for CMake-Class-Creator 0.1.6
File Interpreter ABI Platform
CMake_Class_Creator-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 48.6 kB

Release files / CMake-Class-Creator-0.1.6.tar.gz

Download URL CMake-Class-Creator-0.1.6.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cde6576baee155f4ddd57867cad61ee048dfbc54432a0ae89fa4b11cc05803c5
BLAKE2b-256 checksum
How to use checksums
f7a9356ea47783cc4ed12a6e2aefffe7d42bcca5c06faf6b90cef409f63f5fd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / CMake_Class_Creator-0.1.6-py3-none-any.whl

Download URL CMake_Class_Creator-0.1.6-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d85911d058815e8ddcd7574cdcccf61ee3f97fca3ad84007a0595f6947c3f661
BLAKE2b-256 checksum
How to use checksums
5913bedc7372b718e109956103021ee856e03a3f2b3d4078ca9e5049bebc7fec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page