This is an old revision of the document!
Table of Contents
About Ctor
Welcome to the official ctor.cc C++ build system website!
Have you wondered, why, when you are a C++ expert and want to compile a C++ project, you need to learn some other language (such as make, cmake, lua, python, m4, …) to be able to compile your code?
Well, wonder no more - ctor is here!
“'ctor” is an often used short-hand form of the word “constructor” referring to the class function that sets up the internals of an object in object oriented programming - so the intended pronunciation of “ctor” is “constructor”.
Ctor is a c++ based build system, making it possible to build complex projects without writing a single line of non-C++.
It aims towards the feature-richness found in auto-tools and beyond, but with a compilation speed rivalling that of raw makefiles.
Get it
Clone:
git clone --recursive git://git.ctor.cc/ctor.git libctor
Browse the sources: http://cgit.ctor.cc/ctor.git/
License
Ctor is distributed under the BSD 2-Clause License. See accompanying file LICENSE for details.
Getting started
If the ctor library is already available as part of your distro skip directly to “How to set up your build configuration”.
Adding libctor to your project
Assuming you are working on a git repository:
git submodule add git://git.ctor.cc/ctor.git libctor git submodule update --init --recursive
This should give you all the files you need to build your code.
Enter the libctor dir and run the ./boostrap.sh
script, which will build the ctor binary.
Then run ./ctor
to build it - it will end up in the build subfolder.
How to set up your build configuration
Assuming that you have a project with a two c++ source files, hello.cc
and world.cc
, and would like to compile them into an application binary (target) with the name hello
:
In the root of your project you can create your first ctor.cc
build configuration file:
#include <libctor.h> namespace { BuildConfigurations myConfigs() { return { { .target = "hello", // output filename .sources = { "hello.cc", "world.cc" }, // list of source files to compile // See libctor.h for more options } }; } } // Register callback REG(myConfigs);
Now you just need to compile the ctor.cc
file along with the libctor.a
library:
g++ ctor.cc -Llibctor/build -lctor -Ilibctor/src -pthread -o ctor
Finally the configure
step must be carried out to set (at least) the include and lib paths to ctor (this step can be skipped if ctor is installed in the system paths, /usr/include
and /usr/lib
for example):
./ctor configure --ctor-includedir=libctor/src --ctor-libdir=libctor/build
One can advantageously put these commands into a boostrap.sh
script for the project. It will only be needed the first time ctor
is being built.
Finally, run ./ctor
to build your project.