4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
Installation and Usage

Contents

Requirements

You need the following dependencies to build fcppt:

The following dependencies are optional:

Tested Platforms

The following platforms are tested by us:

  • gcc-14.2 (Gentoo Linux and MinGW)
  • clang-19.1.0 (Gentoo Linux)
  • VC++-14.41 (Visual Studio 2022)

fcppt needs a C++20-conforming compiler.

Download

The source code and releases are available on Github.

Gentoo ebuilds are available in Freundlich's overlay.

Building and Installation

fcppt uses CMake as its build system, so the standard CMake procedure to build a project applies: First, download and extract the tarball or clone the git repository. Create a new directory that will be used as build directory, which we refer to as $build. Change directory into $build. Assuming fcppt is in $fcpptpath, call

cmake $fcpptpath

and pass all relevant arguments, e.g. -G Ninja, to CMake.

Several CMake options are available:

  • ENABLE_BOOST: Whether to build fcppt.boost. Boost is required for this. Take a look at CMake's FindBoost.cmake to see how to specify where to find Boost.
  • ENABLE_CATCH: Whether to build fcppt.catch. Catch-3 is required for this.
  • ENABLE_EXAMPLES: Whether to build fcppt's examples. This is probably something you want to turn off when you install fcppt only.
  • ENABLE_TEST: Whether to build fcppt's tests. Catch-3 and ENABLE_CATCH are required for this.
  • ENABLE_DOC: Whether to build fcppt's documentation. Doxygen is required for this. Take a look at CMake's FindDoxygen.cmake on how to specify which Doxygen installation to use.
  • ENABLE_SHARED: Build shared libraries. This defaults to on.
  • ENABLE_STATIC: Build static libraries. This defaults to off.
  • ENABLE_THREADS: Enables thread-support in fcppt.log. This defaults to on.

You need at least one of ENABLE_SHARED or ENABLE_STATIC.

fcppt does not need to be installed in order to be used. After fcppt has been built you can directly use it from its source directory. If you want to install don't forget to set CMAKE_INSTALL_PREFIX.

Using fcppt

Modify your CMakeLists.txt

fcppt comes with an exported CMake file that defines all of fcppt's targets, which currently are boost, catch, core, filesystem, log, options and parse. The following code provides a small example in which the target mytarget links to core and log:

find_package(fcppt REQUIRED)
add_executable(mytarget main.cpp)

target_link_libraries(
        mytarget
        PRIVATE
        ${fcppt_core_TARGET}
        ${fcppt_log_TARGET}
)

Linking to a specific target, e.g. ${fcppt_core_TARGET}, directly inherits all includes directories and build flags as needed. If you only use headers from a specific target, e.g. fcppt core, you can link to its interface library instead:

target_link_libraries(
        mytarget
        PRIVATE
        fcppt_core_interface
)

fcppt.boost, fcppt.catch and fcppt.parse only provide interface targets.

Interfaces are CMake targets that do not include a library to link to but, as with regular targets, provide include directories and build flags.

If fcppt has not been installed in a location already recognized by CMake, you will have to specify additional parameters depending on where fcppt is located:

Using fcppt from the build directory

If you don't install fcppt, you should specify fcppt's build config directory using -D fcppt_DIR=${fcppt_build_dir}/config, where fcppt_build_dir points to fcppt's build directory.

Using fcppt from an installation

If fcppt is installed, fcppt's config is installed to INSTALL_CMAKECONFIG_DIR (which is usually /usr/lib/cmake), where CMake should be able to find it when find_package(fcppt) is used. Otherwise, you have to specify fcppt_DIR manually.

Static and shared builds

fcppt can be built as a static or shared library, which is controlled by ENABLE_STATIC and ENABLE_SHARED, respectively. If you intend to use fcppt as a static library you need to set fcppt_USE_STATIC_LIBS=ON before you call find_package(fcppt). For example, fcppt_core_TARGET will then point to fcppt_core_static instead of fcppt_core.