This commit is contained in:
hotwatermorning 2016-01-28 13:18:54 +09:00
commit 57ed4783e3
3 changed files with 54 additions and 10 deletions

View File

@ -12,12 +12,5 @@ before_install:
install:
- sudo apt-get install -y --force-yes libboost1.55-dev libboost-regex1.55-dev
before_script:
- mkdir -p build
script:
- pushd build
- cmake ..
- make
- ./test_suite
- popd
- ./travis.sh

View File

@ -1,8 +1,19 @@
cmake_minimum_required (VERSION 2.6)
project (valijson)
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_CXX_FLAGS "-std=c++11")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
if(VALIJSON_CXX11_ADAPTERS STREQUAL "disabled")
message(STATUS "Building with C++11 support disabled")
else()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
message(STATUS "Building with C++11 support enabled")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DVALIJSON_BUILD_CXX11_ADAPTERS=1")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
endif()
add_definitions(-DBOOST_ALL_DYN_LINK)
set(Boost_USE_STATIC_LIBS OFF)

40
travis.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
set -e # (errexit) Exit if any subcommand or pipeline returns a non-zero status
set -u # (nounset) Exit on any attempt to use an uninitialised variable
: ${CXX:=}
: ${TRAVIS:=false}
echo -n "Checking that we're running on Travis CI..."
if [[ $TRAVIS == 'true' ]]; then
echo " OK"
else
echo " Nope."
echo "This script is only intended for use on Travis CI."
echo "Set the TRAVIS environment variable to 'true' to override."
exit 1
fi
mkdir -p build
pushd build > /dev/null
echo "Attempting to build and run test suite with C++11 support disabled..."
cmake -DVALIJSON_CXX11_ADAPTERS=disabled ..
make
./test_suite
echo "Checking if current compiler is GCC..."
if [[ $CXX == 'g++' ]]; then
echo "Not building test suite with C++11 support due to ancient version of GCC on Travis CI"
else
echo "Attempting to build and run test suite with C++11 support enabled..."
make clean
cmake -DVALIJSON_CXX11_ADAPTERS=enabled ..
make
./test_suite
fi
make clean
popd > /dev/null