Skip to main content

Clark's Conan, CMake, C++ Project Tools

Note: this is a rewrite of a another project https://github.com/CD3/cccpt and does not fully support Windows yet.

This project started out as a collection of small scripts to automate the configure, build, and testing steps of C++ projects I work on. It has since grown to include several small utilities that I have found useful while working on C++ projects.

Overview

While CMake has its issues, and there are many that despise it, it is the de facto standard for building C++ projects. Most people's objections with CMake have to do with its home-grown scripting language. The command line interface is actually quite nice. Not only does it support multiple generators, but it abstracts away many of the differences between the generated build systems. For example, on Linux, you might do something like this:

$ mkdir build
$ cd build
$ cmake ..
$ make

But on Windows you might do:

$ mkdir build
$ cd build
$ cmake ..
$ msbuild MyProject.vcxproj

But with the cmake --build tool, you can do

$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .

This works for Makefiles, Visual Studio Solutions, Ninja, etc. What's more, if you follow the normal conventions, these four lines should build any CMake project you create (things get more complicated if you need to support custom options, but you should still have a default build that will just work).

I found that I was constantly running these commands, so I just put them into a script and eventually that morphed into ccc. I also do most of my development on Linux, but occasionally need to build projects on Windows (mostly for testing), so I wanted something I could run on either platform and have it "just work".

Usage

Installing

You can install ccc with pip.

$ pip install conan-cmake-cpp-project-tools

This may be an out-of-date version. To use the latest version, clone this repository and install with pip

$ cd cccpt
$ pip install .

Requirements

ccc expects several standard tools to be installed. It makes use of these tools wherever possible, rather than re-implementing functionality. Current dependencies are:

  • Python (required)
  • CMake (required)
  • git (required)
  • Conan (optional)

If you don't use these tools, then ccc won't be useful.

Commands

To build a C++ project, run

$ ccc build

from anywhere in the project directory. This will create a build directory in the project root (git is used to find the project root), install any dependencies specified in a conanfile.txt file, and configure and build (by default, Debug mode is built) the project.

To run the unit tests

$ ccc test

This will automatically run the build step, so it possible to run this command on a fresh copy of the project. Currently this command just looks for executables created in the build directory that match file name patterns I commonly use, so it may not work for you.

To build or test in Release mode, pass either command the -R option.

To get a list of all source files in the project

$ ccc list-sources

This is useful for triggering the unit tests to run when a file changes with the entr command.

$ ccc list-sources | entr ccc test

To install a project into a given root directory

$ ccc install /path/to/install/dir

This will run CMake with the -DCMAKE_INSTALL_PREFIX=/path/to/install/dir option, build the project in release mode, and then run cmake --build . --target install.

There are many other commands that I find useful in my developement workflow. You may or may not find them useful. To get a list of all commands, run

$ ccc --help

Metadata

Release files for conan-cmake-cpp-project-tools 0.7

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

Source distribution (sdist)

Source distribution for conan-cmake-cpp-project-tools 0.7
File Size Uploaded
conan_cmake_cpp_project_tools-0.7.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conan-cmake-cpp-project-tools 0.7
File Interpreter ABI Platform
conan_cmake_cpp_project_tools-0.7-py3-none-any.whl Python 3 none any Details

Total release size: 28.7 kB

Release files / conan_cmake_cpp_project_tools-0.7.tar.gz

Download URL conan_cmake_cpp_project_tools-0.7.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2461c128970d324a5ba26e84993a499948d5df40084293bb5b25e85bd6cba79f
BLAKE2b-256 checksum
How to use checksums
b9ee04b073c4877cfc01d39d902cba1713381a8d6407465f9a689d12de456c08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.6 Linux/5.15.0-52-generic

Release files / conan_cmake_cpp_project_tools-0.7-py3-none-any.whl

Download URL conan_cmake_cpp_project_tools-0.7-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c269c0b5e31d28a4342010893a869c00c2346d9f3ab031ac2ca2fc86462f6c81
BLAKE2b-256 checksum
How to use checksums
9e40a4f8409cff71ce0f954ff2c4bf1c4939ed03c69f0698c6dc08ab043cfad7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.6 Linux/5.15.0-52-generic

Release history Release notifications | RSS feed

This release

0.7 This release

2 release files

0.6.1

2 release files

0.6

2 release files

0.5

2 release files

0.3

1 release file

0.2

1 release file

0.1

1 release file

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