Skip to content

Commit 4886706

Browse files
authored
Merge pull request #37 from c42f/cmakeify-argh
CI setup for osx, windows and extra compilers/options on linux
2 parents 3a33bbf + df7c47d commit 4886706

File tree

5 files changed

+288
-27
lines changed

5 files changed

+288
-27
lines changed

.travis.yml

Lines changed: 189 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,195 @@ language: cpp
22

33
sudo: false
44

5-
os:
6-
- linux
5+
# C'mon Travis, you're a great service, but why do I need a script to generate my build matrix?
76

8-
compiler:
9-
- g++-4.9
7+
# cat $0 | sed -e 's/^\(.\)/# \1/' -e 's/^$/#/'
8+
#
9+
# cat <<EOF
10+
# matrix:
11+
# include:
12+
#
13+
# EOF
14+
#
15+
#
16+
# for os in linux ; do
17+
# for compiler in g++-5 clang++-3.8 ; do
18+
# for buildtype in Release Debug ; do
19+
# for std in c++98 c++11 ; do
20+
# cat <<EOF
21+
# - os: $os
22+
# compiler: $compiler
23+
# env:
24+
# - CXX_STD=$std
25+
# - COMPILER=$compiler
26+
# - BUILD_TYPE=$buildtype
27+
# EOF
28+
# if [[ $os == linux ]] ; then
29+
# cat <<EOF
30+
# addons:
31+
# apt:
32+
# sources:
33+
# - ubuntu-toolchain-r-test
34+
# - llvm-toolchain-precise-3.8
35+
# packages:
36+
# - $compiler
37+
# EOF
38+
# fi
39+
# echo
40+
# done
41+
# done
42+
# done
43+
# done
44+
matrix:
45+
include:
46+
47+
- os: linux
48+
compiler: g++-5
49+
env:
50+
- CXX_STD=c++98
51+
- COMPILER=g++-5
52+
- BUILD_TYPE=Release
53+
addons:
54+
apt:
55+
sources:
56+
- ubuntu-toolchain-r-test
57+
- llvm-toolchain-precise-3.8
58+
packages:
59+
- g++-5
60+
61+
- os: linux
62+
compiler: g++-5
63+
env:
64+
- CXX_STD=c++11
65+
- COMPILER=g++-5
66+
- BUILD_TYPE=Release
67+
addons:
68+
apt:
69+
sources:
70+
- ubuntu-toolchain-r-test
71+
- llvm-toolchain-precise-3.8
72+
packages:
73+
- g++-5
74+
75+
- os: linux
76+
compiler: g++-5
77+
env:
78+
- CXX_STD=c++98
79+
- COMPILER=g++-5
80+
- BUILD_TYPE=Debug
81+
addons:
82+
apt:
83+
sources:
84+
- ubuntu-toolchain-r-test
85+
- llvm-toolchain-precise-3.8
86+
packages:
87+
- g++-5
88+
89+
- os: linux
90+
compiler: g++-5
91+
env:
92+
- CXX_STD=c++11
93+
- COMPILER=g++-5
94+
- BUILD_TYPE=Debug
95+
addons:
96+
apt:
97+
sources:
98+
- ubuntu-toolchain-r-test
99+
- llvm-toolchain-precise-3.8
100+
packages:
101+
- g++-5
102+
103+
- os: linux
104+
compiler: clang++-3.8
105+
env:
106+
- CXX_STD=c++98
107+
- COMPILER=clang++-3.8
108+
- BUILD_TYPE=Release
109+
addons:
110+
apt:
111+
sources:
112+
- ubuntu-toolchain-r-test
113+
- llvm-toolchain-precise-3.8
114+
packages:
115+
- clang++-3.8
116+
117+
- os: linux
118+
compiler: clang++-3.8
119+
env:
120+
- CXX_STD=c++11
121+
- COMPILER=clang++-3.8
122+
- BUILD_TYPE=Release
123+
addons:
124+
apt:
125+
sources:
126+
- ubuntu-toolchain-r-test
127+
- llvm-toolchain-precise-3.8
128+
packages:
129+
- clang++-3.8
130+
131+
- os: linux
132+
compiler: clang++-3.8
133+
env:
134+
- CXX_STD=c++98
135+
- COMPILER=clang++-3.8
136+
- BUILD_TYPE=Debug
137+
addons:
138+
apt:
139+
sources:
140+
- ubuntu-toolchain-r-test
141+
- llvm-toolchain-precise-3.8
142+
packages:
143+
- clang++-3.8
144+
145+
- os: linux
146+
compiler: clang++-3.8
147+
env:
148+
- CXX_STD=c++11
149+
- COMPILER=clang++-3.8
150+
- BUILD_TYPE=Debug
151+
addons:
152+
apt:
153+
sources:
154+
- ubuntu-toolchain-r-test
155+
- llvm-toolchain-precise-3.8
156+
packages:
157+
- clang++-3.8
158+
159+
- os: osx
160+
compiler: clang
161+
env:
162+
- CXX_STD=c++98
163+
- COMPILER=clang++
164+
- BUILD_TYPE=Release
165+
166+
- os: osx
167+
compiler: clang
168+
env:
169+
- CXX_STD=c++11
170+
- COMPILER=clang++
171+
- BUILD_TYPE=Release
172+
173+
- os: osx
174+
compiler: clang
175+
env:
176+
- CXX_STD=c++98
177+
- COMPILER=clang++
178+
- BUILD_TYPE=Debug
179+
180+
- os: osx
181+
compiler: clang
182+
env:
183+
- CXX_STD=c++11
184+
- COMPILER=clang++
185+
- BUILD_TYPE=Debug
186+
187+
188+
before_script:
189+
- cmake --version
10190

11191
script:
12-
- make CXX=g++-4.9 test
13-
14-
addons:
15-
apt:
16-
sources:
17-
- ubuntu-toolchain-r-test
18-
packages:
19-
- gcc-4.9
20-
- g++-4.9
192+
- mkdir build
193+
- cd build
194+
- cmake -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCXX_STD=$CXX_STD ..
195+
- make testall
196+

CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# CMake build for tests.
2+
#
3+
# See also the Makefile, which is currently more fully featured on unix.
4+
5+
6+
# Set cmake builtin variables before calling project(), otherwise the
7+
# cmake-provided defaults will get in first!
8+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
9+
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
10+
)
11+
12+
set(CXX_STD "c++11" CACHE STRING "Version of C++ standard in use")
13+
14+
# This project is infrastructure. Warnings from common warning levels should
15+
# be errors on all compilers, unless explicitly silenced.
16+
if(NOT WIN32)
17+
set(CMAKE_CXX_FLAGS "-Wall -Werror -std=${CXX_STD}" CACHE STRING "Flags used by the compiler during all build types.")
18+
endif()
19+
20+
project(tinyformat)
21+
cmake_minimum_required(VERSION 2.8)
22+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
23+
24+
if(WIN32)
25+
# Treat warnings as errors. Would set this above, but need the default
26+
# flags too, and `project()` behaves is differently on different systems.
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX")
28+
endif()
29+
30+
add_executable(tinyformat_test tinyformat_test.cpp)
31+
enable_testing()
32+
if(CMAKE_CONFIGURATION_TYPES)
33+
set(ctest_config_opt -C ${CMAKE_BUILD_TYPE})
34+
endif()
35+
add_test(NAME test COMMAND tinyformat_test)
36+
add_custom_target(testall COMMAND ${CMAKE_CTEST_COMMAND} -V ${ctest_config_opt} DEPENDS tinyformat_test)
37+
38+
option(COMPILE_SPEED_TEST FALSE)
39+
if (COMPILE_SPEED_TEST)
40+
add_executable(tinyformat_speed_test tinyformat_speed_test.cpp)
41+
endif ()

Makefile.nmake

Lines changed: 0 additions & 12 deletions
This file was deleted.

appveyor.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Windows CI build via the Appveyor service
2+
3+
version: '{build}'
4+
5+
# branches to build
6+
branches:
7+
only:
8+
- master
9+
10+
# scripts that are called at very beginning, before repo cloning
11+
init:
12+
- git config --global core.autocrlf input
13+
14+
# Build matrix variables -
15+
# * environment
16+
# * platform
17+
# * configuration
18+
environment:
19+
matrix:
20+
- COMPILER: "Visual Studio 12 Win64"
21+
- COMPILER: "Visual Studio 14 Win64"
22+
#- COMPILER: "Visual Studio 15 Win64" # Not in appveyor standard image yet
23+
24+
# build platform, i.e. x86, x64, Any CPU.
25+
platform:
26+
- x86
27+
- x64
28+
29+
# build Configuration, i.e. Debug, Release, etc.
30+
configuration:
31+
- Debug
32+
- Release
33+
34+
before_build:
35+
- echo --------------------------------------------------------------------------------
36+
- echo Appveyor environment info:
37+
- echo COMPILER = %COMPILER%, CONFIGURATION = %CONFIGURATION%
38+
- cmake -h
39+
40+
build_script:
41+
- echo --------------------------------------------------------------------------------
42+
- echo Build tinyformat
43+
- mkdir build
44+
- cd build
45+
- cmake -G "%COMPILER%" ..
46+
- cmake --build . --config %CONFIGURATION%
47+
48+
test_script:
49+
# cmake testall target has problems finding the correct configuration, so use ctest directly.
50+
- ctest -C %CONFIGURATION%
51+

tinyformat_test.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
namespace std { class type_info; }
55
#endif
66

7+
#if defined(_MSC_VER) && _MSC_VER == 1800
8+
// Disable spurious warning about printf format string mismatch in VS 2012
9+
# pragma warning(disable:4313)
10+
#endif
11+
712
#include <stdexcept>
813
#include <climits>
914
#include <cfloat>
@@ -255,8 +260,8 @@ int unitTests()
255260
// which would noramlly go to the stdout
256261
std::ostringstream coutCapture;
257262
std::streambuf* coutBuf = std::cout.rdbuf(coutCapture.rdbuf());
258-
tfm::printf("%s %s %d\n", "printf", "test", "1");
259-
tfm::printfln("%s %s %d", "printfln", "test", "1");
263+
tfm::printf("%s %s %d\n", "printf", "test", 1);
264+
tfm::printfln("%s %s %d", "printfln", "test", 1);
260265
std::cout.rdbuf(coutBuf); // restore buffer
261266
CHECK_EQUAL(coutCapture.str(), "printf test 1\nprintfln test 1\n");
262267

0 commit comments

Comments
 (0)