Unverified Commit 3b0ec84a authored by Peter Steinbach's avatar Peter Steinbach Committed by GitHub

Merge pull request #10 from psteinb/test-matrix

Test matrix
parents f3e3380b 4f4ac79d
# C++ project
language: cpp
dist: trusty
rvm:
- 2.3
matrix:
include:
# works on Precise and Trusty
# - os: linux
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - g++-4.9
# env:
# - MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
env:
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
- os: osx
osx_image: xcode9
env:
- MATRIX_EVAL="CC=gcc && CXX=g++"
- os: osx
osx_image: xcode9.3
env:
- MATRIX_EVAL="brew install gcc; brew link --overwrite gcc && CC=gcc-7 && CXX=g++-7"
- os: osx
osx_image: xcode9
env:
- MATRIX_EVAL="CC=clang && CXX=clang"
before_install:
- eval "${MATRIX_EVAL}"
script:
- mkdir -p build && cd build
- cmake ..
- make
- make VERBOSE=1
- ctest -V -j
- cd ..
\ No newline at end of file
......@@ -11,6 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckSymbolExists)
include(CheckCXXSourceCompiles)
# Project information
SET (COMPASS_NAME "Compass - drop-in header-only C++ library to detect hardware capabilities at runtime and at compiletime")
......@@ -36,6 +37,20 @@ check_cxx_compiler_flag(-Wl,-Bsymbolic HAS_BSYMBOLIC_COMPILERFLAG)
check_cxx_compiler_flag("-Xclang -march=native" HAS_XCLANG_COMPILERFLAG)
check_cxx_compiler_flag(-Wall HAS_WALL_COMPILERFLAG)
check_cxx_compiler_flag(-ggdb HAS_GGDB_COMPILERFLAG)
set(CXX11_CODE_EXAMPLE "\
#include <string>\n\
\
int main(int argc,char** argv){std::string msg;return msg.size();}")
set(CMAKE_REQUIRED_LIBRARIES -lc++ -lc++abi)
CHECK_CXX_SOURCE_COMPILES("${CXX11_CODE_EXAMPLE}" COMPILES_WITH_LIBCXX)
set(CMAKE_REQUIRED_LIBRARIES -lstdc++)
CHECK_CXX_SOURCE_COMPILES("${CXX11_CODE_EXAMPLE}" COMPILES_WITH_LIBSTDCXX)
unset(CMAKE_REQUIRED_LIBRARIES)
CHECK_CXX_SOURCE_COMPILES("${CXX11_CODE_EXAMPLE}" COMPILES_WITH_NO_EXTRAL)
check_cxx_compiler_flag(-lc++ HAS_LIBCXX_COMPILERFLAG)
check_cxx_compiler_flag(-lc++abi HAS_LIBCXXABI_COMPILERFLAG)
check_cxx_compiler_flag(-ggdb3 HAS_GGDB3_COMPILERFLAG)
check_cxx_compiler_flag(-O3 HAS_O3_COMPILERFLAG)
check_cxx_compiler_flag(/Oi HAS_OI_COMPILERFLAG)
......@@ -73,7 +88,7 @@ target_include_directories(
target_compile_definitions(${COMPASS_TARGET_NAME}
INTERFACE LIBRARY_HEADER_ONLY
INTERFACE cxx_std_11
)
)
## ============== generate single-header ================
if (${GENERATE_SINGLE_HEADER})
......@@ -103,7 +118,7 @@ endif()
IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.0")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.0")
set(WITH_CXX11_ABI ON)
endif()
......@@ -114,9 +129,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_
endif()
target_compile_definitions(${COMPASS_TARGET_NAME} INTERFACE -D_GLIBCXX_USE_CXX11_ABI=${CXX11_ABI_VALUE})
message(">> [GCC ${CMAKE_CXX_COMPILER_VERSION}] adding -D_GLIBCXX_USE_CXX11_ABI=${CXX11_ABI_VALUE}")
message(">> [${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}] adding -D_GLIBCXX_USE_CXX11_ABI=${CXX11_ABI_VALUE}")
endif()
IF(NOT WIN32)
check_symbol_exists(__get_cpuid_max "cpuid.h" GET_CPUID_MAX_INSTRINSIC_EXISTS)
check_symbol_exists(__cpuid_count "cpuid.h" GET_CPUID_COUNT_MACRO_INSTRINSIC_EXISTS)
......
[![Build Status](https://travis-ci.org/psteinb/compass.svg?branch=master)](https://travis-ci.org/psteinb/compass)
[![Build status](https://ci.appveyor.com/api/projects/status/dvgk88ynuuvx1ldi/branch/master?svg=true)](https://ci.appveyor.com/project/psteinb/compass/branch/master)
# compass
......
version: '{build}'
os:
- Visual Studio 2015
- Visual Studio 2017
environment:
matrix:
- additional_flags: ""
init: []
install: []
build_script:
- IF "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2015" ( SET GEN="Visual Studio 14 2015") ELSE (SET GEN="Visual Studio 15 2017")
- cmake . -G%GEN% # -DCMAKE_CXX_FLAGS="%additional_flags%"
- cmake --build . --config Release
test_script:
- ctest -C Release -V -j
\ No newline at end of file
#ifndef COMPASS_X86_CPUID_COMMON_H
#define COMPASS_X86_CPUID_COMMON_H
#ifndef COMPASS_CT_COMP_MSVC
#include "cpuid.h"
namespace compass {
......@@ -39,5 +40,5 @@ namespace compass {
}; // runtime
}; //compass
#endif /* COMPASS_CT_COMP_MSVC */
#endif /* COMPASS_X86_CPUID_COMMON_H */
......@@ -3,8 +3,8 @@ include(ExternalProject)
ExternalProject_Add(
catch2
PREFIX ${CMAKE_BINARY_DIR}/tests
URL https://raw.githubusercontent.com/catchorg/Catch2/v2.0.1/single_include/catch.hpp
URL_MD5 9b3d2cb5c0f9532cddfbbfd0a622f0af
URL https://raw.githubusercontent.com/catchorg/Catch2/v2.2.2/single_include/catch.hpp
URL_MD5 40b58ea3607594234e53e1748240876f
DOWNLOAD_NO_EXTRACT TRUE
TIMEOUT 10
CONFIGURE_COMMAND ""
......@@ -23,8 +23,28 @@ add_executable(test_compass_impl test_compass_impl.cpp $<TARGET_OBJECTS:catcho>)
target_include_directories(test_compass_impl PRIVATE ${CATCH2_HEADER_PATH} ${COMPASS_INCLUDE_BUILD_DIR})
add_executable(test_bitview test_bitview.cpp $<TARGET_OBJECTS:catcho>)
target_include_directories(test_bitview PRIVATE ${PROJECT_SOURCE_DIR}/include ${CATCH2_HEADER_PATH})
target_include_directories(test_bitview PRIVATE ${CATCH2_HEADER_PATH} ${COMPASS_INCLUDE_BUILD_DIR} )
if("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang")
if(NOT "${COMPILES_WITH_NO_EXTRAL}")
message(STATUS "detected malacious support of libc++/libstdc++")
if(${COMPILES_WITH_LIBCXX})
message(STATUS "adding c++ c++abi to test binary dependencies")
target_link_libraries(test_compass_impl c++ c++abi)
target_link_libraries(test_bitview c++ c++abi)
else()
if(${COMPILES_WITH_LIBSTDCXX})
message(STATUS "adding stdc++ to test binary dependencies")
target_link_libraries(test_compass_impl stdc++)
target_link_libraries(test_bitview stdc++)
endif()
endif()
endif()
endif()
#idea for generating test fixture at cmake-invocation
#Windows 7: use `wmic cpu GET Name` to obtain clearname of CPU model
......@@ -41,25 +61,19 @@ if(${CURRENT_HOSTNAME} MATCHES ".*(falcon2|talisker|schorle|scicomp-pc-3|recover
add_executable(test_compass_sizes test_compass_sizes.cpp $<TARGET_OBJECTS:catcho>)
target_include_directories(test_compass_sizes PRIVATE ${CATCH2_HEADER_PATH} ${COMPASS_INCLUDE_BUILD_DIR})
endif()
### test single header
if("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang" AND NOT "${COMPILES_WITH_NO_EXTRAL}")
if(${COMPILES_WITH_LIBCXX})
target_link_libraries(test_compass_sizes c++ c++abi)
target_link_libraries(test_machine c++ c++abi)
else()
if(${COMPILES_WITH_LIBSTDCXX})
target_link_libraries(test_compass_sizes stdc++)
target_link_libraries(test_machine stdc++)
endif()
# if(WITH_SINGLE_HEADER)
# find_program(PCPP NAME pcpp HINT ${PCPP_PATH})
# if(PCPP_FOUND OR EXISTS ${PCPP_PATH})
# add_custom_target(sh
# COMMAND pcpp -o ${PROJECT_BINARY_DIR}/tests/compass-sh.hpp --line-directive --passthru-defines --passthru-unfound-includes --passthru-unknown-exprs ${PROJECT_SOURCE_DIR}/include/compass.hpp
# BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/compass-sh.hpp
# COMMENT "Preprocessing ${PROJECT_SOURCE_DIR}/include/compass.hpp into ${CMAKE_CURRENT_BINARY_DIR}/tests/compass-sh.hpp ..."
# USES_TERMINAL)
endif()
# add_executable(test_single_header test_single_header.cpp $<TARGET_OBJECTS:catcho> ${CMAKE_CURRENT_BINARY_DIR}/compass-sh.hpp)
# add_dependencies(test_single_header sh)
# target_include_directories(test_single_header PRIVATE ${PROJECT_BINARY_DIR}/tests ${CATCH2_HEADER_PATH})
# else()
# message(WARNING "pcpp not found ${PCPP_PATH}")
# endif()
endif()
# endif()
endif()
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