Maybe this will finally fix all the example errors

This commit is contained in:
ThePhD 2018-02-12 03:55:14 -05:00
parent 18901463be
commit 8d2a25988c
14 changed files with 87 additions and 38 deletions

View File

@ -53,6 +53,15 @@ set(CXX_FEATURES
cxx_variadic_macros
cxx_variadic_templates)
# # #
if (PLATFORM MATCHES "i686" OR PLATFORM STREQUAL "x86")
set(IS_X86 TRUE)
elseif (PLATFORM MATCHES "ARM")
set(IS_ARM TRUE)
else()
set(IS_X64 TRUE)
endif()
# # # General project flags
if (MSVC)
add_definitions(/DUNICODE /D_UNICODE /D_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING /D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE)
@ -62,6 +71,10 @@ if (MSVC)
add_compile_options(/MP)
endif()
else()
if (IS_X86)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif()
add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors)
endif()
@ -208,6 +221,7 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES OR EXAMPLE
# Here, we pull in all the necessary libraries for building examples and tests
# Find threading library
if (NOT MSVC)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif()
find_package(Threads REQUIRED)

View File

@ -121,6 +121,7 @@ init:
- set logger=
- set build_type=
- set build_compiler=
- set lua_build_type=OFF
- set vcvars_script="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
- if "%PLATFORM%"=="x64" (set arch= Win64)
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (set CMAKE_GENERATOR=Visual Studio 15 2017%arch%&&set parallelism=/maxcpucount&&set logger=/verbosity:quiet /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"&&set vcvars_script="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat")
@ -145,7 +146,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% -DLUA_VERSION="%LUA_VERSION%" -DCI=ON -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=OFF -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DEXAMPLES_SINGLE=ON -DTESTS_SINGLE=ON
- cmake .. -G "%CMAKE_GENERATOR%" %build_type% %build_compiler% -DLUA_VERSION="%LUA_VERSION%" -DCI=ON -DBUILD_LUA=ON -DBUILD_LUA_AS_DLL=%lua_build_type% -DTESTS=ON -DEXAMPLES=ON -DSINGLE=ON -DTESTS_EXAMPLES=ON -DEXAMPLES_SINGLE=ON -DTESTS_SINGLE=ON
# We do not build the debug versions because the compiler
# generates too much debug info for MinGW to handle

View File

@ -43,7 +43,7 @@ ExternalProject_Add(LUABRIDGE_BUILD_SOURCE
# # Use Git to get what we need
GIT_SHALLOW TRUE
GIT_SUBMODULES ""
GIT_REPOSITORY https://github.com/vinniefalco/LuaBridge.git
GIT_REPOSITORY https://github.com/ThePhD/LuaBridge.git
PREFIX ${luabridge_build_toplevel}
SOURCE_DIR ${luabridge_build_toplevel}
DOWNLOAD_DIR ${luabridge_build_toplevel}

View File

@ -53,7 +53,6 @@ function(find_lua_build LUA_VERSION)
set(LUA_BUILD_OBJECT_FILE_SUFFIX .o)
endif()
# # # Options
option(BUILD_LUA_AS_DLL ${LUA_BUILD_BUILD_DLL_DEFAULT} "Build Lua or LuaJIT as a Shared/Dynamic Link Library")

View File

@ -236,6 +236,9 @@ elseif(LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "latest")
set(LUA_JIT_PULL_LATEST TRUE)
endif()
set(LUA_JIT_BYPRODUCTS "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_SOURCE_LUA_LIB_EXP}"
"${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_SOURCE_LUA_IMP_LIB}")
if (LUA_JIT_GIT_COMMIT OR LUA_JIT_PULL_LATEST)
if (LUA_JIT_PULL_LATEST)
MESSAGE(STATUS "Latest LuaJIT has been requested: pulling from git...")
@ -261,8 +264,7 @@ if (LUA_JIT_GIT_COMMIT OR LUA_JIT_PULL_LATEST)
${LUA_JIT_BUILD_COMMAND}
INSTALL_COMMAND ""
TEST_COMMAND ""
BUILD_BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}"
"${LUA_JIT_DESTINATION_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}")
BUILD_BYPRODUCTS "${LUA_JIT_BYPRODUCTS}")
else()
ExternalProject_Add(LUA_JIT
BUILD_IN_SOURCE TRUE
@ -282,50 +284,62 @@ else()
${LUA_JIT_BUILD_COMMAND}
INSTALL_COMMAND ""
TEST_COMMAND ""
BUILD_BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}"
"${LUA_JIT_DESTINATION_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}")
BUILD_BYPRODUCTS "${LUA_JIT_BYPRODUCTS}")
endif()
# # Post-Build moving steps for necessary items
# Add post-step to move library afterwards
set(LUA_JIT_EXTERNAL_PROJECT_DEPS "")
if (MSVC)
ExternalProject_Add_Step(LUA_JIT
postbuild.exp
DEPENDEES build
COMMENT "Libray - Moving \"${LUA_JIT_SOURCE_LUA_LIB_EXP}\" to \"${LUA_JIT_DESTINATION_LUA_LIB_EXP}\"..."
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB_EXP}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}" && echo Successfully moved!)
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB_EXP}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}"
BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_LIB_EXP}")
ExternalProject_Add_StepTargets(LUA_JIT postbuild_exp)
list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_exp")
endif()
if (BUILD_LUA_AS_DLL)
if (MSVC)
MESSAGE(STATUS ${LUA_JIT_SOURCE_LUA_IMP_LIB})
MESSAGE(STATUS ${LUA_JIT_DESTINATION_LUA_IMP_LIB})
ExternalProject_Add_Step(LUA_JIT
postbuild.import.lib
postbuild_import_lib
DEPENDEES build
COMMENT "Libray - Moving \"${LUA_JIT_SOURCE_LUA_IMP_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_IMP_LIB}\"..."
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_IMP_LIB}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}"
COMMAND echo Successfully moved!)
BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_IMP_LIB}")
ExternalProject_Add_StepTargets(LUA_JIT postbuild_import_lib)
list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_import_lib")
endif()
MESSAGE(STATUS ${LUA_JIT_SOURCE_LUA_DLL})
MESSAGE(STATUS ${LUA_JIT_DESTINATION_LUA_DLL})
MESSAGE(STATUS ${LUA_JIT_DLL_FILE})
ExternalProject_Add_Step(LUA_JIT
postbuild.dll
postbuild_dll
DEPENDEES build
COMMENT "Dynamic Library - Moving \"${LUA_JIT_SOURCE_LUA_DLL}\" to \"${LUA_JIT_DESTINATION_LUA_DLL}\"..."
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_DLL}" && echo Successfully moved!)
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_DLL}"
BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_DLL}")
ExternalProject_Add_StepTargets(LUA_JIT postbuild_dll)
list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_dll")
else()
ExternalProject_Add_Step(LUA_JIT
postbuild.lib
postbuild_lib
DEPENDEES build
COMMENT "Library - Moving \"${LUA_JIT_SOURCE_LUA_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_LIB}\"..."
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB}" && echo Successfully moved!)
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB}"
BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_LIB}")
ExternalProject_Add_StepTargets(LUA_JIT postbuild_lib)
list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_lib")
endif()
ExternalProject_Add_Step(LUA_JIT
postbuild.exe
postbuild_exe
DEPENDEES build
COMMENT "Library - Moving \"${LUA_JIT_SOURCE_LUA_INTERPRETER}\" to \"${LUA_JIT_DESTINATION_LUA_INTERPRETER}\"..."
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_INTERPRETER}" "${LUA_JIT_DESTINATION_LUA_INTERPRETER}" && echo Successfully moved!)
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_INTERPRETER}" "${LUA_JIT_DESTINATION_LUA_INTERPRETER}"
BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_INTERPRETER}")
ExternalProject_Add_StepTargets(LUA_JIT postbuild_exe)
list(APPEND LUA_JIT_EXTERNAL_PROJECT_DEPS "LUA_JIT-postbuild_exe")
# # TODO:
# Add additional post-build step to move all necessary headers/lua files
# for now, we just point directly to the `src` directory...
@ -333,18 +347,15 @@ ExternalProject_Add_Step(LUA_JIT
# # Lua Library
add_library(${lualib} ${LUA_BUILD_LIBRARY_TYPE} IMPORTED)
# make sure the library we export really does depend on Lua JIT's external project
add_dependencies(${lualib} LUA_JIT)
add_dependencies(${lualib} LUA_JIT ${LUA_JIT_EXTERNAL_PROJECT_DEPS})
if (BUILD_LUA_AS_DLL)
if (MSVC)
set_target_properties(${lualib}
PROPERTIES
IMPORTED_IMPLIB "${LUA_JIT_IMP_LIB_FILE}")
endif()
MESSAGE(STATUS "${LUA_JIT_DLL_FILE}")
MESSAGE(STATUS "${LUA_JIT_DESTINATION_LUA_DLL}")
set_target_properties(${lualib}
PROPERTIES
#IMPORTED_SONAME "${LUA_BUILD_LIBNAME}"
IMPORTED_LOCATION "${LUA_JIT_DLL_FILE}")
else ()
set_target_properties(${lualib}

View File

@ -295,7 +295,7 @@ if (MSVC)
PRIVATE /W1)
else()
target_compile_options(${liblua}
PRIVATE -w -Wno-implicit-fallthrough)
PRIVATE -w)
endif()
if (WIN32)
#target_compile_definitions(${liblua}
@ -332,6 +332,9 @@ target_compile_definitions(${luainterpreter}
if (MSVC)
target_compile_options(${luainterpreter}
PRIVATE /W1)
else()
target_compile_options(${luainterpreter}
PRIVATE -w)
endif()
if (WIN32)
#target_compile_definitions(${luainterpreter}
@ -373,6 +376,9 @@ target_compile_definitions(${luacompiler}
if (MSVC)
target_compile_options(${luacompiler}
PRIVATE /W1)
else()
target_compile_options(${luacompiler}
PRIVATE -w)
endif()
if (WIN32)
#target_compile_definitions(${luacompiler}

View File

@ -33,7 +33,7 @@ set(toluapp_build_toplevel "${CMAKE_BINARY_DIR}/vendor/toluapp_${toluapp_version
set(toluapp_include_dirs "${toluapp_build_toplevel}/include")
# # ToLua library sources
set(toluapp_sources tolua_event.c tolua_event.h tolua_is.c tolua_map.c tolua_push.c tolua_to.c)
set(toluapp_sources tolua_event.c tolua_event.h tolua_is.c tolua_map.c tolua_push.c tolua_to.c tolua_compat.h tolua_compat.c)
prepend(toluapp_sources "${toluapp_build_toplevel}/src/lib/" ${toluapp_sources})
list(APPEND toluapp_sources "${toluapp_build_toplevel}/include/tolua++.h")
@ -44,7 +44,7 @@ ExternalProject_Add(TOLUAPP_BUILD_SOURCE
# # Use Git to get what we need
#GIT_SUBMODULES ""
GIT_SHALLOW TRUE
GIT_REPOSITORY https://github.com/waltervn/toluapp.git
GIT_REPOSITORY https://github.com/ThePhD/toluapp
PREFIX ${toluapp_build_toplevel}
SOURCE_DIR ${toluapp_build_toplevel}
DOWNLOAD_DIR ${toluapp_build_toplevel}
@ -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} ${LUA_LIBRARIES})
target_link_libraries(${toluapp_lib} PRIVATE ${LUA_LIBRARIES})
if (MSVC)
target_compile_options(${toluapp_lib}
PRIVATE /W1)
@ -77,6 +77,9 @@ else()
INTERFACE -Wno-noexcept-type
PUBLIC -Wno-ignored-qualifiers -Wno-unused-parameter)
endif()
# add compatibility define
target_compile_definitions(${toluapp_lib}
PRIVATE COMPAT53_PREFIX=toluapp_compat53)
# # Variables required by ToLuaBuild
set(TOLUAPP_LIBRARIES ${toluapp_lib})

View File

@ -22,11 +22,11 @@
# # # sol2 Examples
# # require_from_dll example
# just add the subdirectory
add_subdirectory(require_dll_example)
if (INTEROP_EXAMPLES)
# # require_from_dll example
# just add the subdirectory
add_subdirectory(require_dll_example)
# # interop examples
add_subdirectory(interop/kaguya)
add_subdirectory(interop/tolua)

View File

@ -31,6 +31,9 @@ function (make_luabridge_interop_example target_library is_single)
endif(is_single)
add_executable(${example_name} LuaBridge.cpp)
target_link_libraries(${example_name} PUBLIC ${LUA_LIBRARIES} PRIVATE ${LUABRIDGE_LIBRARIES} ${target_library})
if (CMAKE_DL_LIBS)
target_link_libraries(${example_name} PRIVATE ${CMAKE_DL_LIBS})
endif()
if (NOT MSVC)
target_compile_options(${example_name} PRIVATE -Wno-noexcept-type -Wignored-qualifiers -Wunused-parameter)
endif()

View File

@ -31,6 +31,9 @@ function (make_kaguya_interop_example target_library is_single)
endif(is_single)
add_executable(${example_name} kaguya.cpp)
target_link_libraries(${example_name} PUBLIC ${LUA_LIBRARIES} PRIVATE ${KAGUYA_LIBRARIES} ${target_library})
if (CMAKE_DL_LIBS)
target_link_libraries(${example_name} PRIVATE ${CMAKE_DL_LIBS})
endif()
if (NOT MSVC)
target_compile_options(${example_name} PRIVATE -Wno-noexcept-type)
endif()

View File

@ -1,9 +1,9 @@
#include <kaguya/kaguya.hpp>
#define SOL_CHECK_ARGUMENTS 1
#define SOL_ENABLE_INTEROP 1 // MUST be defined to use interop features
#include <sol.hpp>
#include <kaguya/kaguya.hpp>
#include <iostream>
#include "../../assert.hpp"

View File

@ -31,6 +31,9 @@ function (make_luwra_interop_example target_library is_single)
endif(is_single)
add_executable(${example_name} luwra.cpp)
target_link_libraries(${example_name} PUBLIC ${LUA_LIBRARIES} PRIVATE ${LUWRA_LIBRARIES} ${target_library})
if (CMAKE_DL_LIBS)
target_link_libraries(${example_name} PRIVATE ${CMAKE_DL_LIBS})
endif()
if (NOT MSVC)
target_compile_options(${example_name} PRIVATE -Wno-noexcept-type)
endif()

View File

@ -31,6 +31,9 @@ function(make_tolua_interop_example target_library is_single)
endif()
add_executable(${example_name} tolua.cpp)
target_link_libraries(${example_name} PUBLIC ${LUA_LIBRARIES} PRIVATE ${TOLUAPP_LIBRARIES} ${target_library})
if (CMAKE_DL_LIBS)
target_link_libraries(${example_name} PRIVATE ${CMAKE_DL_LIBS})
endif()
if (NOT MSVC)
target_compile_options(${example_name} PRIVATE -Wno-noexcept-type -Wno-unused-function -Wno-pedantic)
endif()

View File

@ -38,7 +38,8 @@ function(make_require_from_dll_example target_lib is_single)
endif()
# is the lua library a shared or static library?
get_target_property(lua_lib_type ${LUA_LIBRARIES} TYPE)
list(GET LUA_LIBRARIES 0 lua_lib_target)
get_target_property(lua_lib_type ${lua_lib_target} TYPE)
# add library target my_object for the require_from_dll program
add_library(${example_lib_name} SHARED ${my_object_sources})
@ -83,7 +84,9 @@ function(make_require_from_dll_example target_lib is_single)
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
# target_link_libraries(${example_name} PRIVATE ${LUA_LIBRARIES})
if (NOT lua_lib_type MATCHES "STATIC")
target_link_libraries(${example_name} PRIVATE ${LUA_LIBRARIES})
endif()
target_include_directories(${example_name} PRIVATE ${LUA_INCLUDE_DIRS})
if (TESTS_EXAMPLES)