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
78
.travis.yml
78
.travis.yml
@ -23,23 +23,23 @@ matrix:
|
|||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
# XCode 8.3
|
# XCode 8.3
|
||||||
- env: COMPILER=clang++ BUILD_TYPE=Debug
|
- env: COMPILER=clang++ BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode8.3
|
osx_image: xcode8.3
|
||||||
compiler: clang
|
compiler: clang
|
||||||
|
|
||||||
- env: COMPILER=clang++ BUILD_TYPE=Release
|
- env: COMPILER=clang++ BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode8.3
|
osx_image: xcode8.3
|
||||||
compiler: clang
|
compiler: clang
|
||||||
|
|
||||||
# XCode 9.1
|
# XCode 9.1
|
||||||
- env: COMPILER=clang++ BUILD_TYPE=Debug
|
- env: COMPILER=clang++ BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode9.1
|
osx_image: xcode9.1
|
||||||
compiler: clang
|
compiler: clang
|
||||||
|
|
||||||
- env: COMPILER=clang++ BUILD_TYPE=Release
|
- env: COMPILER=clang++ BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||||
os: osx
|
os: osx
|
||||||
osx_image: xcode9.1
|
osx_image: xcode9.1
|
||||||
compiler: clang
|
compiler: clang
|
||||||
@ -49,7 +49,7 @@ matrix:
|
|||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
# Clang 3.6
|
# 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
|
addons: &clang36
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
@ -59,11 +59,11 @@ matrix:
|
|||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.6
|
- 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
|
addons: *clang36
|
||||||
|
|
||||||
# Clang 3.7
|
# 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
|
addons: &clang37
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
@ -73,11 +73,11 @@ matrix:
|
|||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.7
|
- 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
|
addons: *clang37
|
||||||
|
|
||||||
# Clang 3.8
|
# 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
|
addons: &clang38
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
@ -87,11 +87,11 @@ matrix:
|
|||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.8
|
- 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
|
addons: *clang38
|
||||||
|
|
||||||
# Clang 3.9
|
# 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
|
addons: &clang39
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
@ -101,11 +101,11 @@ matrix:
|
|||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-precise-3.9
|
- 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
|
addons: *clang39
|
||||||
|
|
||||||
# Clang 4.0
|
# 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
|
addons: &clang40
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
@ -115,11 +115,11 @@ matrix:
|
|||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
- llvm-toolchain-trusty-4.0
|
- 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
|
addons: *clang40
|
||||||
|
|
||||||
# Clang 5.0
|
# 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
|
addons: &clang50
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
@ -131,46 +131,76 @@ matrix:
|
|||||||
- sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main'
|
- sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main'
|
||||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
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
|
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 on Linux
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
# GCC 5
|
# GCC 5
|
||||||
- env: COMPILER=g++-5 BUILD_TYPE=Debug
|
- env: COMPILER=g++-5 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||||
addons: &gcc5
|
addons: &gcc5
|
||||||
apt:
|
apt:
|
||||||
packages: g++-5
|
packages: g++-5
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
- env: COMPILER=g++-5 BUILD_TYPE=Release
|
- env: COMPILER=g++-5 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||||
addons: *gcc5
|
addons: *gcc5
|
||||||
|
|
||||||
# GCC 6
|
# GCC 6
|
||||||
- env: COMPILER=g++-6 BUILD_TYPE=Debug
|
- env: COMPILER=g++-6 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||||
addons: &gcc6
|
addons: &gcc6
|
||||||
apt:
|
apt:
|
||||||
packages: g++-6
|
packages: g++-6
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
- env: COMPILER=g++-6 BUILD_TYPE=Release
|
- env: COMPILER=g++-6 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||||
addons: *gcc6
|
addons: *gcc6
|
||||||
|
|
||||||
# GCC 7
|
# GCC 7
|
||||||
- env: COMPILER=g++-7 BUILD_TYPE=Debug
|
- env: COMPILER=g++-7 BUILD_TYPE=Debug GSL_CXX_STANDARD=14
|
||||||
addons: &gcc7
|
addons: &gcc7
|
||||||
apt:
|
apt:
|
||||||
packages: g++-7
|
packages: g++-7
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
|
|
||||||
- env: COMPILER=g++-7 BUILD_TYPE=Release
|
- env: COMPILER=g++-7 BUILD_TYPE=Release GSL_CXX_STANDARD=14
|
||||||
addons: *gcc7
|
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:
|
install:
|
||||||
# Set the ${CXX} variable properly
|
# Set the ${CXX} variable properly
|
||||||
@ -230,7 +260,7 @@ before_script:
|
|||||||
# have CMake to generate build files
|
# have CMake to generate build files
|
||||||
- cd "${TRAVIS_BUILD_DIR}"
|
- cd "${TRAVIS_BUILD_DIR}"
|
||||||
- mkdir build && cd build
|
- mkdir build && cd build
|
||||||
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DGSL_CXX_STANDARD=$GSL_CXX_STANDARD
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# build and run tests
|
# build and run tests
|
||||||
|
@ -14,32 +14,28 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|||||||
set(GSL_STANDALONE_PROJECT ON)
|
set(GSL_STANDALONE_PROJECT ON)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
set(GSL_CXX_STANDARD "14" CACHE STRING "Use c++ standard")
|
||||||
|
set(GSL_CXX_STD "cxx_std_${GSL_CXX_STANDARD}")
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
if (MSVC)
|
||||||
if (NOT MSVC)
|
set(GSL_CXX_STD_OPT "-std:c++${GSL_CXX_STANDARD}")
|
||||||
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
|
||||||
else()
|
else()
|
||||||
CHECK_CXX_COMPILER_FLAG("-std:c++14" COMPILER_SUPPORTS_CXX14)
|
set(GSL_CXX_STD_OPT "-std=c++${GSL_CXX_STANDARD}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# when minimum version required is 3.8.0 remove if below
|
# when minimum version required is 3.8.0 remove if below
|
||||||
# both branches do exactly the same thing
|
# both branches do exactly the same thing
|
||||||
if (CMAKE_VERSION VERSION_LESS 3.7.9)
|
if (CMAKE_VERSION VERSION_LESS 3.7.9)
|
||||||
if (NOT MSVC)
|
include(CheckCXXCompilerFlag)
|
||||||
if(COMPILER_SUPPORTS_CXX14)
|
CHECK_CXX_COMPILER_FLAG("${GSL_CXX_STD_OPT}" COMPILER_SUPPORTS_CXX_STANDARD)
|
||||||
target_compile_options(GSL INTERFACE "-std=c++14")
|
|
||||||
else()
|
if(COMPILER_SUPPORTS_CXX_STANDARD)
|
||||||
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
|
target_compile_options(GSL INTERFACE "${GSL_CXX_STD_OPT}")
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
if(COMPILER_SUPPORTS_CXX14)
|
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no c++${GSL_CXX_STANDARD} support. Please use a different C++ compiler.")
|
||||||
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()
|
|
||||||
endif()
|
endif()
|
||||||
else ()
|
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)
|
# on *nix systems force the use of -std=c++XX instead of -std=gnu++XX (default)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
endif()
|
endif()
|
||||||
@ -49,6 +45,8 @@ target_compile_definitions(GSL INTERFACE
|
|||||||
$<$<CXX_COMPILER_ID:MSVC>:
|
$<$<CXX_COMPILER_ID:MSVC>:
|
||||||
# remove unnecessary warnings about unchecked iterators
|
# remove unnecessary warnings about unchecked iterators
|
||||||
_SCL_SECURE_NO_WARNINGS
|
_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 2015
|
||||||
- Visual Studio 2017
|
- Visual Studio 2017
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- GSL_CXX_STANDARD: 14
|
||||||
|
- GSL_CXX_STANDARD: 17
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
exclude:
|
||||||
|
- image: Visual Studio 2015
|
||||||
|
GSL_CXX_STANDARD: 17
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
- C:\cmake-3.8.0-win32-x86
|
- C:\cmake-3.8.0-win32-x86
|
||||||
|
|
||||||
@ -27,6 +37,7 @@ before_build:
|
|||||||
- ps: |
|
- ps: |
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
|
||||||
if ("$env:APPVEYOR_JOB_NAME" -match "Image: Visual Studio 2015") {
|
if ("$env:APPVEYOR_JOB_NAME" -match "Image: Visual Studio 2015") {
|
||||||
$env:generator="Visual Studio 14 2015"
|
$env:generator="Visual Studio 14 2015"
|
||||||
} else {
|
} else {
|
||||||
@ -36,7 +47,7 @@ before_build:
|
|||||||
$env:generator="$env:generator Win64"
|
$env:generator="$env:generator Win64"
|
||||||
}
|
}
|
||||||
echo generator="$env:generator"
|
echo generator="$env:generator"
|
||||||
cmake .. -G "$env:generator"
|
cmake .. -G "$env:generator" -DGSL_CXX_STANDARD="$env:GSL_CXX_STANDARD"
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- cmake --build . --config %CONFIGURATION% -- /m /v:minimal
|
- cmake --build . --config %CONFIGURATION% -- /m /v:minimal
|
||||||
|
@ -26,6 +26,10 @@ else()
|
|||||||
add_custom_target(catch)
|
add_custom_target(catch)
|
||||||
endif()
|
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
|
# this interface adds compile options to how the tests are run
|
||||||
# please try to keep entries ordered =)
|
# please try to keep entries ordered =)
|
||||||
add_library(gsl_tests_config INTERFACE)
|
add_library(gsl_tests_config INTERFACE)
|
||||||
@ -35,6 +39,7 @@ target_compile_options(gsl_tests_config INTERFACE
|
|||||||
/W4
|
/W4
|
||||||
/WX
|
/WX
|
||||||
>
|
>
|
||||||
|
${GSL_CPLUSPLUS_OPT}
|
||||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||||
-fno-strict-aliasing
|
-fno-strict-aliasing
|
||||||
-Wall
|
-Wall
|
||||||
@ -122,6 +127,7 @@ target_compile_options(gsl_tests_config_noexcept INTERFACE
|
|||||||
/W4
|
/W4
|
||||||
/WX
|
/WX
|
||||||
>
|
>
|
||||||
|
${GSL_CPLUSPLUS_OPT}
|
||||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||||
-fno-strict-aliasing
|
-fno-strict-aliasing
|
||||||
-fno-exceptions
|
-fno-exceptions
|
||||||
|
Loading…
Reference in New Issue
Block a user