Chigraph CMake options
CMake is the meta-build-system used to compile chigraph. It generates files for another build system (GNU Makefiles, Visual Studio, Ninja, etc) that are used to compile your project.
There are some notable flags you can pass to it to configure how chigraph is compiled.
Basic CMake usage
You usually want to run CMake in a separate directory from the chigraph source directory to make it impossible to check in build files.
The build
subdirectory is a common choice, and is already in the .gitignore
file.
CMake generators
Because CMake can target many different build systems, you have to tell it which to target.
On linux and macOS, this is usually Unix Makefiles
or Ninja
.
On windows, it’s usually a Visual Studio generator. You sepcify the generator using the -G
flag on the cmake commandline, or
if you’re using the GUI then it will ask.
CMake varaibles
You can specify variables to pass to the CMake script with the -D
flag, which is how compile options are set.
Usage:
cmake .. -G<Generator> [ -D<Variable name>=<Variable value> ]
Important generic CMake flags
Flags that aren’t specific to chigraph but important nonetheless.
CMAKE_BUILD_TYPE
: Set this toDebug
orRelease
to build in a deubg or release configuration.CMAKE_CXX_FLAGS
: Extra flags to pass to the C++ compiler. Useful for passing sanitizers like-fsanitize=address
.CMAKE_INSTALL_PREFIX
: Where to install chigraph toCMAKE_PREFIX_PATH
: Paths to find packages outside of the normal search paths.LLVM_CONFIG
: Path to thellvm-config
executable.
Chigraph specific flags
Flags that are specifc to chigraph. All have
CG_BUILD_TESTS
: Set toOFF
if you don’t want the tests built. Defaults toON
.CG_BUILD_EXAMPLES
: Set toON
if you want the examples to be built. Defaults toOFF
.CG_BUILD_DEBUGGER
: Set toOFF
if you don’t want the debugger to be built with chigraph. Useful when your LLVM install doesn’t include LLDB. Defaults toON
.CG_USE_SYSTEM_LIBGIT2
: Set toON
if you want CMake to find a system libgit2 instead of the prepackaged one. Defaults toOFF
.CG_USE_SYSTEM_BOOST
: Set toON
if you want CMake to find the system boost install instead of the prepackaged install. Defaults toOFF
.