Skip to content

Commit 7ef51f6

Browse files
committed
Merge pull request yhirose#21 from hvellyr/master
Supporting CI on windows (using appveyor) and more compiler warning fixes
2 parents b07573e + f98f869 commit 7ef51f6

File tree

8 files changed

+69
-13
lines changed

8 files changed

+69
-13
lines changed

CMakeLists.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
cmake_minimum_required(VERSION 2.8)
2-
add_definitions("-std=c++1y")
32

43
# Check if a supported compiler is used and add c++14 flag:
54
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
65
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
76
message(FATAL_ERROR "Need at least gcc 4.9 to compile.")
87
endif()
98
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
10-
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
9+
elseif(MSVC)
1110
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
1211
message(FATAL_ERROR "Visual Studio 2015 or newer is required.")
1312
endif()
@@ -53,14 +52,25 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
5352
)
5453
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
5554
set(warning_options -Wall -Wpedantic -Wextra)
56-
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
57-
set(warning_options /WX /W4 /wd4503 /wd4512)
55+
elseif(MSVC)
56+
set(warning_options /W4 /wd4503 /wd4512)
57+
endif()
58+
59+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
60+
set(add_link_deps pthread)
61+
endif()
62+
63+
if(MSVC)
64+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
5865
endif()
5966

6067
enable_testing()
6168

62-
add_subdirectory(lint)
6369
add_subdirectory(test)
6470
add_subdirectory(example)
71+
72+
if(NOT MSVC)
73+
add_subdirectory(lint)
6574
add_subdirectory(language/pl0)
6675
add_subdirectory(language/culebra)
76+
endif()

appveyor.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
clone_depth: 5
2+
3+
environment:
4+
matrix:
5+
- CMAKE_GENERATOR: "Visual Studio 14 2015"
6+
CONFIGURATION: Release
7+
- CMAKE_GENERATOR: "Visual Studio 14 2015 Win64"
8+
CONFIGURATION: Release
9+
10+
build_script:
11+
- mkdir build && cd build
12+
- cmake .. -Wno-dev -G"%CMAKE_GENERATOR%"
13+
- cmake --build . --config %CONFIGURATION%
14+
15+
test_script:
16+
- ctest -C %CONFIGURATION% -V

example/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
cmake_minimum_required(VERSION 2.8)
22
include_directories(..)
3-
add_compile_options(${cxx11_options} ${warning_options})
3+
4+
if(MSVC)
5+
add_compile_options(${cxx11_options} /W3)
6+
else()
7+
add_compile_options(${cxx11_options})
8+
endif()
49

510
add_executable(calc calc.cc)
6-
target_link_libraries(calc pthread)
11+
target_link_libraries(calc ${add_link_deps})
712

813
add_executable(calc2 calc2.cc)
9-
target_link_libraries(calc2 pthread)
14+
target_link_libraries(calc2 ${add_link_deps})
1015

1116
add_executable(calc3 calc3.cc)
12-
target_link_libraries(calc3 pthread)
17+
target_link_libraries(calc3 ${add_link_deps})

language/culebra/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
cmake_minimum_required(VERSION 2.8)
22
include_directories(../..)
33

4+
if(MSVC)
5+
add_compile_options(${cxx11_options} /W3)
6+
add_definitions(-DUNICODE)
7+
else()
8+
add_compile_options(${cxx11_options})
9+
endif()
10+
411
add_executable(culebra main.cc)

language/pl0/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
cmake_minimum_required(VERSION 2.8)
22
include_directories(../..)
33

4+
if(MSVC)
5+
add_compile_options(${cxx11_options} /W0)
6+
else()
7+
add_compile_options(${cxx11_options})
8+
endif()
9+
410
add_executable(pl0 pl0.cc)

lint/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
cmake_minimum_required(VERSION 2.8)
22
include_directories(..)
33

4+
if(MSVC)
5+
add_compile_options(${cxx11_options} /W3)
6+
else()
7+
add_compile_options(${cxx11_options})
8+
endif()
9+
410
add_executable(peglint peglint.cc server.cc)

peglib.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// MIT License
66
//
77

8-
#ifndef _CPPPEGLIB_PEGLIB_H_
9-
#define _CPPPEGLIB_PEGLIB_H_
8+
#ifndef CPPPEGLIB_PEGLIB_H
9+
#define CPPPEGLIB_PEGLIB_H
1010

1111
#include <algorithm>
1212
#include <cassert>
@@ -1104,6 +1104,8 @@ struct Ope::Visitor
11041104

11051105
struct AssignIDToDefinition : public Ope::Visitor
11061106
{
1107+
using Ope::Visitor::visit;
1108+
11071109
void visit(Sequence& ope) override {
11081110
for (auto op: ope.opes_) {
11091111
op->accept(*this);
@@ -1133,6 +1135,8 @@ struct IsToken : public Ope::Visitor
11331135
{
11341136
IsToken() : has_token_boundary(false), has_rule(false) {}
11351137

1138+
using Ope::Visitor::visit;
1139+
11361140
void visit(Sequence& ope) override {
11371141
for (auto op: ope.opes_) {
11381142
op->accept(*this);
@@ -1352,7 +1356,7 @@ class Definition
13521356
inline size_t LiteralString::parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const {
13531357
c.trace("LiteralString", s, n, sv, dt);
13541358

1355-
auto i = 0u;
1359+
size_t i = 0;
13561360
for (; i < lit_.size(); i++) {
13571361
if (i >= n || s[i] != lit_[i]) {
13581362
c.set_error_pos(s);
@@ -1661,6 +1665,8 @@ class ParserGenerator
16611665
DetectLeftRecursion(const std::string& name)
16621666
: s_(nullptr), name_(name), done_(false) {}
16631667

1668+
using Ope::Visitor::visit;
1669+
16641670
void visit(Sequence& ope) override {
16651671
for (auto op: ope.opes_) {
16661672
op->accept(*this);

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ include_directories(..)
33
add_compile_options(${cxx11_options} ${warning_options})
44

55
add_executable(test-main test.cc)
6-
target_link_libraries(test-main pthread)
6+
target_link_libraries(test-main ${add_link_deps})
77

88
add_test(TestMain test-main)

0 commit comments

Comments
 (0)