From 9760a400cde8ff3417831396f599e645202500ff Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sun, 23 Dec 2018 13:18:14 -0500 Subject: [PATCH] testing and test matrix improvements --- .travis.yml | 64 ++++++-------- CMakeLists.txt | 94 ++++++--------------- appveyor.yml | 8 +- examples/CMakeLists.txt | 22 ++++- examples/interop/LuaBridge/CMakeLists.txt | 38 +++++++-- examples/interop/kaguya/CMakeLists.txt | 36 ++++++-- examples/interop/luwra/CMakeLists.txt | 38 +++++++-- examples/interop/tolua/CMakeLists.txt | 36 ++++++-- examples/require_dll_example/CMakeLists.txt | 81 +++++++++++++----- include/sol/stack_core.hpp | 10 +-- include/sol/traits.hpp | 2 +- include/sol/types.hpp | 2 +- single/include/sol/forward.hpp | 4 +- single/include/sol/sol.hpp | 18 ++-- tests/compile_tests/CMakeLists.txt | 15 ++++ tests/runtime_tests/CMakeLists.txt | 23 +++++ 16 files changed, 305 insertions(+), 186 deletions(-) diff --git a/.travis.yml b/.travis.yml index a22f5c91..5517abc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,7 +46,7 @@ matrix: include: # GCC 4.9.x, 5.x, 6.x, 7.x - env: - - LUA_VERSION=5.3.4 + - LUA_VERSION=5.3.5 GCC_VERSION=7 PLATFORM=i686 CI=true @@ -64,63 +64,51 @@ matrix: CI=true - env: - - LUA_VERSION=5.3.4 - GCC_VERSION=4.9 - PLATFORM=x64 - CI=true - - - env: - - LUA_VERSION=5.3.4 - GCC_VERSION=5 - CI=true - PLATFORM=x64 - - - env: - - LUA_VERSION=5.3.4 - GCC_VERSION=6 - PLATFORM=x64 - CI=true - - - env: - - LUA_VERSION=5.3.4 + - LUA_VERSION=5.3.5 GCC_VERSION=7 PLATFORM=x64 CI=true # LLVM 3.6.x -> 5.0.x - env: - - LUA_VERSION=5.3.4 + - LUA_VERSION=5.3.5 LLVM_VERSION=3.6.2 PLATFORM=x64 CI=true - env: - - LUA_VERSION=5.3.4 + - LUA_VERSION=5.3.5 LLVM_VERSION=3.7.1 PLATFORM=x64 CI=true - env: - - LUA_VERSION=5.3.4 - LLVM_VERSION=3.8.1 - PLATFORM=x64 - CI=true - - - env: - - LUA_VERSION=5.3.4 + - LUA_VERSION=5.3.5 LLVM_VERSION=3.9.1 PLATFORM=x64 CI=true - env: - - LUA_VERSION=5.3.4 + - LUA_VERSION=5.3.5 LLVM_VERSION=4.0.1 PLATFORM=x64 CI=true - env: - - LUA_VERSION=5.3.4 - LLVM_VERSION=5.0.1 + - LUA_VERSION=5.3.5 + LLVM_VERSION=5.0.2 + PLATFORM=x64 + CI=true + + - env: + - LUA_VERSION=5.3.5 + LLVM_VERSION=6.0.1 + PLATFORM=x64 + CI=true + + - env: + - LUA_VERSION=5.3.5 + LLVM_VERSION=7.0.0 PLATFORM=x64 CI=true @@ -152,8 +140,8 @@ matrix: - os: osx osx_image: xcode9.0 env: - - LUA_VERSION=lua-5.3.4 - LLVM_VERSION=5.0.1 + - LUA_VERSION=lua-5.3.5 + LLVM_VERSION=5.0.2 before_install: - chmod +x ./scripts/run.osx.sh - chmod +x ./scripts/preparation.osx.sh @@ -164,8 +152,8 @@ matrix: - os: osx osx_image: xcode9.1 env: - - LUA_VERSION=lua-5.3.4 - LLVM_VERSION=5.0.1 + - LUA_VERSION=lua-5.3.5 + LLVM_VERSION=5.0.2 before_install: - chmod +x ./scripts/run.osx.sh - chmod +x ./scripts/preparation.osx.sh @@ -176,8 +164,8 @@ matrix: - os: osx osx_image: xcode9.2 env: - - LUA_VERSION=lua-5.3.4 - LLVM_VERSION=5.0.1 + - LUA_VERSION=lua-5.3.5 + LLVM_VERSION=5.0.2 before_install: - chmod +x ./scripts/run.osx.sh - chmod +x ./scripts/preparation.osx.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index a1f278e0..15290221 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,73 +29,6 @@ project(sol2 VERSION 3.0.0 LANGUAGES CXX C) include(GNUInstallDirs) -# # # General Project Requirements -# Set general standard requirements here -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -# Features a C++ compiler must have to be used to compile sol2 -# This list is not *complete* as CMake does not support features for -# all of the advanced features utilized. -set(CXX_FEATURES - cxx_auto_type - cxx_constexpr - cxx_decltype - cxx_decltype_auto - cxx_default_function_template_args - cxx_final - cxx_lambdas - cxx_noexcept - cxx_nullptr - cxx_override - cxx_range_for - cxx_return_type_deduction - cxx_right_angle_brackets - cxx_static_assert - cxx_strong_enums - cxx_variadic_macros - cxx_variadic_templates) - -# # # -if (SOL2_PLATFORM MATCHES "i686" OR SOL2_PLATFORM STREQUAL "x86") - set(IS_X86 TRUE) -elseif (SOL2_PLATFORM MATCHES "ARM64") - set(IS_ARM64 TRUE) - set(IS_X64 TRUE) -elseif (SOL2_PLATFORM MATCHES "ARM") - set(IS_ARM TRUE) -elseif (SOL2_PLATFORM MATCHES "x86_64" OR SOL2_PLATFORM STREQUAL "x64") - set(IS_X64 TRUE) -else() - set(IS_X64 TRUE) -endif() - -# # # General project flags -if (MSVC) - add_definitions(/DUNICODE /D_UNICODE /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) - # Warning level, exceptions - add_compile_options(/EHsc) - add_compile_options("$<$:/MDd>" - "$<$:/MD>" - "$<$:/MD>" - "$<$:/MD>") - if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(/MP) - endif() -else() - add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) -endif() - -# # # General project output locations -if (IS_X86 OR CMAKE_SIZEOF_VOID_P EQUAL 4) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/lib") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/bin") - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/bin") -else() - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/lib") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/bin") - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/bin") -endif() - # # # Modules # # Include modules useful to the project, whether locally made in our own cmake DIRECTORY # # our from the standard cmake libraries @@ -147,6 +80,33 @@ CMAKE_DEPENDENT_OPTION(BUILD_LUA_AS_DLL "Build Lua as a DLL" ON "SOL2_BUILD_LUA" OFF) +# # # Platform +# Detect x86 and x64 stuff +if (SOL2_PLATFORM MATCHES "i686" OR SOL2_PLATFORM STREQUAL "x86") + set(IS_X86 TRUE) +elseif (SOL2_PLATFORM MATCHES "ARM64") + set(IS_ARM64 TRUE) + set(IS_X64 TRUE) +elseif (SOL2_PLATFORM MATCHES "ARM") + set(IS_ARM TRUE) +elseif (SOL2_PLATFORM MATCHES "x86_64" OR SOL2_PLATFORM STREQUAL "x64") + set(IS_X64 TRUE) +else() + set(IS_X64 TRUE) +endif() + +# # # General project output locations +if (IS_X86 OR CMAKE_SIZEOF_VOID_P EQUAL 4) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/lib") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/bin") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/bin") +else() + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/lib") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/bin") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/bin") +endif() + + # # # sol2 Source Groups # # Sources everyone is going to need # Header files diff --git a/appveyor.yml b/appveyor.yml index ae125296..34d0caf6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -47,15 +47,15 @@ environment: # apparently, I can't quite make LLVM work right now... #- LUA_VERSION: 5.3.4 # LLVM_VERSION: 4.0.0 - - LUA_VERSION: 5.3.4 + - LUA_VERSION: 5.3.5 MINGW_VERSION: 7.2.0 - - LUA_VERSION: 5.3.4 + - LUA_VERSION: 5.3.5 MINGW_VERSION: 6.3.0 - LUA_VERSION: luajit-2.0.5 MINGW_VERSION: 6.3.0 - LUA_VERSION: luajit-2.1.0-beta3 MINGW_VERSION: 6.3.0 - - LUA_VERSION: 5.3.4 + - LUA_VERSION: 5.3.5 - LUA_VERSION: 5.2.4 - LUA_VERSION: 5.1.5 - LUA_VERSION: luajit-2.0.5 @@ -152,7 +152,7 @@ before_build: - if DEFINED LLVM_VERSION (call %vcvars_script% && cd C:\projects\sol2) - md build-sol2 - cd build-sol2 -- cmake .. -G "%CMAKE_GENERATOR%" %build_type% %build_compiler% -DSOL2_LUA_VERSION="%LUA_VERSION%" -DSOL2_CI=ON -DSOL2_BUILD_LUA=ON -DBUILD_LUA_AS_DLL=%lua_build_type% -DSOL2_TESTS=ON -DSOL2_EXAMPLES=ON -DSOL2_SINGLE_GENERATED=ON -DSOL2_TESTS_EXAMPLES=ON -DSOL2_EXAMPLES_SINGLE_GENERATED=ON -DSOL2_TESTS_SINGLE_GENERATED=ON +- cmake .. -G "%CMAKE_GENERATOR%" %build_type% %build_compiler% -DSOL2_LUA_VERSION="%LUA_VERSION%" -DSOL2_CI=ON -DSOL2_BUILD_LUA=ON -DBUILD_LUA_AS_DLL=%lua_build_type% -DSOL2_TESTS=ON -DSOL2_EXAMPLES=ON -DSOL2_GENERATE_SINGLE=ON -DSOL2_TESTS_EXAMPLES=ON -DSOL2_EXAMPLES_SINGLE_GENERATED=ON -DSOL2_TESTS_SINGLE_GENERATED=ON # We do not build the debug versions because the compiler # generates too much debug info for MinGW to handle diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d2e577f3..ff88debc 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,13 +22,13 @@ # # # sol2 Examples -if (SOL2_DYNAMIC_LOADING_EXAMPLES) +if (SOL2_DYNAMIC_LOADING_EXAMPLES OR SOL2_DYNAMIC_LOADING_EXAMPLES_SINGLE OR SOL2_DYNAMIC_LOADING_EXAMPLES_SINGLE_GENERATED) # # require_from_dll example # just add the subdirectory add_subdirectory(require_dll_example) endif() -if (SOL2_INTEROP_EXAMPLES) +if (SOL2_INTEROP_EXAMPLES OR SOL2_INTEROP_EXAMPLES_SINGLE OR SOL2_INTEROP_EXAMPLES_SINGLE_GENERATED) # # interop examples add_subdirectory(interop/kaguya) add_subdirectory(interop/tolua) @@ -61,9 +61,23 @@ function (MAKE_EXAMPLE example_source_file example_suffix target_sol example_tes PROPERTIES OUTPUT_NAME "${example_output_name}" EXPORT_NAME sol2::${example_output_name}) + + if (MSVC) + target_compile_options(${example_name} + PRIVATE /std:c++latest /EHsc "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${example_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${example_name} + PRIVATE -std=c++1z -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + target_link_libraries(${example_name} ${target_sol}) - target_compile_features(${example_name} - PRIVATE ${CXX_FEATURES}) target_link_libraries(${example_name} ${LUA_LIBRARIES}) if(CMAKE_DL_LIBS) target_link_libraries(${example_name} ${CMAKE_DL_LIBS}) diff --git a/examples/interop/LuaBridge/CMakeLists.txt b/examples/interop/LuaBridge/CMakeLists.txt index 329b288c..3445bd4f 100644 --- a/examples/interop/LuaBridge/CMakeLists.txt +++ b/examples/interop/LuaBridge/CMakeLists.txt @@ -24,13 +24,30 @@ find_package(LuaBridgeBuild) -function (make_luabridge_interop_example target_library is_single) +function (make_luabridge_interop_example target_library example_suffix) set(example_name luabridge_interop_example) - if (is_single) - set(example_name "${example_name}.single") - endif(is_single) + set(example_name "${example_name}${example_suffix}") + add_executable(${example_name} source/LuaBridge.cpp) target_link_libraries(${example_name} PUBLIC ${LUA_LIBRARIES} PRIVATE ${LUABRIDGE_LIBRARIES} ${target_library}) + + if (MSVC) + target_compile_options(${example_name} + PRIVATE /std:c++latest /EHsc "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${example_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${example_name} + PRIVATE -std=c++1z + -Wno-noexcept-type -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + + if (CMAKE_DL_LIBS) target_link_libraries(${example_name} PRIVATE ${CMAKE_DL_LIBS}) endif() @@ -39,12 +56,17 @@ function (make_luabridge_interop_example target_library is_single) else() target_compile_options(${example_name} PRIVATE -w) endif() - if (TESTS_EXAMPLES) + if (SOL2_TESTS_INTEROP_EXAMPLES) add_test(NAME ${example_name} COMMAND ${example_name}) endif() endfunction() -make_luabridge_interop_example(sol2::sol2 FALSE) -if (SOL2_SINGLE_FOUND AND INTEROP_EXAMPLES_SINGLE) - make_luabridge_interop_example(sol2::sol2_single TRUE) +if (SOL2_INTEROP_EXAMPLES) + make_luabridge_interop_example(sol2::sol2 "") +endif() +if (SOL2_INTEROP_EXAMPLES_SINGLE) + make_luabridge_interop_example(sol2::sol2_single ".single") +endif() +if (SOL2_INTEROP_EXAMPLES_SINGLE_GENERATED) + make_luabridge_interop_example(sol2::sol2_single_generated ".single.generated") endif() diff --git a/examples/interop/kaguya/CMakeLists.txt b/examples/interop/kaguya/CMakeLists.txt index c23e51ba..aef655aa 100644 --- a/examples/interop/kaguya/CMakeLists.txt +++ b/examples/interop/kaguya/CMakeLists.txt @@ -24,11 +24,26 @@ find_package(KaguyaBuild) -function (make_kaguya_interop_example target_library is_single) +function (make_kaguya_interop_example target_library example_suffix) set(example_name kaguya_interop_example) - if (is_single) - set(example_name "${example_name}.single") - endif(is_single) + set(example_name "${example_name}${example_suffix}") + + if (MSVC) + target_compile_options(${example_name} + PRIVATE /std:c++latest /EHsc "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${example_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${example_name} + PRIVATE -std=c++1z + -Wno-noexcept-type -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + add_executable(${example_name} source/kaguya.cpp) target_link_libraries(${example_name} PUBLIC ${LUA_LIBRARIES} PRIVATE ${KAGUYA_LIBRARIES} ${target_library}) if (CMAKE_DL_LIBS) @@ -39,12 +54,17 @@ function (make_kaguya_interop_example target_library is_single) else() target_compile_options(${example_name} PRIVATE -w) endif() - if (TESTS_INTEROP_EXAMPLES) + if (SOL2_TESTS_INTEROP_EXAMPLES) add_test(NAME ${example_name} COMMAND ${example_name}) endif() endfunction() -make_kaguya_interop_example(sol2::sol2 FALSE) -if (SOL2_SINGLE_FOUND AND INTEROP_EXAMPLES_SINGLE) - make_kaguya_interop_example(sol2::sol2_single TRUE) +if (SOL2_INTEROP_EXAMPLES) + make_kaguya_interop_example(sol2::sol2 "") +endif() +if (SOL2_INTEROP_EXAMPLES_SINGLE) + make_kaguya_interop_example(sol2::sol2_single ".single") +endif() +if (SOL2_INTEROP_EXAMPLES_SINGLE_GENERATED) + make_kaguya_interop_example(sol2::sol2_single_generated ".single.generated") endif() diff --git a/examples/interop/luwra/CMakeLists.txt b/examples/interop/luwra/CMakeLists.txt index 5ccd3c4c..06d114e6 100644 --- a/examples/interop/luwra/CMakeLists.txt +++ b/examples/interop/luwra/CMakeLists.txt @@ -24,13 +24,30 @@ find_package(LuwraBuild) -function (make_luwra_interop_example target_library is_single) +function (make_luwra_interop_example target_library example_suffix) set(example_name luwra_interop_example) - if (is_single) - set(example_name "${example_name}.single") - endif(is_single) + set(example_name "${example_name}${example_suffix}") + add_executable(${example_name} source/luwra.cpp) target_link_libraries(${example_name} PUBLIC ${LUA_LIBRARIES} PRIVATE ${LUWRA_LIBRARIES} ${target_library}) + + if (MSVC) + target_compile_options(${example_name} + PRIVATE /std:c++latest /EHsc "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${example_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${example_name} + PRIVATE -std=c++1z + -Wno-noexcept-type -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + + if (CMAKE_DL_LIBS) target_link_libraries(${example_name} PRIVATE ${CMAKE_DL_LIBS}) endif() @@ -39,12 +56,17 @@ function (make_luwra_interop_example target_library is_single) else() target_compile_options(${example_name} PRIVATE -w) endif() - if (TESTS_EXAMPLES) + if (SOL2_TESTS_INTEROP_EXAMPLES) add_test(NAME ${example_name} COMMAND ${example_name}) endif() endfunction() -make_luwra_interop_example(sol2::sol2 FALSE) -if (SOL2_SINGLE_FOUND AND INTEROP_EXAMPLES_SINGLE) - make_luwra_interop_example(sol2::sol2_single TRUE) +if (SOL2_INTEROP_EXAMPLES) + make_luwra_interop_example(sol2::sol2 "") endif() +if (SOL2_INTEROP_EXAMPLES_SINGLE) + make_luwra_interop_example(sol2::sol2_single ".single") +endif() +if (SOL2_INTEROP_EXAMPLES_SINGLE_GENERATED) + make_luwra_interop_example(sol2::sol2_single_generated ".single.generated") +endif() \ No newline at end of file diff --git a/examples/interop/tolua/CMakeLists.txt b/examples/interop/tolua/CMakeLists.txt index 91272582..87e80e70 100644 --- a/examples/interop/tolua/CMakeLists.txt +++ b/examples/interop/tolua/CMakeLists.txt @@ -24,13 +24,28 @@ find_package(ToLuappBuild REQUIRED) -function(make_tolua_interop_example target_library is_single) +function(make_tolua_interop_example target_library example_suffix) set(example_name tolua_interop_example) - if (is_single) - set(example_name "${example_name}.single") - endif() + set(example_name "${example_name}${example_suffix}") add_executable(${example_name} source/tolua.cpp) target_link_libraries(${example_name} PUBLIC ${LUA_LIBRARIES} PRIVATE ${TOLUAPP_LIBRARIES} ${target_library}) + + if (MSVC) + target_compile_options(${example_name} + PRIVATE /std:c++latest /EHsc "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${example_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${example_name} + PRIVATE -std=c++1z + -Wno-noexcept-type -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + if (CMAKE_DL_LIBS) target_link_libraries(${example_name} PRIVATE ${CMAKE_DL_LIBS}) endif() @@ -39,12 +54,17 @@ function(make_tolua_interop_example target_library is_single) else() target_compile_options(${example_name} PRIVATE -w) endif() - if (SOL2_TESTS_EXAMPLES) + if (SOL2_TESTS_INTEROP_EXAMPLES) add_test(NAME ${example_name} COMMAND ${example_name}) endif() endfunction() -make_tolua_interop_example(sol2::sol2 FALSE) -if (SOL2_SINGLE AND SOL2_INTEROP_EXAMPLES_SINGLE) - make_tolua_interop_example(sol2::sol2_single TRUE) +if (SOL2_INTEROP_EXAMPLES) + make_tolua_interop_example(sol2::sol2 "") +endif() +if (SOL2_INTEROP_EXAMPLES_SINGLE) + make_tolua_interop_example(sol2::sol2_single ".single") +endif() +if (SOL2_INTEROP_EXAMPLES_SINGLE_GENERATED) + make_tolua_interop_example(sol2::sol2_single_generated ".single.generated") endif() \ No newline at end of file diff --git a/examples/require_dll_example/CMakeLists.txt b/examples/require_dll_example/CMakeLists.txt index 9694c6ad..20f17074 100644 --- a/examples/require_dll_example/CMakeLists.txt +++ b/examples/require_dll_example/CMakeLists.txt @@ -24,7 +24,7 @@ # # Reusable function to call for single target # # Also hides variables from directory/global scope -function(make_require_from_dll_example target_lib is_single) +function(make_require_from_dll_example target_lib example_lib_name_suffix) # define sources set(my_object_sources my_object.cpp my_object.hpp my_object_api.hpp) set(require_from_dll_sources require_from_dll.cpp) @@ -32,11 +32,9 @@ function(make_require_from_dll_example target_lib is_single) # define names set(example_lib_name my_object) set(example_name require_from_dll) - if (is_single) - set(example_lib_name "${example_lib_name}.single") - set(example_name "${example_name}.single") - endif() - + set(example_lib_name "${example_lib_name}${example_lib_name_suffix}") + set(example_name "${example_name}${example_lib_name_suffix}") + # is the lua library a shared or static library? list(GET LUA_LIBRARIES 0 lua_lib_target) get_target_property(lua_lib_type ${lua_lib_target} TYPE) @@ -45,13 +43,32 @@ function(make_require_from_dll_example target_lib is_single) add_library(${example_lib_name} SHARED ${my_object_sources}) set_target_properties(${example_lib_name} PROPERTIES PREFIX "") + target_include_directories(${example_lib_name} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") - target_compile_features(${example_lib_name} PRIVATE ${CXX_FEATURES}) target_compile_definitions(${example_lib_name} PUBLIC MY_OBJECT_DLL PRIVATE MY_OBJECT_BUILD) + target_link_libraries(${example_lib_name} PRIVATE ${target_lib}) + target_include_directories(${example_lib_name} PUBLIC "${LUA_INCLUDE_DIRS}") + + if (MSVC) + target_compile_options(${example_lib_name} + PRIVATE /std:c++latest /EHsc "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${example_lib_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${example_lib_name} + PRIVATE + -Wno-noexcept-type -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + if(CMAKE_DL_LIBS) target_link_libraries(${example_lib_name} PUBLIC ${CMAKE_DL_LIBS}) endif() - if (CI) + if (SOL2_CI) target_compile_definitions(${example_lib_name} PRIVATE SOL2_CI) endif() if (NOT MSVC) @@ -70,12 +87,27 @@ function(make_require_from_dll_example target_lib is_single) if (IS_X86) target_compile_options(${example_lib_name} BEFORE PRIVATE -m32) endif() - target_link_libraries(${example_lib_name} PRIVATE ${target_lib}) - target_include_directories(${example_lib_name} PUBLIC "${LUA_INCLUDE_DIRS}") - + # add executable target that represents require_from_dll program add_executable(${example_name} ${require_from_dll_sources}) - target_compile_features(${example_name} PRIVATE ${CXX_FEATURES}) + target_link_libraries(${example_name} PRIVATE my_object ${target_lib}) + + if (MSVC) + target_compile_options(${example_name} + PRIVATE /std:c++latest /EHsc "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${example_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${example_name} + PRIVATE -std=c++1z + -Wno-noexcept-type -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + if(CMAKE_DL_LIBS) target_link_libraries(${example_name} PRIVATE ${CMAKE_DL_LIBS}) endif() @@ -83,9 +115,9 @@ function(make_require_from_dll_example target_lib is_single) target_compile_definitions(${example_name} PRIVATE SOL2_CI) endif() if (NOT MSVC) - target_compile_options(${example_name} PRIVATE -Wno-noexcept-type) + target_compile_options(${example_name} PRIVATE ) endif() - target_link_libraries(${example_name} PRIVATE my_object ${target_lib}) + # avoid multiply defined references due to linking in the same static library # twice over, and get "multiple definition" errors during linking if (NOT lua_lib_type MATCHES "STATIC") @@ -93,15 +125,18 @@ function(make_require_from_dll_example target_lib is_single) endif() target_include_directories(${example_name} PRIVATE ${LUA_INCLUDE_DIRS}) - if (TESTS_DYNAMIC_LOADING_EXAMPLES) - if ((NOT is_single) OR (is_single AND DYNAMIC_LOADING_EXAMPLES_SINGLE)) - get_target_property(example_working_dir ${example_name} RUNTIME_OUTPUT_DIRECTORY) - add_test(NAME ${example_name} COMMAND ${example_name} WORKING_DIRECTORY "${example_working_dir}") - endif() + if (SOL2_TESTS_DYNAMIC_LOADING_EXAMPLES) + get_target_property(example_working_dir ${example_name} RUNTIME_OUTPUT_DIRECTORY) + add_test(NAME ${example_name} COMMAND ${example_name} WORKING_DIRECTORY "${example_working_dir}") endif() endfunction() -make_require_from_dll_example(sol2::sol2 FALSE) -if (SOL2_SINGLE_FOUND AND DYNAMIC_LOADING_EXAMPLES_SINGLE) - make_require_from_dll_example(sol2::sol2_single TRUE) -endif() \ No newline at end of file +if (SOL2_DYNAMIC_LOADING_EXAMPLES) + make_require_from_dll_example(sol2::sol2 "") +endif() +if (SOL2_DYNAMIC_LOADING_EXAMPLES_SINGLE) + make_require_from_dll_example(sol2::sol2_single ".single") +endif() +if (SOL2_DYNAMIC_LOADING_EXAMPLES_SINGLE_GENERATED) + make_require_from_dll_example(sol2::sol2_single_generated ".single.generated") +endif() diff --git a/include/sol/stack_core.hpp b/include/sol/stack_core.hpp index 8bfc6fe6..90bdd561 100644 --- a/include/sol/stack_core.hpp +++ b/include/sol/stack_core.hpp @@ -675,19 +675,19 @@ namespace sol { }; template - constexpr bool is_adl_sol_lua_get_v = is_adl_sol_lua_get::value; + inline constexpr bool is_adl_sol_lua_get_v = is_adl_sol_lua_get::value; template - constexpr bool is_adl_sol_lua_check_v = is_adl_sol_lua_check::value; + inline constexpr bool is_adl_sol_lua_check_v = is_adl_sol_lua_check::value; template - constexpr bool is_adl_sol_lua_check_get_v = is_adl_sol_lua_check_get::value; + inline constexpr bool is_adl_sol_lua_check_get_v = is_adl_sol_lua_check_get::value; template - constexpr bool is_adl_sol_lua_push_v = is_adl_sol_lua_push::value; + inline constexpr bool is_adl_sol_lua_push_v = is_adl_sol_lua_push::value; template - constexpr bool is_adl_sol_lua_push_exact_v = is_adl_sol_lua_push_exact::value; + inline constexpr bool is_adl_sol_lua_push_exact_v = is_adl_sol_lua_push_exact::value; }} // namespace meta::meta_detail diff --git a/include/sol/traits.hpp b/include/sol/traits.hpp index 7013b0ed..4439fda7 100644 --- a/include/sol/traits.hpp +++ b/include/sol/traits.hpp @@ -123,7 +123,7 @@ namespace sol { using is_specialization_of = meta_detail::is_specialization_of, Templ>; template class Templ> - constexpr bool is_specialization_of_v = is_specialization_of, Templ>::value; + inline constexpr bool is_specialization_of_v = is_specialization_of, Templ>::value; template struct all_same : std::true_type {}; diff --git a/include/sol/types.hpp b/include/sol/types.hpp index 5a3bf3cb..ac51b0af 100644 --- a/include/sol/types.hpp +++ b/include/sol/types.hpp @@ -1266,7 +1266,7 @@ namespace sol { using is_lua_c_function = meta::any, std::is_same, std::is_same>; template - constexpr bool is_lua_c_function_v = is_lua_c_function::value; + inline constexpr bool is_lua_c_function_v = is_lua_c_function::value; struct automagic_enrollments { bool default_constructor = true; diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index 9a8355e1..1193d47b 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/sol/forward.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2018-12-22 20:32:42.897539 UTC -// This header was generated with sol v2.20.6 (revision 88cafb2) +// Generated 2018-12-23 18:17:39.332965 UTC +// This header was generated with sol v2.20.6 (revision a6abc0a) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index c816d83a..a058613c 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2018-12-22 20:32:28.534178 UTC -// This header was generated with sol v2.20.6 (revision 88cafb2) +// Generated 2018-12-23 18:17:38.798117 UTC +// This header was generated with sol v2.20.6 (revision a6abc0a) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -3896,7 +3896,7 @@ namespace sol { using is_specialization_of = meta_detail::is_specialization_of, Templ>; template class Templ> - constexpr bool is_specialization_of_v = is_specialization_of, Templ>::value; + inline constexpr bool is_specialization_of_v = is_specialization_of, Templ>::value; template struct all_same : std::true_type {}; @@ -5940,7 +5940,7 @@ namespace sol { using is_lua_c_function = meta::any, std::is_same, std::is_same>; template - constexpr bool is_lua_c_function_v = is_lua_c_function::value; + inline constexpr bool is_lua_c_function_v = is_lua_c_function::value; struct automagic_enrollments { bool default_constructor = true; @@ -8063,19 +8063,19 @@ namespace sol { }; template - constexpr bool is_adl_sol_lua_get_v = is_adl_sol_lua_get::value; + inline constexpr bool is_adl_sol_lua_get_v = is_adl_sol_lua_get::value; template - constexpr bool is_adl_sol_lua_check_v = is_adl_sol_lua_check::value; + inline constexpr bool is_adl_sol_lua_check_v = is_adl_sol_lua_check::value; template - constexpr bool is_adl_sol_lua_check_get_v = is_adl_sol_lua_check_get::value; + inline constexpr bool is_adl_sol_lua_check_get_v = is_adl_sol_lua_check_get::value; template - constexpr bool is_adl_sol_lua_push_v = is_adl_sol_lua_push::value; + inline constexpr bool is_adl_sol_lua_push_v = is_adl_sol_lua_push::value; template - constexpr bool is_adl_sol_lua_push_exact_v = is_adl_sol_lua_push_exact::value; + inline constexpr bool is_adl_sol_lua_push_exact_v = is_adl_sol_lua_push_exact::value; }} // namespace meta::meta_detail namespace stack { diff --git a/tests/compile_tests/CMakeLists.txt b/tests/compile_tests/CMakeLists.txt index a8c50d85..a61bb6c3 100644 --- a/tests/compile_tests/CMakeLists.txt +++ b/tests/compile_tests/CMakeLists.txt @@ -37,6 +37,21 @@ function(CREATE_TEST test_target_name test_name target_sol) EXPORT_NAME sol2::${test_name}) target_link_libraries(${test_target_name} ${target_sol}) + if (MSVC) + target_compile_options(${test_target_name} + PRIVATE /std:c++latest /EHsc "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${test_target_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${test_target_name} + PRIVATE -std=c++1z -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + if (MSVC) if (NOT CMAKE_COMPILER_ID MATCHES "Clang") target_compile_options(${test_target_name} diff --git a/tests/runtime_tests/CMakeLists.txt b/tests/runtime_tests/CMakeLists.txt index 38bbd8af..feba7f9e 100644 --- a/tests/runtime_tests/CMakeLists.txt +++ b/tests/runtime_tests/CMakeLists.txt @@ -39,6 +39,13 @@ function(CREATE_TEST test_target_name test_name target_sol) EXPORT_NAME sol2::${test_name}) target_link_libraries(${test_target_name} ${target_sol}) + add_definitions(/DUNICODE /D_UNICODE /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + add_compile_options(/EHsc) + add_compile_options("$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + if (MSVC) if (NOT CMAKE_COMPILER_ID MATCHES "Clang") target_compile_options(${test_target_name} @@ -56,10 +63,26 @@ function(CREATE_TEST test_target_name test_name target_sol) endif() endif() endif() + if (MSVC) + target_compile_options(${test_target_name} + PRIVATE /EHsc /std:c++latest "$<$:/MDd>" + "$<$:/MD>" + "$<$:/MD>" + "$<$:/MD>") + target_compile_definitions(${test_target_name} + PRIVATE /DUNICODE /D_UNICODE + /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE) + else() + target_compile_options(${test_target_name} + PRIVATE -std=c++1z -Wno-unknown-warning -Wno-unknown-warning-option + -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) + endif() + if (SOL2_CI) target_compile_definitions(${test_target_name} PRIVATE SOL2_CI) endif() + if (CMAKE_DL_LIBS) target_link_libraries(${test_target_name} ${CMAKE_DL_LIBS})