Building a C Project
What This Guide Covers
This guide covers build environment and configuration topics specific to C++ projects. Please make sure to read our Getting Started and general build configuration guides first.
CI environment for C Projects
Travis VMs are 64 bit and currently provide
- gcc 4.6
- clang 3.1
- core GNU build toolchain (autotools, make), cmake, scons
C++ projects on travis-ci.org assume you use Autotools and Make by default.
As a free community service, Travis CI limits build duration to about 20 minutes. Because some large C++ codebases may take very long time to build, please take care to not take too much of workers time. If you project takes longer than 10-15, please contact us on the mailing list before you add your project to Travis.
Dependency Management
Because there is no dominant convention in the community about dependency management, Travis CI skips dependency installation for C++ projects.
If you need to perform special tasks before your tests can run, override the install: key in your .travis.yml:
install: make get-deps
See general build configuration guide to learn more.
Default Test Script
Because C projects on travis-ci.org assume Autotools and Make by default, naturally, the default command Travis CI will use to run your project test suite is
./configure && make && make test
Projects that find this sufficient can use a very minimalistic .travis.yml file:
language: cpp
This can be overridden as described in the general build configuration guide. For example, to build
by running Scons without arguments, override the script: key in .travis.yml like this:
script: scons
Choosing compilers to test against
It is possible to test projects against either GCC or Clang, or both. To do so, specify the compiler to use using the compiler: key
in .travis.yml. For example, to build with Clang:
compiler: clang
or both GCC and Clang:
compiler:
- clang
- gcc
Testing against two compilers will create (at least) 2 rows in your build matrix. For each row, Travis CI C builder will export the CXX
env variable to point to either g++ or clang++ and CC to either gcc or clang.