Merge pull request #1 from Luthaf/appveyor

Add windows support
This commit is contained in:
Toru Niina
2017-05-16 12:11:16 +09:00
committed by GitHub
6 changed files with 120 additions and 16 deletions

View File

@@ -2,7 +2,34 @@ cmake_minimum_required(VERSION 2.8)
enable_testing()
project(toml11)
include_directories(${PROJECT_SOURCE_DIR})
add_definitions(-std=c++11)
include(CheckCXXCompilerFlag)
if("${CMAKE_VERSION}" VERSION_GREATER 3.1)
set(CMAKE_CXX_STANDARD 11)
set(CXX_STANDARD_REQUIRED ON)
else()
# Manually check for C++11 compiler flag.
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXXOX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif(COMPILER_SUPPORTS_GNU11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
elseif(COMPILER_SUPPORTS_GNU0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
else()
if(MSVC)
if(MSVC_VERSION LESS 1900)
message(SEND_ERROR "MSVC < 14.0 is not supported. Please update your compiler or use mingw")
endif()
else()
message(SEND_ERROR "The ${CMAKE_CXX_COMPILER} compiler lacks C++11 support. Use another compiler.")
endif()
endif()
endif()
include_directories(${PROJECT_SOURCE_DIR})
add_subdirectory(tests)

25
appveyor.yml Normal file
View File

@@ -0,0 +1,25 @@
version: "{build}"
os: Visual Studio 2015
environment:
matrix:
- generator: Visual Studio 14 2015 Win64
- generator: Visual Studio 14 2015
configuration:
- Release
- Debug
clone_depth: 10
clone_folder: c:\toml11
build_script:
- cd C:\toml11
- mkdir build
- cd build
- git clone https://github.com/toml-lang/toml.git
- cmake -G"%generator%" -DBOOST_ROOT=C:/Libraries/boost_1_63_0 ..
- cmake --build . --config "%configuration%"
test_script:
- ctest --build-config "%configuration%" --timeout 300 --output-on-failure

View File

@@ -12,18 +12,70 @@ set(TEST_NAMES
test_parse_file
)
add_definitions("-Wall -Wpedantic")
CHECK_CXX_COMPILER_FLAG("-Wall" COMPILER_SUPPORTS_WALL)
CHECK_CXX_COMPILER_FLAG("-Wpedantic" COMPILER_SUPPORTS_WPEDANTIC)
set(test_library_dependencies)
find_library(BOOST_UNITTEST_FRAMEWORK_LIBRARY boost_unit_test_framework)
if (BOOST_UNITTEST_FRAMEWORK_LIBRARY)
add_definitions(-DBOOST_TEST_DYN_LINK)
add_definitions(-DUNITTEST_FRAMEWORK_LIBRARY_EXIST)
set(test_library_dependencies boost_unit_test_framework)
if(COMPILER_SUPPORTS_WALL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
if(COMPILER_SUPPORTS_WPEDANTIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
endif()
# Disable some MSVC warnings
if(MSVC)
# conversion from 'double' to 'unsigned int', possible loss of data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244")
# conversion from 'int' to 'unsigned int', signed/unsigned mismatch
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4365")
# layout of class may have changed from a previous version of the compiler
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4371")
# enumerator in switch of enum is not explicitly handled by a case label
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4061")
# unreferenced inline function has been removed
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4514")
# constructor is not implicitly called
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4582")
# destructor is not implicitly called
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4583")
# pragma warning: there is no warning number <x>
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4619")
# default constructor was implicitly defined as deleted
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4623")
# copy constructor was implicitly defined as deleted
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4625")
# assignment operator was implicitly defined as deleted
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4626")
# move assignment operator was implicitly defined as deleted
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4627")
# <X> is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4668")
# function not inlined
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4710")
# function selected for automatic inlining
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4711")
# <x> bytes padding added after data member
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4820")
# pragma warning(pop): likely mismatch, popping warning state pushed in different file
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5031")
endif()
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
add_definitions(-DBOOST_TEST_DYN_LINK)
add_definitions(-DUNITTEST_FRAMEWORK_LIBRARY_EXIST)
foreach(TEST_NAME ${TEST_NAMES})
add_executable(${TEST_NAME} ${TEST_NAME}.cpp)
target_link_libraries(${TEST_NAME} ${test_library_dependencies})
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/build)
target_link_libraries(${TEST_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_include_directories(${TEST_NAME} PRIVATE ${Boost_INCLUDE_DIRS})
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
# Set the PATH to be able to find Boost DLL
if(WIN32)
STRING(REPLACE ";" "\\;" PATH_STRING "$ENV{PATH}")
set_tests_properties(${TEST_NAME}
PROPERTIES ENVIRONMENT "PATH=${PATH_STRING}\;${Boost_LIBRARY_DIRS}"
)
endif()
endforeach(TEST_NAME)

View File

@@ -15,7 +15,7 @@ BOOST_AUTO_TEST_CASE(test_resize)
typedef std::vector<int> resizable_type;
typedef std::array<int,1> non_resizable_type;
BOOST_CHECK(toml::detail::has_resize_method<resizable_type>::value);
BOOST_CHECK(not toml::detail::has_resize_method<non_resizable_type>::value);
BOOST_CHECK(!toml::detail::has_resize_method<non_resizable_type>::value);
}
{
@@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(test_resize)
{
thrown = true;
}
BOOST_CHECK(not thrown);
BOOST_CHECK(!thrown);
BOOST_CHECK_EQUAL(v.size(), 10);
}
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(test_resize)
{
thrown = true;
}
BOOST_CHECK(not thrown);
BOOST_CHECK(!thrown);
BOOST_CHECK_EQUAL(a.size(), 15);
}

View File

@@ -29,7 +29,7 @@
# error "__cplusplus is not defined"
#endif
#if __cplusplus < 201103L
#if __cplusplus < 201103L && _MSC_VER < 1900
# error "toml11 requires C++11 or later."
#endif

View File

@@ -109,7 +109,7 @@ struct is_chain_of_impl
static Iterator invoke(Iterator iter, Iterator rollback)
{
const Iterator tmp = headT::invoke(iter);
return (tmp == iter && not ignorable) ? rollback :
return (tmp == iter && !ignorable) ? rollback :
is_chain_of_impl<condT...>::invoke(tmp, rollback);
}
};