diff --git a/.travis.sh b/.travis.sh index 3cec20f53..5de2d8e69 100755 --- a/.travis.sh +++ b/.travis.sh @@ -1,7 +1,7 @@ #!/bin/bash # common tasks before either build or test -function prepare () +function configure() { set -e # Make sure any error makes the script to return an error code set -x # echo @@ -14,21 +14,23 @@ function prepare () rm -fr $BUILD_DIR || true mkdir $BUILD_DIR && cd $BUILD_DIR - if [ -z "$CMAKE_BUILD_TYPE" ]; then - CMAKE_BUILD_TYPE=Debug - fi - - if [ -z "$GTSAM_ALLOW_DEPRECATED_SINCE_V4" ]; then - GTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF - fi - if [ ! -z "$GCC_VERSION" ]; then - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 \ - --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION - sudo update-alternatives --set gcc /usr/bin/gcc-$GCC_VERSION + export CC=gcc-$GCC_VERSION + export CXX=g++-$GCC_VERSION fi + + # GTSAM_BUILD_WITH_MARCH_NATIVE=OFF: to avoid crashes in builder VMs + cmake $SOURCE_DIR \ + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \ + -DGTSAM_BUILD_TESTS=${GTSAM_BUILD_TESTS:-OFF} \ + -DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \ + -DGTSAM_BUILD_EXAMPLES_ALWAYS=${GTSAM_BUILD_EXAMPLES_ALWAYS:-ON} \ + -DGTSAM_ALLOW_DEPRECATED_SINCE_V4=${GTSAM_ALLOW_DEPRECATED_SINCE_V4:-OFF} \ + -DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \ + -DCMAKE_VERBOSE_MAKEFILE=ON } + # common tasks after either build or test function finish () { @@ -41,17 +43,12 @@ function finish () # compile the code with the intent of populating the cache function build () { - prepare + export GTSAM_BUILD_EXAMPLES_ALWAYS=ON + export GTSAM_BUILD_TESTS=OFF - cmake $SOURCE_DIR \ - -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ - -DGTSAM_BUILD_TESTS=OFF \ - -DGTSAM_BUILD_UNSTABLE=$GTSAM_BUILD_UNSTABLE \ - -DGTSAM_BUILD_EXAMPLES_ALWAYS=ON \ - -DGTSAM_ALLOW_DEPRECATED_SINCE_V4=$GTSAM_ALLOW_DEPRECATED_SINCE_V4 + configure - # Actual build: - VERBOSE=1 make -j2 + make -j2 finish } @@ -59,14 +56,10 @@ function build () # run the tests function test () { - prepare + export GTSAM_BUILD_EXAMPLES_ALWAYS=OFF + export GTSAM_BUILD_TESTS=ON - cmake $SOURCE_DIR \ - -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \ - -DGTSAM_BUILD_TESTS=ON \ - -DGTSAM_BUILD_UNSTABLE=$GTSAM_BUILD_UNSTABLE \ - -DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \ - -DGTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF + configure # Actual build: make -j2 check @@ -79,7 +72,7 @@ case $1 in -b) build ;; - -t) + -t) test ;; esac diff --git a/.travis.yml b/.travis.yml index 1e2d6760a..bcb6ceb4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,12 @@ addons: apt: sources: - ubuntu-toolchain-r-test + - sourceline: 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main' + key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key' packages: - - g++-8 - - clang-3.8 - - build-essential - - pkg-config + - g++-9 + - clang-9 + - build-essential pkg-config - cmake - libpython-dev python-numpy - libboost-all-dev @@ -28,8 +29,14 @@ stages: - compile - test +env: + global: + - MAKEFLAGS="-j2" + - CCACHE_SLOPPINESS=pch_defines,time_macros + # Compile stage without building examples/tests to populate the caches. jobs: +# -------- STAGE 1: COMPILE ----------- include: # on Mac, GCC - stage: compile @@ -68,46 +75,45 @@ jobs: - stage: compile os: linux compiler: clang - env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF + env: CC=clang-9 CXX=clang++-9 CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF script: bash .travis.sh -b - stage: compile os: linux compiler: clang - env: CMAKE_BUILD_TYPE=Release + env: CC=clang-9 CXX=clang++-9 CMAKE_BUILD_TYPE=Release script: bash .travis.sh -b # on Linux, with deprecated ON to make sure that path still compiles - stage: compile os: linux compiler: clang - env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF GTSAM_ALLOW_DEPRECATED_SINCE_V4=ON + env: CC=clang-9 CXX=clang++-9 CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF GTSAM_ALLOW_DEPRECATED_SINCE_V4=ON script: bash .travis.sh -b - -# Matrix configuration: -os: - - osx - - linux -compiler: - - gcc - - clang -env: - global: - - MAKEFLAGS="-j2" - - CCACHE_SLOPPINESS=pch_defines,time_macros - - GTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF - - GTSAM_BUILD_UNSTABLE=ON - matrix: - - CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF - - CMAKE_BUILD_TYPE=Release -script: - - bash .travis.sh -t - -matrix: - exclude: - # Exclude g++ debug on Linux as it consistently times out - - os: linux - compiler: gcc - env : CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF - # Exclude clang on Linux/clang in release until issue #57 is solved - - os: linux - compiler: clang - env : CMAKE_BUILD_TYPE=Release +# -------- STAGE 2: TESTS ----------- +# on Mac, GCC + - stage: test + os: osx + compiler: clang + env: CMAKE_BUILD_TYPE=Release + script: bash .travis.sh -t + - stage: test + os: osx + compiler: clang + env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF + script: bash .travis.sh -t + - stage: test + os: linux + compiler: gcc + env: CMAKE_BUILD_TYPE=Release + script: bash .travis.sh -t +# Exclude g++ debug on Linux as it consistently times out +# - stage: test +# os: linux +# compiler: gcc +# env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_UNSTABLE=OFF +# script: bash .travis.sh -t +# Exclude clang on Linux/clang in release until issue #57 is solved +# - stage: test +# os: linux +# compiler: clang +# env: CC=clang-9 CXX=clang++-9 CMAKE_BUILD_TYPE=Release +# script: bash .travis.sh -t diff --git a/CMakeLists.txt b/CMakeLists.txt index 732717141..2af6341ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -434,7 +434,7 @@ add_subdirectory(timing) # Build gtsam_unstable if (GTSAM_BUILD_UNSTABLE) add_subdirectory(gtsam_unstable) -endif(GTSAM_BUILD_UNSTABLE) +endif() # Matlab toolbox if (GTSAM_INSTALL_MATLAB_TOOLBOX)