Skip to content

Commit

Permalink
Merge the three streams of meta:
Browse files Browse the repository at this point in the history
* meta
* range-v3
* cmcstl2

Details:
* Modernize cmake a bit, add support for MSVC/clang-cl.

* Update CI config from range-v3, add MSVC to appveyor.

* C++20-ify requires-clauses.

* Armor `Integral` concept against non-constant expressions.

* Don't constraint all arguments of the concept implementations of `and_`, `or_`, which causes instantation defeating the short-circuiting.

* Implement `and_v` and `or_v` variable template forms of `and_c` and `or_c`.

* `detail::count_`: remove unused third template parameter.

* Remove `inline v1` namespace.
  • Loading branch information
CaseyCarter committed Jan 10, 2019
1 parent 9780f35 commit af9318f
Show file tree
Hide file tree
Showing 9 changed files with 3,764 additions and 2,962 deletions.
109 changes: 67 additions & 42 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,117 +13,133 @@
# - Louis Dionne's Hana: https://github.com/ldionne/hana
# - Paul Fultz II's FIT: https://github.com/pfultz2/Fit
language: cpp
sudo: required
script: cmake

git:
depth: 1

env:
global:
- DEPS_DIR=${TRAVIS_BUILD_DIR}/deps
- CMAKE_VERSION="3.6.3"

cache:
directories:
- ${TRAVIS_BUILD_DIR}/deps/cmake
- ${DEPS_DIR}/cmake-${CMAKE_VERSION}

matrix:
include:
- env: BUILD_TYPE=Release CPP=11
os: osx
compiler: clang

# ASAN disabled for clang < 5 builds per resolution of
# https://llvm.org/bugs/show_bug.cgi?id=22757

# clang 3.6 C++11/14 Release libc++
- env: CLANG_VERSION=3.6 BUILD_TYPE=Release CPP=11 LIBCXX=On
os: linux
addons: &clang36
apt:
packages:
- util-linux
- clang-3.6
- g++-5
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6

- env: CLANG_VERSION=3.6 BUILD_TYPE=Release CPP=14 LIBCXX=On
os: linux
addons: *clang36

# clang 3.7 C++11/14 Release libc++
- env: CLANG_VERSION=3.7 BUILD_TYPE=Release CPP=11 LIBCXX=On
os: linux
addons: &clang37
apt:
packages:
- util-linux
- clang-3.7
- g++-5
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- llvm-toolchain-trusty-3.7
- sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.7 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'

- env: CLANG_VERSION=3.7 BUILD_TYPE=Release CPP=14 LIBCXX=On
os: linux
addons: *clang37

# clang 3.8 C++11/14 Release libc++
- env: CLANG_VERSION=3.8 BUILD_TYPE=Release CPP=11 LIBCXX=On
os: linux
addons: &clang38
apt:
packages:
- util-linux
- clang-3.8
- g++-5
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8

- env: CLANG_VERSION=3.8 BUILD_TYPE=Release CPP=14 LIBCXX=On
os: linux
addons: *clang38

# clang 3.9 C++11/14 Release libc++
- env: CLANG_VERSION=3.9 BUILD_TYPE=Release CPP=11 LIBCXX=On
os: linux
addons: &clang39
apt:
packages:
- util-linux
- clang-3.9
- g++-6
- libstdc++-6-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9

- env: CLANG_VERSION=3.9 BUILD_TYPE=Release CPP=14 LIBCXX=On
os: linux
addons: *clang39

- env: CLANG_VERSION=5.0 BUILD_TYPE=Debug CPP=11 ASAN=On LIBCXX=On
# clang 5 C++11/14/1z Debug/Release libc++, 11 Debug libstdc++
- env: CLANG_VERSION=5.0 BUILD_TYPE=Debug CPP=11 LIBCXX=On
os: linux
addons: &clang5
apt:
packages:
- util-linux
- clang-5.0
- g++-6
- libstdc++-6-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise
- llvm-toolchain-trusty-5.0
- sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'

- env: CLANG_VERSION=5.0 BUILD_TYPE=Release CPP=11 LIBCXX=On
os: linux
addons: *clang5

- env: CLANG_VERSION=5.0 BUILD_TYPE=Release CPP=11 ASAN=On LIBCXX=On
- env: CLANG_VERSION=5.0 BUILD_TYPE=Debug CPP=14 LIBCXX=On
os: linux
addons: *clang5

- env: CLANG_VERSION=5.0 BUILD_TYPE=Debug CPP=14 ASAN=On LIBCXX=On
- env: CLANG_VERSION=5.0 BUILD_TYPE=Release CPP=14 LIBCXX=On
os: linux
addons: *clang5

- env: CLANG_VERSION=5.0 BUILD_TYPE=Release CPP=14 ASAN=On LIBCXX=On
- env: CLANG_VERSION=5.0 BUILD_TYPE=Debug CPP=1z LIBCXX=On
os: linux
addons: *clang5

- env: CLANG_VERSION=5.0 BUILD_TYPE=Debug CPP=1z ASAN=On LIBCXX=On
- env: CLANG_VERSION=5.0 BUILD_TYPE=Release CPP=1z LIBCXX=On
os: linux
addons: *clang5

- env: CLANG_VERSION=5.0 BUILD_TYPE=Release CPP=1z ASAN=On LIBCXX=On
- env: CLANG_VERSION=5.0 BUILD_TYPE=Release CPP=11
os: linux
addons: *clang5

# gcc-4.9 C++11/C++14 Release
- env: GCC_VERSION=4.9 BUILD_TYPE=Release CPP=11
os: linux
addons: &gcc49
Expand All @@ -137,6 +153,7 @@ matrix:
os: linux
addons: *gcc49

# gcc-5 C++11/C++14 Release
- env: GCC_VERSION=5 BUILD_TYPE=Release CPP=11
os: linux
addons: &gcc5
Expand All @@ -150,6 +167,7 @@ matrix:
os: linux
addons: *gcc5

# gcc-6 C++11/14/1z Debug/Release
- env: GCC_VERSION=6 BUILD_TYPE=Debug CPP=11
os: linux
addons: &gcc6
Expand Down Expand Up @@ -181,44 +199,51 @@ matrix:

# Install dependencies
before_install:
- export CHECKOUT_PATH=`pwd`;
- set -e
- |
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew update
brew install gnu-sed --with-default-names
brew install gnu-which --with-default-names
brew install gnu-sed
brew install gnu-which
brew upgrade cmake
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
fi
- |
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
if [ -z "$(ls -A ${TRAVIS_BUILD_DIR}/deps/cmake/bin)" ]; then
CMAKE_URL="https://cmake.org/files/v3.6/cmake-3.6.2-Linux-x86_64.tar.gz"
mkdir -p ${TRAVIS_BUILD_DIR}/deps/cmake && travis_retry wget --no-check-certificate --quiet -O - "${CMAKE_URL}" | tar --strip-components=1 -xz -C ${TRAVIS_BUILD_DIR}/deps/cmake
if [ -f ${DEPS_DIR}/cmake-${CMAKE_VERSION}/cached ]; then
echo "Using cached cmake version ${CMAKE_VERSION}."
else
CMAKE_URL="https://cmake.org/files/v3.6/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz"
mkdir -p ${DEPS_DIR}/cmake-${CMAKE_VERSION}
travis_retry wget --no-check-certificate --quiet -O - "${CMAKE_URL}" | tar --strip-components=1 -xz -C ${DEPS_DIR}/cmake-${CMAKE_VERSION}
touch ${DEPS_DIR}/cmake-${CMAKE_VERSION}/cached
fi
export PATH="${TRAVIS_BUILD_DIR}/deps/cmake/bin:${PATH}"
else
if ! brew ls --version cmake &>/dev/null; then brew install cmake; fi
export PATH="${DEPS_DIR}/cmake-${CMAKE_VERSION}/bin:${PATH}"
fi
- 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
- which $CXX
- which $CXX && $CXX --version
- which $CC
- $CXX --version
- if [ "$ASAN" == "On" ]; then export SANITIZER=Address; fi
- if [ "$LIBCXX" == "On" ]; then sudo PATH="${PATH}" CXX="$CXX" CC="$CC" ./install_libcxx.sh; fi
- if [ -n "$CLANG_VERSION" ]; then PATH="${PATH}" CXX="$CXX" CC="$CC" ./install_libcxx.sh; fi

install:
- cd $CHECKOUT_PATH
- |
if [ "$LIBCXX" == "On" ]; then
CXX_FLAGS="${CXX_FLAGS} -stdlib=libc++ -nostdinc++ -cxx-isystem ${TRAVIS_BUILD_DIR}/llvm/include/c++/v1/ -Wno-unused-command-line-argument"
CXX_LINKER_FLAGS="${CXX_LINKER_FLAGS} -L ${TRAVIS_BUILD_DIR}/llvm/lib -Wl,-rpath,${TRAVIS_BUILD_DIR}/llvm/lib -lc++abi"
fi
- mkdir -p build
- cd build
- if [ -n "$CLANG_VERSION" -a "$ASAN" == "On" ]; then CXX_FLAGS="${CXX_FLAGS} -fsanitize=address,undefined,integer -fno-omit-frame-pointer -fno-sanitize=unsigned-integer-overflow"; fi
- if [ -n "$GCC_VERSION" -a "$ASAN" == "On" ]; then CXX_FLAGS="${CXX_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer"; fi
- if [ -n "$CLANG_VERSION" ]; then CXX_FLAGS="${CXX_FLAGS} -D__extern_always_inline=inline"; fi
- if [ "$LIBCXX" == "On" ]; then CXX_FLAGS="${CXX_FLAGS} -stdlib=libc++ -nostdinc++ -cxx-isystem /usr/include/c++/v1/ -Wno-unused-command-line-argument"; fi
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${CXX_LINKER_FLAGS}" -DRANGES_CXX_STD=$CPP -DRANGE_V3_NO_HEADER_CHECK=1
# This cd works, but causes the shell to exit on OSX with set -e. I don't even.
- set +e; cd build; set -e; pwd
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" -DCMAKE_EXE_LINKER_FLAGS="${CXX_LINKER_FLAGS}" -DMETA_CXX_STD=$CPP -Wdev
- cat CMakeFiles/CMakeError.log || true
- cat CMakeFiles/CMakeOutput.log || true

- make -j2 VERBOSE=1

script:
- ctest -j2 -VV ${CTEST_FLAGS}
- ctest -j2 -VV

notifications:
email: false
47 changes: 35 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
cmake_minimum_required(VERSION 2.8)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 3.6)
get_directory_property(is_subproject PARENT_DIRECTORY)

project(Meta CXX)

if(META_CXX_STD)
else()
# Defaults to C++11 if not set:
set(META_CXX_STD 11)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Export compilation data-base

set(META_CXX_STD 11 CACHE STRING "C++ standard version.")

add_library(meta INTERFACE)
target_include_directories(meta INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
target_include_directories(meta SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)

enable_testing()
include(CTest) # invokes enable_testing() and defines BUILD_TESTING variable, defaulting to ON

include_directories(include)
if("x${CMAKE_CXX_COMPILER_ID}" MATCHES "x.*Clang")
if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
set(META_CXX_COMPILER_CLANGCL TRUE)
else()
set(META_CXX_COMPILER_CLANG TRUE)
endif()
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(META_CXX_COMPILER_GCC TRUE)
elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
set(META_CXX_COMPILER_MSVC TRUE)
endif()

if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if(META_CXX_COMPILER_CLANGCL OR META_CXX_COMPILER_MSVC)
# Clang-CL will blow up in the standard library if compiling with less than
# C++14, and MSVC doesn't support less than C++14 at all.
if(META_CXX_STD LESS 14)
set(META_CXX_STD 14)
endif()
# MSVC is currently supported only in 17+ mode
if(META_CXX_COMPILER_MSVC AND META_CXX_STD LESS 17)
set(META_CXX_STD 17)
endif()
set(CMAKE_CXX_FLAGS "/std:c++${META_CXX_STD} /permissive- /WX ${CMAKE_CXX_FLAGS}")
elseif(META_CXX_COMPILER_CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${META_CXX_STD} -ftemplate-backtrace-limit=0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Werror -pedantic-errors -Wdocumentation")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-old-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation-unknown-command -Wno-missing-prototypes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation-unknown-command -Wno-missing-prototypes")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fno-inline -g3 -fstack-protector-all")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -g0 -march=native -mtune=native -DNDEBUG")
elseif(CMAKE_COMPILER_IS_GNUCXX)
elseif(META_CXX_COMPILER_GCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${META_CXX_STD} -ftemplate-backtrace-limit=0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Werror -pedantic-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
Expand Down
51 changes: 51 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
shallow_clone: true

image: Visual Studio 2017

platform:
- x64_x86
- x64

configuration:
- Debug
- Release

environment:
matrix:
- CXX: clang-cl
CPP: latest

- CXX: cl
CPP: latest

cache:
- C:\ninja-1.8.2

install:
- ps: |
if (![IO.File]::Exists("C:\ninja-1.8.2\ninja.exe")) {
Start-FileDownload 'https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-win.zip'
7z x -y ninja-win.zip -oC:\ninja-1.8.2
}
$env:PATH="C:\ninja-1.8.2;$env:PATH"
- for /f "tokens=1* delims=" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath') do call "%%i\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM%
- cmake --version
- ninja --version
- clang-cl --version
- cl /Bv || exit 0

build_script:
- mkdir build && cd build
- ps: |
$env:CC=$env:CXX
if (($env:CXX -eq "clang-cl") -and (-not ($env:PLATFORM -eq "x64"))) {
$env:CXXFLAGS='-m32'
$env:CFLAGS='-m32'
}
- cmake .. -G Ninja -Wdev -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DMETA_CXX_STD=%CPP%
- ninja -v

test_script:
- ctest -j2 --output-on-failure

deploy: off
6 changes: 4 additions & 2 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
add_executable(tutorial_snippets tutorial_snippets.cpp)
add_test(example.tutorial_snippets, tutorial_snippets)
target_link_libraries(tutorial_snippets meta)
add_test(example.tutorial_snippets tutorial_snippets)

add_executable(tuple_cat tuple_cat.cpp)
add_test(example.tuple_cat, tuple_cat)
target_link_libraries(tuple_cat meta)
add_test(example.tuple_cat tuple_cat)
Loading

0 comments on commit af9318f

Please sign in to comment.