fix VC++ build of examples and try to get appveyor to compile and run...

This commit is contained in:
ThePhD 2017-12-24 01:30:55 -05:00
parent ed3de48cce
commit 453a0daaaf
5 changed files with 10 additions and 17 deletions

View File

@ -24,6 +24,12 @@
cmake_minimum_required(VERSION 3.5.0) cmake_minimum_required(VERSION 3.5.0)
project(sol2 VERSION 2.19.0 LANGUAGES CXX C) project(sol2 VERSION 2.19.0 LANGUAGES CXX C)
if (MSVC)
add_definitions(/DUNICODE /D_UNICODE /D_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING /D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
add_compile_options(/W4 /EHsc /std:c++latest)
else()
add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors -Wno-noexcept-type -ftemplate-depth=1024)
endif()
# # # General Project Requirements # # # General Project Requirements
# Set general standard requirements here # Set general standard requirements here

View File

@ -57,7 +57,7 @@ before_build:
- set PATH=%PYTHON_PATH%;%PATH% - set PATH=%PYTHON_PATH%;%PATH%
- md build-sol2 - md build-sol2
- cd build-sol2 - cd build-sol2
- cmake .. -G "%CMAKE_GENERATOR%" -DLUA_VERSION="%LUA_VERSION%" -DLUA_BUILD=ON -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DTESTS_SINGLE=ON - cmake .. -G "%CMAKE_GENERATOR%" -DLUA_VERSION="%LUA_VERSION%" -DBUILD_LUA=ON -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DTESTS_SINGLE=ON
build_script: build_script:
- cmake --build . - cmake --build .

View File

@ -25,12 +25,6 @@
file(GLOB EXAMPLES_SRC *.cpp tutorials/quick_n_dirty/*.cpp) file(GLOB EXAMPLES_SRC *.cpp tutorials/quick_n_dirty/*.cpp)
source_group(examples FILES ${EXAMPLES_SRC}) source_group(examples FILES ${EXAMPLES_SRC})
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /EHsc /std:c++latest /D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING=1 /D_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING=1")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors -Wno-noexcept-type -ftemplate-depth=1024")
endif()
function (MAKE_EXAMPLE example_source_file is_single) function (MAKE_EXAMPLE example_source_file is_single)
if (is_single) if (is_single)
set(header_files ${SOL2_SINGLE_HEADER_SOURCES}) set(header_files ${SOL2_SINGLE_HEADER_SOURCES})
@ -64,11 +58,10 @@ function (MAKE_EXAMPLE example_source_file is_single)
target_link_libraries(${example_name} ${CMAKE_DL_LIBS}) target_link_libraries(${example_name} ${CMAKE_DL_LIBS})
endif() endif()
# examples must be built in debug mode to allow assertions to fire # examples must be built in debug mode to allow assertions to fire
target_compile_definitions(${example_name} PRIVATE _DEBUG)
if (MSVC) if (MSVC)
target_compile_options(${example_name} PRIVATE /DDEBUG /UNDEBUG) target_compile_options(${example_name} PRIVATE /UNDEBUG)
else() else()
target_compile_options(${example_name} PRIVATE -Og -g -UNDEBUG) target_compile_options(${example_name} PRIVATE -UNDEBUG)
endif() endif()
if (TESTS_EXAMPLES) if (TESTS_EXAMPLES)

View File

@ -14,7 +14,7 @@ sol::object fancy_func(sol::object a, sol::object b, sol::this_state s) {
} }
else if (a.is<bool>()) { else if (a.is<bool>()) {
bool do_triple = a.as<bool>(); bool do_triple = a.as<bool>();
return sol::object(lua, sol::in_place<double>, b.as<double>() * (do_triple ? 3 : 1)); return sol::object(lua, sol::in_place_type<double>, b.as<double>() * (do_triple ? 3 : 1));
} }
// Can also use make_object // Can also use make_object
return sol::make_object(lua, sol::nil); return sol::make_object(lua, sol::nil);

View File

@ -25,12 +25,6 @@
file(GLOB SOL2_TEST_SOURCES test*.cpp) file(GLOB SOL2_TEST_SOURCES test*.cpp)
source_group(test_sources FILES ${SOL2_TEST_SOURCES}) source_group(test_sources FILES ${SOL2_TEST_SOURCES})
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /EHsc /std:c++latest /D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING=1 /D_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING=1")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors -Wno-noexcept-type -ftemplate-depth=1024")
endif()
file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v2.0.1/catch.hpp ${CMAKE_BINARY_DIR}/Catch/include/catch.hpp) file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v2.0.1/catch.hpp ${CMAKE_BINARY_DIR}/Catch/include/catch.hpp)
function(CREATE_TEST test_target_name test_name is_single) function(CREATE_TEST test_target_name test_name is_single)