Skip to content

Commit 767099a

Browse files
committed
Merge branch 'jonitis-feature_vs2015_support'
2 parents 94ddf1a + 1c810bc commit 767099a

File tree

9 files changed

+47
-18
lines changed

9 files changed

+47
-18
lines changed

CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,19 @@ IF (MSGPACK_CXX11)
3737
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
3838
SET (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
3939
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
40-
MESSAGE ( FATAL_ERROR "MSVC doesn't support C++11 yet.")
40+
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
41+
MESSAGE ( FATAL_ERROR "MSVC doesn't support C++11.")
42+
ENDIF ()
43+
ENDIF ()
44+
ELSE ()
45+
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
46+
SET (CMAKE_CXX_FLAGS "-std=c++03 ${CMAKE_CXX_FLAGS}")
47+
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
48+
SET (CMAKE_CXX_FLAGS "-std=c++03 ${CMAKE_CXX_FLAGS}")
49+
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
50+
IF (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18)
51+
SET (CMAKE_CXX_FLAGS "-DMSGPACK_USE_CPP03 ${CMAKE_CXX_FLAGS}")
52+
ENDIF ()
4153
ENDIF ()
4254
ENDIF ()
4355

@@ -59,6 +71,9 @@ IF (MSGPACK_BOOST)
5971
SET (Boost_USE_MULTITHREADED ON)
6072
SET (Boost_USE_STATIC_RUNTIME OFF)
6173
FIND_PACKAGE (Boost COMPONENTS chrono timer system)
74+
INCLUDE_DIRECTORIES (
75+
${MSGPACK_BOOST_DIR}
76+
)
6277
ENDIF ()
6378

6479
FILE (GLOB_RECURSE PREDEF_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost ${CMAKE_CURRENT_SOURCE_DIR}/external/boost/predef/include/boost/*.h)

appveyor.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,20 @@ before_build:
2121
- cd ..
2222
- cd ..
2323

24+
environment:
25+
matrix:
26+
- cpp11: -DMSGPACK_CXX11=ON
27+
boost: -DMSGPACK_BOOST=ON
28+
- cpp11: -DMSGPACK_CXX11=OFF
29+
boost: -DMSGPACK_BOOST=ON
30+
- cpp11: -DMSGPACK_CXX11=ON
31+
boost: -DMSGPACK_BOOST=OFF
32+
- cpp11: -DMSGPACK_CXX11=OFF
33+
boost: -DMSGPACK_BOOST=OFF
2434
build_script:
2535
- md build
2636
- cd build
27-
- cmake -DMSGPACK_BOOST=ON -DMSGPACK_BOOST_DIR=C:\Libraries\boost -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 ..
37+
- cmake %cpp11% %boost% -DMSGPACK_BOOST_DIR=C:\Libraries\\boost_1_58_0 -DGTEST_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest.lib -DGTEST_MAIN_LIBRARY=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\build\Release\gtest_main.lib -DGTEST_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\gtest-1.7.0\include -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\build\Release\zlib.lib -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 ..
2838
- cmake --build . --config Release
2939

3040
test_script:

example/cpp03/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ IF (MSGPACK_BOOST)
2727
ENDIF ()
2828

2929
FOREACH (source_file ${exec_PROGRAMS})
30-
INCLUDE_DIRECTORIES (
31-
../include
32-
${MSGPACK_BOOST_DIR}
33-
)
3430
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
3531
ADD_EXECUTABLE (
3632
${source_file_we}
@@ -49,10 +45,6 @@ FOREACH (source_file ${exec_PROGRAMS})
4945
ENDFOREACH ()
5046

5147
FOREACH (source_file ${with_pthread_PROGRAMS})
52-
INCLUDE_DIRECTORIES (
53-
../include
54-
${MSGPACK_BOOST_DIR}
55-
)
5648
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
5749
ADD_EXECUTABLE (
5850
${source_file_we}

include/msgpack/adaptor/detail/cpp11_msgpack_tuple.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ namespace type {
7171

7272
template< std::size_t I>
7373
typename tuple_element<I, base >::type&
74-
get() { return std::get<I>(*this); }
74+
get() & { return std::get<I>(*this); }
7575

7676
template< std::size_t I>
7777
typename tuple_element<I, base >::type const&
78-
get() const { return std::get<I>(*this); }
78+
get() const& { return std::get<I>(*this); }
7979

8080
template< std::size_t I>
8181
typename tuple_element<I, base >::type&&

include/msgpack/cpp_config.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
#include "msgpack/versioning.hpp"
2222

2323
#if !defined(MSGPACK_USE_CPP03)
24-
// If MSVC would support C++11 completely,
25-
// then 'defined(_MSC_VER)' would replace with
26-
// '_MSC_VER < XXXX'
27-
# if (__cplusplus < 201103L) || defined(_MSC_VER)
24+
# if defined(_MSC_VER)
25+
# if _MSC_VER < 1900
26+
# define MSGPACK_USE_CPP03
27+
# endif
28+
# elif (__cplusplus < 201103L)
2829
# define MSGPACK_USE_CPP03
2930
# endif
3031
#endif // MSGPACK_USE_CPP03

include/msgpack/object.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ template <typename Stream>
183183
inline
184184
msgpack::packer<Stream>&
185185
msgpack::adaptor::pack<T, Enabler>::operator()(msgpack::packer<Stream>& o, T const& v) const {
186-
return detail::packer_serializer<Stream, T>::pack(o, v);
186+
return msgpack::detail::packer_serializer<Stream, T>::pack(o, v);
187187
}
188188

189189
template <typename T, typename Enabler>

test/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ FIND_PACKAGE (Threads REQUIRED)
55
INCLUDE_DIRECTORIES (
66
${GTEST_INCLUDE_DIRS}
77
${ZLIB_INCLUDE_DIRS}
8-
${MSGPACK_BOOST_DIR}
98
)
109

1110
LIST (APPEND check_PROGRAMS

test/boost_fusion.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ BOOST_FUSION_ADAPT_STRUCT(
140140
f3 // *3
141141
)
142142

143+
#if !defined(_MSC_VER)
144+
145+
// boost::fusion's adaptor uses std::tuple.
146+
// MSVC2015's std::tuple requires default constructor during 'as' process.
147+
// I don't know why...
143148
TEST(MSGPACK_BOOST, pack_convert_no_def_con)
144149
{
145150
std::stringstream ss;
@@ -151,6 +156,7 @@ TEST(MSGPACK_BOOST, pack_convert_no_def_con)
151156
EXPECT_TRUE(val1 == val2);
152157
}
153158

159+
#endif // !defined(_MSC_VER)
154160

155161
#endif // !defined(MSGPACK_USE_CPP03
156162

test/msgpack_cpp11.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,10 @@ TEST(MSGPACK_NO_DEF_CON_PAIR, simple_buffer)
456456
EXPECT_EQ(val1, val2);
457457
}
458458

459+
#if !defined(_MSC_VER)
460+
461+
// MSVC2015's std::tuple requires default constructor during 'as' process.
462+
// I don't know why...
459463
TEST(MSGPACK_NO_DEF_CON_TUPLE, simple_buffer)
460464
{
461465
std::tuple<no_def_con, no_def_con, no_def_con_composite> val1 {1, 2, 3};
@@ -480,6 +484,8 @@ TEST(MSGPACK_NO_DEF_CON_MSGPACK_TUPLE, simple_buffer)
480484
EXPECT_EQ(val1, val2);
481485
}
482486

487+
#endif // !define(_MSC_VER)
488+
483489
TEST(MSGPACK_NO_DEF_FORWARD_LIST, simple_buffer)
484490
{
485491
std::forward_list<no_def_con> val1 { 1, 2, 3 };

0 commit comments

Comments
 (0)