mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Added testing for c++17 to latest compilers with test with (#692)
* Added testing with std=c++17 for latest compilers Added running latest compilers with -std=c++17 option to CI the test matrix, Updated cmake configuration to allow passing c++ standard on the command line. * attempt to fix appveyor break * added clang6.0, removed c++17 tests for clang 5.0 * commented out tests for clang with c++17 die to issue #695 * Addresed comments
This commit is contained in:
parent
a9ef39f14a
commit
21cb6bb8b0
76
.travis.yml
76
.travis.yml
@ -23,23 +23,23 @@ matrix:
|
||||
##########################################################################
|
||||
|
||||
# XCode 8.3
|
||||
- env: COMPILER=clang++ BUILD_TYPE=Debug
|
||||
- env: COMPILER=clang++ BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
os: osx
|
||||
osx_image: xcode8.3
|
||||
compiler: clang
|
||||
|
||||
- env: COMPILER=clang++ BUILD_TYPE=Release
|
||||
- env: COMPILER=clang++ BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
os: osx
|
||||
osx_image: xcode8.3
|
||||
compiler: clang
|
||||
|
||||
# XCode 9.1
|
||||
- env: COMPILER=clang++ BUILD_TYPE=Debug
|
||||
- env: COMPILER=clang++ BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
os: osx
|
||||
osx_image: xcode9.1
|
||||
compiler: clang
|
||||
|
||||
- env: COMPILER=clang++ BUILD_TYPE=Release
|
||||
- env: COMPILER=clang++ BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
os: osx
|
||||
osx_image: xcode9.1
|
||||
compiler: clang
|
||||
@ -49,7 +49,7 @@ matrix:
|
||||
##########################################################################
|
||||
|
||||
# Clang 3.6
|
||||
- env: COMPILER=clang++-3.6 BUILD_TYPE=Debug
|
||||
- env: COMPILER=clang++-3.6 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &clang36
|
||||
apt:
|
||||
packages:
|
||||
@ -59,11 +59,11 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- env: COMPILER=clang++-3.6 BUILD_TYPE=Release
|
||||
- env: COMPILER=clang++-3.6 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *clang36
|
||||
|
||||
# Clang 3.7
|
||||
- env: COMPILER=clang++-3.7 BUILD_TYPE=Debug
|
||||
- env: COMPILER=clang++-3.7 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &clang37
|
||||
apt:
|
||||
packages:
|
||||
@ -73,11 +73,11 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- env: COMPILER=clang++-3.7 BUILD_TYPE=Release
|
||||
- env: COMPILER=clang++-3.7 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *clang37
|
||||
|
||||
# Clang 3.8
|
||||
- env: COMPILER=clang++-3.8 BUILD_TYPE=Debug
|
||||
- env: COMPILER=clang++-3.8 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &clang38
|
||||
apt:
|
||||
packages:
|
||||
@ -87,11 +87,11 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- env: COMPILER=clang++-3.8 BUILD_TYPE=Release
|
||||
- env: COMPILER=clang++-3.8 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *clang38
|
||||
|
||||
# Clang 3.9
|
||||
- env: COMPILER=clang++-3.9 BUILD_TYPE=Debug
|
||||
- env: COMPILER=clang++-3.9 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &clang39
|
||||
apt:
|
||||
packages:
|
||||
@ -101,11 +101,11 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- env: COMPILER=clang++-3.9 BUILD_TYPE=Release
|
||||
- env: COMPILER=clang++-3.9 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *clang39
|
||||
|
||||
# Clang 4.0
|
||||
- env: COMPILER=clang++-4.0 BUILD_TYPE=Debug
|
||||
- env: COMPILER=clang++-4.0 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &clang40
|
||||
apt:
|
||||
packages:
|
||||
@ -115,11 +115,11 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
|
||||
- env: COMPILER=clang++-4.0 BUILD_TYPE=Release
|
||||
- env: COMPILER=clang++-4.0 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *clang40
|
||||
|
||||
# Clang 5.0
|
||||
- env: COMPILER=clang++-5.0 BUILD_TYPE=Debug
|
||||
- env: COMPILER=clang++-5.0 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &clang50
|
||||
apt:
|
||||
packages:
|
||||
@ -131,46 +131,76 @@ matrix:
|
||||
- sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- env: COMPILER=clang++-5.0 BUILD_TYPE=Release
|
||||
- env: COMPILER=clang++-5.0 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *clang50
|
||||
|
||||
# Clang 6.0
|
||||
- env: COMPILER=clang++-6.0 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &clang60
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
- sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- env: COMPILER=clang++-6.0 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *clang60
|
||||
|
||||
# Does not work due to #695
|
||||
# Clang 6.0 c++17
|
||||
#- env: COMPILER=clang++-6.0 BUILD_TYPE=Debug GSL_CXX_STANDARD=17
|
||||
# addons: *clang60
|
||||
|
||||
#- env: COMPILER=clang++-6.0 BUILD_TYPE=Release GSL_CXX_STANDARD=17
|
||||
# addons: *clang60
|
||||
|
||||
##########################################################################
|
||||
# GCC on Linux
|
||||
##########################################################################
|
||||
|
||||
# GCC 5
|
||||
- env: COMPILER=g++-5 BUILD_TYPE=Debug
|
||||
- env: COMPILER=g++-5 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &gcc5
|
||||
apt:
|
||||
packages: g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- env: COMPILER=g++-5 BUILD_TYPE=Release
|
||||
- env: COMPILER=g++-5 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *gcc5
|
||||
|
||||
# GCC 6
|
||||
- env: COMPILER=g++-6 BUILD_TYPE=Debug
|
||||
- env: COMPILER=g++-6 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &gcc6
|
||||
apt:
|
||||
packages: g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- env: COMPILER=g++-6 BUILD_TYPE=Release
|
||||
- env: COMPILER=g++-6 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *gcc6
|
||||
|
||||
# GCC 7
|
||||
- env: COMPILER=g++-7 BUILD_TYPE=Debug
|
||||
- env: COMPILER=g++-7 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||
addons: &gcc7
|
||||
apt:
|
||||
packages: g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- env: COMPILER=g++-7 BUILD_TYPE=Release
|
||||
- env: COMPILER=g++-7 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||
addons: *gcc7
|
||||
|
||||
# GCC 7 c++17
|
||||
- env: COMPILER=g++-7 BUILD_TYPE=Debug GSL_CXX_STANDARD=17
|
||||
addons: *gcc7
|
||||
|
||||
- env: COMPILER=g++-7 BUILD_TYPE=Release GSL_CXX_STANDARD=17
|
||||
addons: *gcc7
|
||||
|
||||
install:
|
||||
# Set the ${CXX} variable properly
|
||||
@ -230,7 +260,7 @@ before_script:
|
||||
# have CMake to generate build files
|
||||
- cd "${TRAVIS_BUILD_DIR}"
|
||||
- mkdir build && cd build
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DGSL_CXX_STANDARD=$GSL_CXX_STANDARD
|
||||
|
||||
script:
|
||||
# build and run tests
|
||||
|
@ -14,32 +14,28 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(GSL_STANDALONE_PROJECT ON)
|
||||
endif ()
|
||||
|
||||
set(GSL_CXX_STANDARD "14" CACHE STRING "Use c++ standard")
|
||||
set(GSL_CXX_STD "cxx_std_${GSL_CXX_STANDARD}")
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
if (NOT MSVC)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
||||
if (MSVC)
|
||||
set(GSL_CXX_STD_OPT "-std:c++${GSL_CXX_STANDARD}")
|
||||
else()
|
||||
CHECK_CXX_COMPILER_FLAG("-std:c++14" COMPILER_SUPPORTS_CXX14)
|
||||
set(GSL_CXX_STD_OPT "-std=c++${GSL_CXX_STANDARD}")
|
||||
endif()
|
||||
|
||||
# when minimum version required is 3.8.0 remove if below
|
||||
# both branches do exactly the same thing
|
||||
if (CMAKE_VERSION VERSION_LESS 3.7.9)
|
||||
if (NOT MSVC)
|
||||
if(COMPILER_SUPPORTS_CXX14)
|
||||
target_compile_options(GSL INTERFACE "-std=c++14")
|
||||
else()
|
||||
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("${GSL_CXX_STD_OPT}" COMPILER_SUPPORTS_CXX_STANDARD)
|
||||
|
||||
if(COMPILER_SUPPORTS_CXX_STANDARD)
|
||||
target_compile_options(GSL INTERFACE "${GSL_CXX_STD_OPT}")
|
||||
else()
|
||||
if(COMPILER_SUPPORTS_CXX14)
|
||||
target_compile_options(GSL INTERFACE "-std:c++14")
|
||||
else()
|
||||
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no c++${GSL_CXX_STANDARD} support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
else ()
|
||||
target_compile_features(GSL INTERFACE cxx_std_14)
|
||||
target_compile_features(GSL INTERFACE "${GSL_CXX_STD}")
|
||||
# on *nix systems force the use of -std=c++XX instead of -std=gnu++XX (default)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
endif()
|
||||
@ -49,6 +45,8 @@ target_compile_definitions(GSL INTERFACE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
# remove unnecessary warnings about unchecked iterators
|
||||
_SCL_SECURE_NO_WARNINGS
|
||||
# remove deprecation warnings about std::uncaught_exception() (from catch)
|
||||
_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING
|
||||
>
|
||||
)
|
||||
|
||||
|
13
appveyor.yml
13
appveyor.yml
@ -12,6 +12,16 @@ image:
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2017
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- GSL_CXX_STANDARD: 14
|
||||
- GSL_CXX_STANDARD: 17
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- image: Visual Studio 2015
|
||||
GSL_CXX_STANDARD: 17
|
||||
|
||||
cache:
|
||||
- C:\cmake-3.8.0-win32-x86
|
||||
|
||||
@ -27,6 +37,7 @@ before_build:
|
||||
- ps: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
if ("$env:APPVEYOR_JOB_NAME" -match "Image: Visual Studio 2015") {
|
||||
$env:generator="Visual Studio 14 2015"
|
||||
} else {
|
||||
@ -36,7 +47,7 @@ before_build:
|
||||
$env:generator="$env:generator Win64"
|
||||
}
|
||||
echo generator="$env:generator"
|
||||
cmake .. -G "$env:generator"
|
||||
cmake .. -G "$env:generator" -DGSL_CXX_STANDARD="$env:GSL_CXX_STANDARD"
|
||||
|
||||
build_script:
|
||||
- cmake --build . --config %CONFIGURATION% -- /m /v:minimal
|
||||
|
@ -26,6 +26,10 @@ else()
|
||||
add_custom_target(catch)
|
||||
endif()
|
||||
|
||||
if (MSVC AND (GSL_CXX_STANDARD EQUAL 17))
|
||||
set(GSL_CPLUSPLUS_OPT -Zc:__cplusplus)
|
||||
endif()
|
||||
|
||||
# this interface adds compile options to how the tests are run
|
||||
# please try to keep entries ordered =)
|
||||
add_library(gsl_tests_config INTERFACE)
|
||||
@ -35,6 +39,7 @@ target_compile_options(gsl_tests_config INTERFACE
|
||||
/W4
|
||||
/WX
|
||||
>
|
||||
${GSL_CPLUSPLUS_OPT}
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||
-fno-strict-aliasing
|
||||
-Wall
|
||||
@ -122,6 +127,7 @@ target_compile_options(gsl_tests_config_noexcept INTERFACE
|
||||
/W4
|
||||
/WX
|
||||
>
|
||||
${GSL_CPLUSPLUS_OPT}
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||
-fno-strict-aliasing
|
||||
-fno-exceptions
|
||||
|
Loading…
Reference in New Issue
Block a user