Unverified Commit cb299375 authored by Gabi Melman's avatar Gabi Melman Committed by GitHub

Merge pull request #789 from DanielChabrowski/ci-v1

Modify travis-ci, fix compilation issues
parents f8f2d7b9 4534d523
# Adapted from various sources, including: # Adapted from various sources, including:
# - Louis Dionne's Hana: https://github.com/ldionne/hana # - Louis Dionne's Hana: https://github.com/ldionne/hana
# - Paul Fultz II's FIT: https://github.com/pfultz2/Fit # - Paul Fultz II's FIT: https://github.com/pfultz2/Fit
# - Eric Niebler's range-v3: https://github.com/ericniebler/range-v3 # - Eric Niebler's range-v3: https://github.com/ericniebler/range-v3
language: cpp sudo: required
language: cpp
# Test matrix:
# - Build matrix per compiler: C++11/C++14 + Debug/Release addons: &gcc48
# - Optionally: AddressSanitizer (ASAN) apt:
# - Valgrind: all release builds are also tested with valgrind packages:
# - clang 3.4, 3.5, 3.6, trunk - g++-4.8
# - Note: 3.4 and trunk are tested with/without ASAN, - valgrind
# the rest is only tested with ASAN=On. sources:
# - gcc 4.9, 5.0 - ubuntu-toolchain-r-test
#
matrix: addons: &gcc7
include: apt:
packages:
# Test gcc-4.8: C++11, Build=Debug/Release, ASAN=Off - g++-7
- env: GCC_VERSION=4.8 BUILD_TYPE=Debug CPP=11 ASAN=Off LIBCXX=Off - valgrind
os: linux sources:
addons: &gcc48 - ubuntu-toolchain-r-test
apt:
packages: addons: &clang35
- g++-4.8 apt:
- valgrind packages:
sources: - clang-3.5
- ubuntu-toolchain-r-test - valgrind
sources:
- env: GCC_VERSION=4.8 BUILD_TYPE=Release CPP=11 ASAN=Off LIBCXX=Off - ubuntu-toolchain-r-test
os: linux - llvm-toolchain-precise-3.5
addons: *gcc48
addons: &clang6
# Test gcc-4.9: C++11, Build=Debug/Release, ASAN=Off apt:
- env: GCC_VERSION=4.9 BUILD_TYPE=Debug CPP=11 ASAN=Off LIBCXX=Off packages:
os: linux - clang-6.0
addons: &gcc49 - valgrind
apt: sources:
packages: - ubuntu-toolchain-r-test
- g++-4.9 - llvm-toolchain-trusty-6.0
- valgrind
sources: matrix:
- ubuntu-toolchain-r-test include:
# Test gcc-4.8: C++11, Build=Debug/Release
- env: GCC_VERSION=4.9 BUILD_TYPE=Release CPP=11 ASAN=Off LIBCXX=Off - env: GCC_VERSION=4.8 BUILD_TYPE=Debug CPP=11
os: linux os: linux
addons: *gcc49 addons: *gcc48
# Install dependencies - env: GCC_VERSION=4.8 BUILD_TYPE=Release CPP=11
before_install: os: linux
- export CHECKOUT_PATH=`pwd`; addons: *gcc48
- if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi
- if [ -n "$CLANG_VERSION" ]; then export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"; fi # Test gcc-7: C++11, Build=Debug/Release
- if [ "$CLANG_VERSION" == "3.4" ]; then export CXX="/usr/local/clang-3.4/bin/clang++" CC="/usr/local/clang-3.4/bin/clang"; fi - env: GCC_VERSION=7 BUILD_TYPE=Debug CPP=11
- which $CXX os: linux
- which $CC addons: *gcc7
- which valgrind
- if [ -n "$CLANG_VERSION" ]; then sudo CXX=$CXX CC=$CC ./tests/install_libcxx.sh; fi - env: GCC_VERSION=7 BUILD_TYPE=Release CPP=11
os: linux
install: addons: *gcc7
- cd $CHECKOUT_PATH
# Test clang-3.5: C++11, Build=Debug/Release
# Workaround for valgrind bug: https://bugs.kde.org/show_bug.cgi?id=326469. - env: CLANG_VERSION=3.5 BUILD_TYPE=Debug CPP=11
# It is fixed in valgrind 3.10 so this won't be necessary if someone os: linux
# replaces the current valgrind (3.7) with valgrind-3.10 addons: *clang35
- sed -i 's/march=native/msse4.2/' example/Makefile
- env: CLANG_VERSION=3.5 BUILD_TYPE=Release CPP=11
- if [ ! -d build ]; then mkdir build; fi os: linux
- export CXX_FLAGS="-I${CHECKOUT_PATH}/include" addons: *clang35
- export CXX_LINKER_FLAGS=""
- if [ -z "$BUILD_TYPE" ]; then export BUILD_TYPE=Release; fi # Test clang-6.0: C++11, Build=Debug, ASAN=On
- if [ "$ASAN" == "On"]; then export CXX_FLAGS="${CXX_FLAGS} -fsanitize=address,undefined,integer -fno-omit-frame-pointer -fno-sanitize=unsigned-integer-overflow"; fi - env: CLANG_VERSION=6.0 BUILD_TYPE=Debug CPP=11 ASAN=On
- if [ -n "$CLANG_VERSION" ]; then CXX_FLAGS="${CXX_FLAGS} -D__extern_always_inline=inline"; fi os: linux
- if [ "$LIBCXX" == "On" ]; then CXX_FLAGS="${CXX_FLAGS} -stdlib=libc++ -I/usr/include/c++/v1/"; fi addons: *clang6
- if [ "$LIBCXX" == "On" ]; then CXX_LINKER_FLAGS="${CXX_FLAGS} -L/usr/lib/ -lc++"; fi
- CXX_FLAGS="${CXX_FLAGS} -std=c++${CPP}" before_install:
- if [ -n "$GCC_VERSION" ]; then export CXX="g++-${GCC_VERSION}" CC="gcc-${GCC_VERSION}"; fi
# Build examples - if [ -n "$CLANG_VERSION" ]; then export CXX="clang++-${CLANG_VERSION}" CC="clang-${CLANG_VERSION}"; fi
- cd example - which $CXX
- if [ "$BUILD_TYPE" == "Release" ]; then make rebuild CXXFLAGS="${CXX_FLAGS} ${CXX_LINKER_FLAGS}" VERBOSE=1; export BIN=example; fi - which $CC
- if [ "$BUILD_TYPE" == "Debug" ]; then make rebuild debug CXXFLAGS="${CXX_FLAGS} ${CXX_LINKER_FLAGS}" VERBOSE=1; export BIN=example-debug; fi - which valgrind
- $CXX --version
- cmake --version
script: - valgrind --version
- ./"${BIN}"
- valgrind --trace-children=yes --leak-check=full ./"${BIN}" install:
- cd $CHECKOUT_PATH/tests; make rebuild; ./tests - cd ${TRAVIS_BUILD_DIR}
- cd $CHECKOUT_PATH/tests; STYLE=printf make rebuild; ./tests - mkdir -p build && cd build
- |
notifications: cmake .. \
email: false --warn-uninitialized \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_CXX_STANDARD=$CPP \
-DSPDLOG_BUILD_EXAMPLES=ON \
-DSPDLOG_SANITIZE_ADDRESS=$ASAN
- VERBOSE=1 make -j2
script:
- if [ "$ASAN" != "On" ]; then CTEST_FLAGS="-DExperimentalMemCheck"; fi
- ctest -j2 -VV $CTEST_FLAGS
notifications:
email: false
...@@ -14,15 +14,19 @@ include(GNUInstallDirs) ...@@ -14,15 +14,19 @@ include(GNUInstallDirs)
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "-Wall -O3 ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-Wall -O3 ${CMAKE_CXX_FLAGS}")
endif() endif()
include(cmake/sanitizers.cmake)
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------
# spdlog target # spdlog target
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------
add_library(spdlog INTERFACE) add_library(spdlog INTERFACE)
add_library(spdlog::spdlog ALIAS spdlog)
option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF) option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF)
cmake_dependent_option(SPDLOG_BUILD_TESTING cmake_dependent_option(SPDLOG_BUILD_TESTING
......
if(SPDLOG_SANITIZE_THREAD AND SPDLOG_SANITIZE_ADDRESS)
message(FATAL_ERROR "AddressSanitizer is not compatible with ThreadSanitizer.")
endif()
if(SPDLOG_SANITIZE_ADDRESS)
message(STATUS "AddressSanitizer enabled")
set(SANITIZER_FLAGS "-fsanitize=address,undefined")
add_compile_options("-fno-sanitize=signed-integer-overflow")
endif()
if(SPDLOG_SANITIZE_THREAD)
message(STATUS "ThreadSanitizer enabled")
set(SANITIZER_FLAGS "-fsanitize=thread")
endif()
if(SPDLOG_SANITIZE_THREAD OR SPDLOG_SANITIZE_ADDRESS)
add_compile_options(${SANITIZER_FLAGS})
add_compile_options("-fno-sanitize-recover=all")
add_compile_options("-fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS} -fuse-ld=gold")
endif()
...@@ -24,10 +24,7 @@ ...@@ -24,10 +24,7 @@
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
project(SpdlogExamples CXX) project(SpdlogExamples CXX)
if(TARGET spdlog) if(NOT TARGET spdlog)
# Part of the main project
add_library(spdlog::spdlog ALIAS spdlog)
else()
# Stand-alone build # Stand-alone build
find_package(spdlog CONFIG REQUIRED) find_package(spdlog CONFIG REQUIRED)
endif() endif()
...@@ -37,13 +34,10 @@ find_package(Threads REQUIRED) ...@@ -37,13 +34,10 @@ find_package(Threads REQUIRED)
add_executable(example example.cpp) add_executable(example example.cpp)
target_link_libraries(example spdlog::spdlog Threads::Threads) target_link_libraries(example spdlog::spdlog Threads::Threads)
add_executable(benchmark bench.cpp)
target_link_libraries(benchmark spdlog::spdlog Threads::Threads)
add_executable(multisink multisink.cpp) add_executable(multisink multisink.cpp)
target_link_libraries(multisink spdlog::spdlog Threads::Threads) target_link_libraries(multisink spdlog::spdlog Threads::Threads)
enable_testing() enable_testing()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
add_test(NAME RunExample COMMAND example) add_test(NAME example COMMAND example)
add_test(NAME RunBenchmark COMMAND benchmark) add_test(NAME multisink COMMAND multisink)
#include "spdlog/sinks/file_sinks.h" #include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_sinks.h" #include "spdlog/sinks/stdout_sinks.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include <iostream> #include <iostream>
......
...@@ -18,7 +18,7 @@ set(SPDLOG_UTESTS_SOURCES ...@@ -18,7 +18,7 @@ set(SPDLOG_UTESTS_SOURCES
add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES}) add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog) target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog)
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
#!/bin/bash
#
# Install libc++ under travis
svn --quiet co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
mkdir libcxx/build
(cd libcxx/build && cmake .. -DLIBCXX_CXX_ABI=libstdc++ -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.6;/usr/include/c++/4.6/x86_64-linux-gnu")
make -C libcxx/build cxx -j2
sudo cp libcxx/build/lib/libc++.so.1.0 /usr/lib/
sudo cp -r libcxx/build/include/c++/v1 /usr/include/c++/v1/
sudo ln -sf /usr/lib/libc++.so.1.0 /usr/lib/libc++.so
sudo ln -sf /usr/lib/libc++.so.1.0 /usr/lib/libc++.so.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment