Skip to content

Commit df7c47d

Browse files
committed
Appveyor CI build and MSVC tweaks
* appveyor build script * Minor cmake cleanups * Tweak tests to appease broken Visual Studio 12 warning C4313
1 parent 182e2b6 commit df7c47d

File tree

3 files changed

+72
-13
lines changed

3 files changed

+72
-13
lines changed

CMakeLists.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CMake build for tests.
22
#
3-
# See also the Makefile, which is currently more fully featured.
3+
# See also the Makefile, which is currently more fully featured on unix.
44

55

66
# Set cmake builtin variables before calling project(), otherwise the
@@ -15,24 +15,27 @@ set(CXX_STD "c++11" CACHE STRING "Version of C++ standard in use")
1515
# be errors on all compilers, unless explicitly silenced.
1616
if(NOT WIN32)
1717
set(CMAKE_CXX_FLAGS "-Wall -Werror -std=${CXX_STD}" CACHE STRING "Flags used by the compiler during all build types.")
18-
else()
19-
set(CMAKE_CXX_FLAGS "-W3 -WX")
2018
endif()
2119

2220
project(tinyformat)
2321
cmake_minimum_required(VERSION 2.8)
24-
option(COMPILE_SPEED_TEST FALSE)
25-
2622
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2723

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+
2830
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)
2937

38+
option(COMPILE_SPEED_TEST FALSE)
3039
if (COMPILE_SPEED_TEST)
3140
add_executable(tinyformat_speed_test tinyformat_speed_test.cpp)
3241
endif ()
33-
34-
enable_testing()
35-
add_test(NAME test COMMAND tinyformat_test)
36-
37-
add_custom_target(testall COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS tinyformat_test)
38-

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)