[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 5 Supported Build Systems

Check officially supports two build systems: Autotools and CMake. Primarily it is recommended to use Autotools where possible, as CMake is only officially supported for Windows. Information on using Check in either build system follows.

[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 5.1 Autotools

It is recommended to use pkg-config where possible to locate and use Check in an Autotools project. This can be accomplished by including the following in the project’s ‘`configure.ac`’ file:

       PKG_CHECK_MODULES([CHECK], [check >= MINIMUM-VERSION])

where MINIMUM-VERSION is the lowest version which is sufficient for the project. For example, to guarantee that at least version 0.9.6 is available, use the following:

       PKG_CHECK_MODULES([CHECK], [check >= 0.9.6])

An example of a ‘`configure.ac`’ script for a project is included in the ‘`doc/example`’ directory in Check’s source. This macro should provide everything necessary to integrate Check into an Autotools project.

If one does not wish to use pkg-config Check also provides its own macro, `AM_PATH_CHECK()`, which may be used. This macro is deprecated, but is still included with Check for backwards compatibility.

The `AM_PATH_CHECK()` macro is defined in the file ‘`check.m4`’ which is installed by Check. It has some optional parameters that you might find useful in your ‘`configure.ac`’:

    AM_PATH_CHECK([MINIMUM-VERSION,
                   [ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]]])

`AM_PATH_CHECK` does several things:

1. It ensures check.h is available
2. It ensures a compatible version of Check is installed
3. It sets `CHECK_CFLAGS` and `CHECK_LIBS` for use by Automake.

If you include `AM_PATH_CHECK()` in ‘`configure.ac`’ and subsequently see warnings when attempting to create `configure`, it probably means one of the following things:

1. You forgot to call `aclocal`. `autoreconf` will do this for you.
2. `aclocal` can’t find ‘`check.m4`’. Here are some possible solutions:
   1. Call `aclocal` with ‘`-I`’ set to the location of ‘`check.m4`’. This means you have to call both `aclocal` and `autoreconf`.
   2. Add the location of ‘`check.m4`’ to the ‘`dirlist`’ used by `aclocal` and then call `autoreconf`. This means you need permission to modify the ‘`dirlist`’.
   3. Set `ACLOCAL_AMFLAGS` in your top-level ‘`Makefile.am`’ to include ‘`-I DIR`’ with `DIR` being the location of ‘`check.m4`’. Then call `autoreconf`.

[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 5.2 CMake

Those unable to use Autotools in their project may use CMake instead. Officially CMake is supported only for Windows.

Documentation for using CMake is forthcoming. In the meantime, look at the example CMake project in Check’s ‘`doc/examples`’ directory.

If you are using CMake version 3 or above, importing Check into your project is easier than in earlier versions. If you have installed Check as a CMake library, you should have the following files:

    ${INSTALL_PREFIX}/lib/cmake/check/check-config.cmake and
    ${INSTALL_PREFIX}/lib/cmake/check/check-config-version.cmake and

If you haven’t installed Check into a system directory, you have to tell your CMake build how to find it:

    cmake -Dcheck_ROOT=${INSTALL_PREFIX}

    Then use Check in your @file{CMakeLists.txt} like this:

    @verbatim
    find_package(check <check_version if wanted> REQUIRED CONFIG)

    add_executable(myproj.test myproj.test.c)
    target_link_libraries(myproj.test Check::check)
    add_test(NAME MyProj COMMAND myproj.test)

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated on October 2, 2020 using texi2html 5.0.