Skip to content

Commit 9e3c1a0

Browse files
authored
Merge pull request #17 from m-peko/support-cpp11-cpp14
Support C++11 and C++14
2 parents 85e8375 + b035030 commit 9e3c1a0

File tree

5 files changed

+301
-73
lines changed

5 files changed

+301
-73
lines changed

.travis.yml

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ notifications:
66
matrix:
77
include:
88

9-
- name: "Linux GCC"
9+
- name: "Linux GCC C++11"
1010
os: linux
1111
dist: bionic
1212
compiler: gcc
@@ -18,11 +18,49 @@ matrix:
1818
- gcc-8
1919
- g++-8
2020
before_script:
21+
- CPP_VERSION=11
22+
23+
# Install new alternatives
24+
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 30
25+
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 30
26+
27+
- name: "Linux GCC C++14"
28+
os: linux
29+
dist: bionic
30+
compiler: gcc
31+
addons:
32+
apt:
33+
sources:
34+
- ubuntu-toolchain-r-test
35+
packages:
36+
- gcc-8
37+
- g++-8
38+
before_script:
39+
- CPP_VERSION=14
40+
2141
# Install new alternatives
2242
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 30
2343
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 30
2444

25-
- name: "Linux CLANG"
45+
- name: "Linux GCC C++17"
46+
os: linux
47+
dist: bionic
48+
compiler: gcc
49+
addons:
50+
apt:
51+
sources:
52+
- ubuntu-toolchain-r-test
53+
packages:
54+
- gcc-8
55+
- g++-8
56+
before_script:
57+
- CPP_VERSION=17
58+
59+
# Install new alternatives
60+
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 30
61+
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 30
62+
63+
- name: "Linux CLANG C++11"
2664
os: linux
2765
dist: bionic
2866
compiler: clang
@@ -34,10 +72,56 @@ matrix:
3472
- gcc-8
3573
- g++-8
3674
- clang-7
75+
before_script:
76+
- CPP_VERSION=11
3777

38-
- name: "Windows MSVC"
78+
- name: "Linux CLANG C++14"
79+
os: linux
80+
dist: bionic
81+
compiler: clang
82+
addons:
83+
apt:
84+
sources:
85+
- ubuntu-toolchain-r-test
86+
packages:
87+
- gcc-8
88+
- g++-8
89+
- clang-7
90+
before_script:
91+
- CPP_VERSION=14
92+
93+
- name: "Linux CLANG C++17"
94+
os: linux
95+
dist: bionic
96+
compiler: clang
97+
addons:
98+
apt:
99+
sources:
100+
- ubuntu-toolchain-r-test
101+
packages:
102+
- gcc-8
103+
- g++-8
104+
- clang-7
105+
before_script:
106+
- CPP_VERSION=17
107+
108+
- name: "Windows MSVC C++11"
39109
os: windows
40110
compiler: msvc
111+
before_script:
112+
- CPP_VERSION=11
113+
114+
- name: "Windows MSVC C++14"
115+
os: windows
116+
compiler: msvc
117+
before_script:
118+
- CPP_VERSION=14
119+
120+
- name: "Windows MSVC C++17"
121+
os: windows
122+
compiler: msvc
123+
before_script:
124+
- CPP_VERSION=17
41125

42126
- name: "Linux GCC Code Coverage"
43127
os: linux
@@ -71,7 +155,7 @@ script:
71155
- cd build
72156

73157
# Generate build files
74-
- cmake .. -DBITFLAGS_ENABLE_COVERAGE:BOOL=${ENABLE_COVERAGE-False}
158+
- cmake .. -DBITFLAGS_CPP_VERSION:INTEGER=${CPP_VERSION-17} -DBITFLAGS_ENABLE_COVERAGE:BOOL=${ENABLE_COVERAGE-False}
75159

76160
# Compile examples and tests
77161
# - cmake --build . --target samples

CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ else ()
3333
)
3434
endif ()
3535

36-
set (CMAKE_CXX_STANDARD 17)
36+
if (BITFLAGS_CPP_VERSION EQUAL 17)
37+
message (STATUS "Using C++17")
38+
elseif (BITFLAGS_CPP_VERSION EQUAL 14)
39+
message (STATUS "Using C++14")
40+
elseif (BITFLAGS_CPP_VERSION EQUAL 11)
41+
message (STATUS "Using C++11")
42+
endif ()
43+
44+
set (CMAKE_CXX_STANDARD ${BITFLAGS_CPP_VERSION})
3745
set (CMAKE_CXX_STANDARD_REQUIRED ON)
3846
set (CMAKE_CXX_EXTENSIONS OFF)
3947

@@ -54,12 +62,12 @@ endif ()
5462
option (BITFLAGS_BUILD_SAMPLES "Build examples" ON)
5563
option (BITFLAGS_BUILD_TESTS "Build tests" ON)
5664

57-
include(GNUInstallDirs)
65+
include (GNUInstallDirs)
5866

5967
add_library (bitflags INTERFACE)
6068
add_library (bitflags::bitflags ALIAS bitflags)
6169

62-
target_compile_features (bitflags INTERFACE cxx_std_17)
70+
target_compile_features (bitflags INTERFACE cxx_std_${BITFLAGS_CPP_VERSION})
6371
target_include_directories (
6472
bitflags INTERFACE
6573
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@@ -91,8 +99,8 @@ if (BITFLAGS_BUILD_TESTS)
9199
endif ()
92100

93101
if (NOT BITFLAGS_SUBPROJECT)
94-
include(CMakePackageConfigHelpers)
95-
102+
include (CMakePackageConfigHelpers)
103+
96104
install (TARGETS bitflags EXPORT bitflags-config)
97105

98106
write_basic_package_version_file (

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
<img src="img/logo.png" height="120px"/>
44

5-
Single-header header-only C++17 library for easily managing set of auto-generated type-safe flags.
5+
Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags.
66

77
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/m-peko/bitflags/blob/master/LICENSE)
88
[![Build Status](https://travis-ci.org/m-peko/bitflags.svg?branch=master)](https://travis-ci.org/m-peko/bitflags)
99
[![Codecov](https://codecov.io/gh/m-peko/bitflags/branch/master/graph/badge.svg)](https://codecov.io/gh/m-peko/bitflags)
10+
[![Standard](https://img.shields.io/badge/C%2B%2B-11-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B11)
11+
[![Standard](https://img.shields.io/badge/C%2B%2B-14-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B14)
1012
[![Standard](https://img.shields.io/badge/C%2B%2B-17-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B17)
1113
[![Compiler explorer](https://img.shields.io/badge/compiler_explorer-online-blue.svg)](https://godbolt.org/z/KPG963)
1214

@@ -93,7 +95,7 @@ _So, why should I use `bitflags` library?_
9395

9496
## Getting Started
9597

96-
`bitflags` is a single-header header-only C++17 library for easily managing set of auto-generated type-safe flags.
98+
`bitflags` is a single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags.
9799

98100
### Raw flags vs flags?
99101

0 commit comments

Comments
 (0)