From 453a0daaaf8683546459062fa4bcc1c9d9ab4754 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sun, 24 Dec 2017 01:30:55 -0500 Subject: [PATCH] fix VC++ build of examples and try to get appveyor to compile and run... --- CMakeLists.txt | 6 ++++++ appveyor.yml | 2 +- examples/CMakeLists.txt | 11 ++--------- examples/any_return.cpp | 2 +- tests/CMakeLists.txt | 6 ------ 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74f4f313..198abe29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,12 @@ cmake_minimum_required(VERSION 3.5.0) 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 # Set general standard requirements here diff --git a/appveyor.yml b/appveyor.yml index 72227c4d..54e0c812 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -57,7 +57,7 @@ before_build: - set PATH=%PYTHON_PATH%;%PATH% - md 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: - cmake --build . diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5116b220..9da842f0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,12 +25,6 @@ file(GLOB EXAMPLES_SRC *.cpp tutorials/quick_n_dirty/*.cpp) 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) if (is_single) 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}) endif() # examples must be built in debug mode to allow assertions to fire - target_compile_definitions(${example_name} PRIVATE _DEBUG) if (MSVC) - target_compile_options(${example_name} PRIVATE /DDEBUG /UNDEBUG) + target_compile_options(${example_name} PRIVATE /UNDEBUG) else() - target_compile_options(${example_name} PRIVATE -Og -g -UNDEBUG) + target_compile_options(${example_name} PRIVATE -UNDEBUG) endif() if (TESTS_EXAMPLES) diff --git a/examples/any_return.cpp b/examples/any_return.cpp index bfaf0c09..a9bf833f 100644 --- a/examples/any_return.cpp +++ b/examples/any_return.cpp @@ -14,7 +14,7 @@ sol::object fancy_func(sol::object a, sol::object b, sol::this_state s) { } else if (a.is()) { bool do_triple = a.as(); - return sol::object(lua, sol::in_place, b.as() * (do_triple ? 3 : 1)); + return sol::object(lua, sol::in_place_type, b.as() * (do_triple ? 3 : 1)); } // Can also use make_object return sol::make_object(lua, sol::nil); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 02c9a4f2..5b5d7a43 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,12 +25,6 @@ file(GLOB SOL2_TEST_SOURCES test*.cpp) 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) function(CREATE_TEST test_target_name test_name is_single)