diff --git a/cmake/Packages/FindKaguyaBuild.cmake b/cmake/Packages/FindKaguyaBuild.cmake index eb99c414..fe7719a3 100644 --- a/cmake/Packages/FindKaguyaBuild.cmake +++ b/cmake/Packages/FindKaguyaBuild.cmake @@ -60,7 +60,7 @@ ExternalProject_Add(KAGUYA_BUILD_SOURCE add_library(${kaguya_lib} INTERFACE) add_dependencies(${kaguya_lib} KAGUYA_BUILD_SOURCE) target_include_directories(${kaguya_lib} INTERFACE ${kaguya_include_dirs}) -target_link_libraries(${kaguya_lib} INTERFACE ${LUA_LIBRARIES}) +target_link_libraries(${kaguya_lib} INTERFACE Lua::Lua) if (NOT MSVC) target_compile_options(${kaguya_lib} INTERFACE -Wno-noexcept-type -Wno-ignored-qualifiers -Wno-unused-parameter) diff --git a/cmake/Packages/FindLuaBridgeBuild.cmake b/cmake/Packages/FindLuaBridgeBuild.cmake index b4534e23..1ee91652 100644 --- a/cmake/Packages/FindLuaBridgeBuild.cmake +++ b/cmake/Packages/FindLuaBridgeBuild.cmake @@ -59,7 +59,7 @@ ExternalProject_Add(LUABRIDGE_BUILD_SOURCE add_library(${luabridge_lib} INTERFACE) add_dependencies(${luabridge_lib} LUABRIDGE_BUILD_SOURCE) target_include_directories(${luabridge_lib} INTERFACE ${luabridge_include_dirs}) -target_link_libraries(${luabridge_lib} INTERFACE ${LUA_LIBRARIES}) +target_link_libraries(${luabridge_lib} INTERFACE Lua::Lua) if (NOT MSVC) target_compile_options(${luabridge_lib} INTERFACE -Wno-noexcept-type -Wno-ignored-qualifiers -Wno-unused-parameter) diff --git a/cmake/Packages/FindLuaBuild.cmake b/cmake/Packages/FindLuaBuild.cmake index 7e6a71f0..14fd4d48 100644 --- a/cmake/Packages/FindLuaBuild.cmake +++ b/cmake/Packages/FindLuaBuild.cmake @@ -88,7 +88,7 @@ function(find_lua_build LUA_VERSION) endif() # # Export variables to the parent scope - set(LUA_LIBRARIES ${LUA_LIBRARIES} PARENT_SCOPE) + set(LUA_LIBRARIES Lua::Lua PARENT_SCOPE) set(LUA_INTERPRETER ${LUA_INTERPRETER} PARENT_SCOPE) set(LUA_INCLUDE_DIRS ${LUA_INCLUDE_DIRS} PARENT_SCOPE) set(LUA_VERSION_STRING ${LUA_VERSION_STRING} PARENT_SCOPE) diff --git a/cmake/Packages/FindLuaBuild/LuaVanilla.cmake b/cmake/Packages/FindLuaBuild/LuaVanilla.cmake index 8b1fa541..b4c3c800 100644 --- a/cmake/Packages/FindLuaBuild/LuaVanilla.cmake +++ b/cmake/Packages/FindLuaBuild/LuaVanilla.cmake @@ -103,20 +103,20 @@ if (LUA_VANILLA_VERSION MATCHES "^5\\.1") lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c ltablib.c lstrlib.c loadlib.c linit.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c print.c ) -endif() + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c print.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP true) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.2") - set(LUA_VANILLA_LIB_SOURCES lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c + set(LUA_VANILLA_LIB_SOURCES lapi.c lbitlib.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c) - set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c ) -endif() + set(LUA_VANILLA_LUA_SOURCES lua.c) + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.3") set(LUA_VANILLA_LIB_SOURCES lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c @@ -125,9 +125,9 @@ elseif (LUA_VANILLA_VERSION MATCHES "^5\\.3") lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c loadlib.c linit.c) set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c ) -endif() + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) elseif (LUA_VANILLA_VERSION MATCHES "^5\\.4") if (LUA_VANILLA_VERSION MATCHES "work" OR LUA_VANILLA_VERSION MATCHES "alpha" OR LUA_VANILLA_VERSION MATCHES "beta") @@ -138,10 +138,10 @@ elseif (LUA_VANILLA_VERSION MATCHES "^5\\.4") llex.c lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c) - set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c ) -endif() + set(LUA_VANILLA_LUA_SOURCES lua.c) + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) else() MESSAGE(WARNING "Using Lua 5.4.4 file list for ${LUA_VERSION} version") @@ -150,10 +150,10 @@ else() llex.c lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c) - set(LUA_VANILLA_LUA_SOURCES lua.c ) -if (LUA_BUILD_LUA_COMPILER) - set(LUA_VANILLA_LUAC_SOURCES luac.c ) -endif() + set(LUA_VANILLA_LUA_SOURCES lua.c) + if (LUA_BUILD_LUA_COMPILER) + set(LUA_VANILLA_LUAC_SOURCES luac.c) + endif() set(LUA_VANILLA_GENERATE_LUA_HPP false) endif() @@ -217,6 +217,7 @@ set(luacompiler "luac-${LUA_VANILLA_VERSION}") # make an actual, buildable target # that other parts of the code can depend on add_library(${liblua} ${LUA_BUILD_LIBRARY_TYPE} ${LUA_VANILLA_LIB_SOURCES}) +add_library(Lua::Lua ALIAS ${liblua}) set_target_properties(${liblua} PROPERTIES LANGUAGE ${LUA_VANILLA_LANGUAGE} @@ -233,7 +234,9 @@ set_source_files_properties(${LUA_VANILLA_LIB_SOURCES} target_include_directories(${liblua} PUBLIC "${LUA_VANILLA_INCLUDE_DIRS}") target_compile_definitions(${liblua} - PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE}) + PUBLIC + LUA_COMPAT_ALL + ${LUA_VANILLA_DLL_DEFINE}) if (MSVC) target_compile_options(${liblua} PRIVATE /W1) diff --git a/cmake/Packages/FindLuwraBuild.cmake b/cmake/Packages/FindLuwraBuild.cmake index 0315bb84..28a5a259 100644 --- a/cmake/Packages/FindLuwraBuild.cmake +++ b/cmake/Packages/FindLuwraBuild.cmake @@ -59,7 +59,7 @@ ExternalProject_Add(LUWRA_BUILD_SOURCE add_library(${luwra_lib} INTERFACE) add_dependencies(${luwra_lib} LUWRA_BUILD_SOURCE) target_include_directories(${luwra_lib} INTERFACE ${luwra_include_dirs}) -target_link_libraries(${luwra_lib} INTERFACE ${LUA_LIBRARIES}) +target_link_libraries(${luwra_lib} INTERFACE Lua::Lua) if (NOT MSVC) target_compile_options(${luwra_lib} INTERFACE -Wno-noexcept-type -Wno-ignored-qualifiers -Wno-unused-parameter) diff --git a/cmake/Packages/FindToLuappBuild.cmake b/cmake/Packages/FindToLuappBuild.cmake index be3f11ba..652dbc01 100644 --- a/cmake/Packages/FindToLuappBuild.cmake +++ b/cmake/Packages/FindToLuappBuild.cmake @@ -65,7 +65,7 @@ set_target_properties(${toluapp_lib} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) target_include_directories(${toluapp_lib} PUBLIC ${toluapp_include_dirs}) -target_link_libraries(${toluapp_lib} PRIVATE ${LUA_LIBRARIES} ${CMAKE_DL_LIBS}) +target_link_libraries(${toluapp_lib} PRIVATE Lua::Lua ${CMAKE_DL_LIBS}) if (MSVC) target_compile_options(${toluapp_lib} PRIVATE /W1) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e33c45b4..0ff8a112 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,7 +24,7 @@ function(sol2_add_example_properties target-name) target_link_libraries(${target-name} - PUBLIC Threads::Threads ${LUA_LIBRARIES} ${CMAKE_DL_LIBS}) + PUBLIC Threads::Threads Lua::Lua ${CMAKE_DL_LIBS}) target_compile_definitions(${target-name} PUBLIC SOL_PRINT_ERRORS=1) target_compile_options(${target-name} diff --git a/examples/customization/CMakeLists.txt b/examples/customization/CMakeLists.txt index 48f5f5b7..11312dfe 100644 --- a/examples/customization/CMakeLists.txt +++ b/examples/customization/CMakeLists.txt @@ -50,7 +50,7 @@ function (MAKE_CUSTOMIZATION_EXAMPLE example_suffix target_sol) endif() target_link_libraries(${customization_example_name} - PRIVATE Threads::Threads ${target_sol} ${LUA_LIBRARIES}) + PRIVATE Threads::Threads ${target_sol} Lua::Lua) target_include_directories(${customization_example_name} PRIVATE include) endfunction() diff --git a/examples/interop/LuaBridge/CMakeLists.txt b/examples/interop/LuaBridge/CMakeLists.txt index 423ef625..1e2c0ae3 100644 --- a/examples/interop/LuaBridge/CMakeLists.txt +++ b/examples/interop/LuaBridge/CMakeLists.txt @@ -30,7 +30,7 @@ function (make_luabridge_interop_example target_library example_suffix) add_executable(${example_name} source/LuaBridge.cpp) target_link_libraries(${example_name} - PRIVATE ${LUA_LIBRARIES} ${LUABRIDGE_LIBRARIES} + PRIVATE Lua::Lua ${LUABRIDGE_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) if (MSVC) diff --git a/examples/interop/kaguya/CMakeLists.txt b/examples/interop/kaguya/CMakeLists.txt index a0b7b13c..6b3a9acc 100644 --- a/examples/interop/kaguya/CMakeLists.txt +++ b/examples/interop/kaguya/CMakeLists.txt @@ -30,7 +30,7 @@ function (make_kaguya_interop_example target_library example_suffix) add_executable(${example_name} source/kaguya.cpp) target_link_libraries(${example_name} - PRIVATE ${LUA_LIBRARIES} ${KAGUYA_LIBRARIES} + PRIVATE Lua::Lua ${KAGUYA_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) if (MSVC) diff --git a/examples/interop/luwra/CMakeLists.txt b/examples/interop/luwra/CMakeLists.txt index bf9aaced..c070ffdd 100644 --- a/examples/interop/luwra/CMakeLists.txt +++ b/examples/interop/luwra/CMakeLists.txt @@ -30,7 +30,7 @@ function (make_luwra_interop_example target_library example_suffix) add_executable(${example_name} source/luwra.cpp) target_link_libraries(${example_name} - PRIVATE ${LUA_LIBRARIES} ${LUWRA_LIBRARIES} + PRIVATE Lua::Lua ${LUWRA_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) if (MSVC) diff --git a/examples/interop/tolua/CMakeLists.txt b/examples/interop/tolua/CMakeLists.txt index 0b4c8125..3f151ba9 100644 --- a/examples/interop/tolua/CMakeLists.txt +++ b/examples/interop/tolua/CMakeLists.txt @@ -31,7 +31,7 @@ function(make_tolua_interop_example target_library example_suffix) add_executable(${example_name} source/tolua.cpp) target_link_libraries(${example_name} PRIVATE - ${LUA_LIBRARIES} ${TOLUAPP_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) + Lua::Lua ${TOLUAPP_LIBRARIES} ${target_library} ${CMAKE_DL_LIBS}) if (MSVC) target_compile_options(${example_name} diff --git a/examples/require_dll_example/CMakeLists.txt b/examples/require_dll_example/CMakeLists.txt index ddd40b25..15c5df1d 100644 --- a/examples/require_dll_example/CMakeLists.txt +++ b/examples/require_dll_example/CMakeLists.txt @@ -46,7 +46,7 @@ function(make_require_from_dll_example target_lib example_lib_name_suffix) PUBLIC MY_OBJECT_DLL PRIVATE MY_OBJECT_BUILD) target_link_libraries(${example_lib_name} - PUBLIC ${target_lib} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS}) + PUBLIC ${target_lib} Lua::Lua ${CMAKE_DL_LIBS}) target_include_directories(${example_lib_name} PUBLIC "${LUA_INCLUDE_DIRS}") @@ -83,7 +83,7 @@ function(make_require_from_dll_example target_lib example_lib_name_suffix) # add executable target that represents require_from_dll program add_executable(${example_name} ${require_from_dll_sources}) target_link_libraries(${example_name} - PRIVATE my_object ${LUA_LIBRARIES} ${target_lib} ${CMAKE_DL_LIBS}) + PRIVATE my_object Lua::Lua ${target_lib} ${CMAKE_DL_LIBS}) target_include_directories(${example_name} PRIVATE ${LUA_INCLUDE_DIRS}) diff --git a/include/sol/abort.hpp b/include/sol/abort.hpp new file mode 100644 index 00000000..692244da --- /dev/null +++ b/include/sol/abort.hpp @@ -0,0 +1,47 @@ +// sol2 + +// The MIT License (MIT) + +// Copyright (c) 2013-2022 Rapptz, ThePhD and contributors + +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#ifndef SOL_ABORT_HPP +#define SOL_ABORT_HPP + +#include + +#include + +#include + +// clang-format off +#if SOL_IS_ON(SOL_DEBUG_BUILD) + #if SOL_IS_ON(SOL_COMPILER_VCXX) + #define SOL_DEBUG_ABORT() \ + if (true) { ::std::abort(); } \ + static_assert(true, "") + #else + #define SOL_DEBUG_ABORT() ::std::abort() + #endif +#else + #define SOL_DEBUG_ABORT() static_assert(true, "") +#endif +// clang-format on + +#endif // SOL_ABORT_HPP diff --git a/include/sol/base_traits.hpp b/include/sol/base_traits.hpp index 811e7992..204afc27 100644 --- a/include/sol/base_traits.hpp +++ b/include/sol/base_traits.hpp @@ -62,6 +62,39 @@ namespace sol { template