TriBITSTriBITS
Docs
Guides
Reference
Pipelines
Downloads
About
Changelog
Docs
Guides
Reference
Pipelines
Downloads
About
Changelog
  • Reference

    • Reference - TriBITS

Reference

The lookup table. Variables, macros, patterns, and options for working with TriBITS projects.

Reference documentation grid showing configuration variables and macro signatures

How to Use This Reference

This section is organized for lookup, not for reading start to finish. Use the headings and search to find what you need. Each entry includes the variable or macro name, what it does, and common usage patterns.

For explanations of why things work the way they do, see the Documentation section. For step-by-step task instructions, see the Guides.

Project-Level Configuration Variables

These variables control the overall behavior of a TriBITS build. Set them on the CMake command line or in a configuration file.

Package Enablement

VariableTypeDefaultDescription
<Project>_ENABLE_<Package>BOOLOFFEnable a specific package.
<Project>_ENABLE_ALL_PACKAGESBOOLOFFEnable every package in the project.
<Project>_ENABLE_ALL_OPTIONAL_PACKAGESBOOLONWhen a package is enabled, also enable its optional dependencies if available.
<Project>_ENABLE_ALL_FORWARD_DEP_PACKAGESBOOLOFFWhen a package is enabled, also enable all packages that depend on it. Useful for CI.

Testing

VariableTypeDefaultDescription
<Project>_ENABLE_TESTSBOOLOFFEnable tests for all enabled packages.
<Project>_TEST_CATEGORIESSTRINGBASICWhich test categories to include: BASIC, NIGHTLY, or HEAVY.
<Project>_ENABLE_EXAMPLESBOOLOFFEnable example executables.
CTEST_PARALLEL_LEVELINT1Number of tests to run in parallel.

Build Configuration

VariableTypeDefaultDescription
CMAKE_BUILD_TYPESTRING(empty)Standard CMake build type: Debug, Release, RelWithDebInfo.
BUILD_SHARED_LIBSBOOLOFFBuild shared libraries instead of static.
CMAKE_INSTALL_PREFIXPATH/usr/localInstallation prefix.
<Project>_VERBOSE_CONFIGUREBOOLOFFPrint detailed information during configure. Useful for debugging.

Multi-Repository

VariableTypeDefaultDescription
<Project>_EXTRA_REPOSITORIESSTRING(empty)Semicolon-separated list of extra repositories to include.
<Project>_EXTRAREPOS_FILEPATH(auto)Path to the extra repositories list file.
<Project>_PRE_REPOSITORIESSTRING(empty)Repositories to configure before the main project.

Core TriBITS Macros

These macros form the API that package developers use most often.

tribits_project()

Declares the top-level project. Called once in the root CMakeLists.txt.

tribits_project()

No arguments. The project name comes from the project() call that precedes it.

tribits_package()

Declares a package. Called at the top of each package's CMakeLists.txt.

tribits_package(PackageName)

This must be paired with tribits_package_postprocess() at the end of the file. Everything between these two calls defines the package contents.

tribits_package_postprocess()

Finalizes package registration. Must be the last TriBITS call in a package's CMakeLists.txt.

tribits_package_postprocess()

Forgetting this call is a common source of subtle bugs where tests or install rules do not behave correctly.

tribits_add_library()

Adds a library target to the current package.

tribits_add_library(mylib
  HEADERS
    mylib.hpp
    utils.hpp
  SOURCES
    mylib.cpp
    utils.cpp
  DEPLIBS
    some_other_lib
)

Key options:

  • HEADERS - Header files to install.
  • SOURCES - Source files to compile.
  • DEPLIBS - Other libraries (within the same package) to link against.
  • IMPORTEDLIBS - External libraries to link against.
  • NOINSTALLHEADERS - Install library but not headers.

tribits_add_executable()

Adds an executable target.

tribits_add_executable(myapp
  SOURCES main.cpp
  DEPLIBS mylib
)

tribits_add_test()

Adds a test that runs an existing executable.

tribits_add_test(myapp
  NAME MyTest
  ARGS "--input=test_data.xml"
  NUM_MPI_PROCS 4
  CATEGORIES BASIC
)

Key options:

  • NAME - Test name (defaults to executable name).
  • ARGS - Arguments passed to the executable.
  • NUM_MPI_PROCS - Number of MPI processes.
  • CATEGORIES - BASIC, NIGHTLY, or HEAVY.
  • PASS_REGULAR_EXPRESSION - Regex that must appear in stdout for the test to pass.
  • FAIL_REGULAR_EXPRESSION - Regex that, if found in stdout, means the test failed.

tribits_add_executable_and_test()

Convenience macro that combines tribits_add_executable() and tribits_add_test() in one call:

tribits_add_executable_and_test(
  MyTest
  SOURCES my_test.cpp
  NUM_MPI_PROCS 1
  CATEGORIES BASIC
)

tribits_add_advanced_test()

For tests that need multiple steps, custom scripts, or complex pass/fail logic:

tribits_add_advanced_test(
  MyAdvancedTest
  TEST_0 EXEC myapp ARGS "--setup"
  TEST_1 EXEC myapp ARGS "--run"
  TEST_2 EXEC myapp ARGS "--verify"
  CATEGORIES NIGHTLY
)

Each TEST_N step runs sequentially. If any step fails, the test fails.

Dependency Declaration

Dependencies are declared in each package's cmake/Dependencies.cmake file.

tribits_package_define_dependencies()

tribits_package_define_dependencies(
  LIB_REQUIRED_PACKAGES PackageA PackageB
  LIB_OPTIONAL_PACKAGES PackageC
  TEST_REQUIRED_PACKAGES TestUtils
  TEST_OPTIONAL_PACKAGES HeavyTestFramework
  LIB_REQUIRED_TPLS Boost
  LIB_OPTIONAL_TPLS MPI
)

Dependency types:

  • LIB_REQUIRED_PACKAGES - Internal packages required for the library to build.
  • LIB_OPTIONAL_PACKAGES - Internal packages that enable additional features.
  • TEST_REQUIRED_PACKAGES - Internal packages needed to build tests.
  • TEST_OPTIONAL_PACKAGES - Internal packages for optional test features.
  • LIB_REQUIRED_TPLS - External third-party libraries required.
  • LIB_OPTIONAL_TPLS - External third-party libraries optional.

Third-Party Libraries (TPLs)

TPLs are external dependencies not managed by TriBITS. The framework provides a standard way to find and configure them:

# In FindTPLBoost.cmake
tribits_tpl_find_include_dirs_and_libraries(Boost
  REQUIRED_HEADERS boost/config.hpp
  REQUIRED_LIBS_NAMES boost_system boost_filesystem
)

The TPL_ENABLE_<name> variable controls whether a TPL is used.

Install Targets

TriBITS handles installation through standard CMake install mechanisms, triggered by the library and executable declarations:

cmake --install . --prefix /opt/myproject

Headers declared in tribits_add_library() are installed to include/. Libraries go to lib/. Executables go to bin/. Configuration files for downstream CMake consumers are generated automatically.

Configuration variable hierarchy showing project, repository, and package levels

Common Configuration Patterns

Minimal Development Build

cmake -D CMAKE_BUILD_TYPE=Debug \
      -D <Project>_ENABLE_<MyPackage>=ON \
      -D <Project>_ENABLE_TESTS=ON \
      -B build

Full Release Build

cmake -D CMAKE_BUILD_TYPE=Release \
      -D BUILD_SHARED_LIBS=ON \
      -D <Project>_ENABLE_ALL_PACKAGES=ON \
      -D CMAKE_INSTALL_PREFIX=/opt/release \
      -B build

CI Incremental Build

cmake -D <Project>_ENABLE_<ChangedPackage>=ON \
      -D <Project>_ENABLE_ALL_FORWARD_DEP_PACKAGES=ON \
      -D <Project>_ENABLE_TESTS=ON \
      -D <Project>_TEST_CATEGORIES=BASIC \
      -B build

Troubleshooting Reference

SymptomLikely CauseFix
Package not foundNot listed in PackagesList.cmakeAdd the package to the project package list
Dependency not resolvedMissing Dependencies.cmakeCreate the dependency file in cmake/
Tests not running_ENABLE_TESTS not setAdd -D <Project>_ENABLE_TESTS=ON
Circular dependency errorTwo packages depend on each otherExtract shared code into a third package
Install headers missingNOINSTALLHEADERS set or headers not listedList headers explicitly in tribits_add_library()