diff --git a/.travis.yml b/.travis.yml index 74ec2946..eb0c336e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,16 +45,22 @@ matrix: - ALLOW_FAILURE=true include: # GCC 4.9.x, 5.x, 6.x, 7.x + - env: + - LUA_VERSION=5.3.4 + GCC_VERSION=7 + PLATFORM=i686 + CI=true + - env: - LUA_VERSION=luajit-2.0.5 GCC_VERSION=7 - PLATFORM=x86 + PLATFORM=i686 CI=true - env: - LUA_VERSION=luajit-2.1.0-beta3 GCC_VERSION=7 - PLATFORM=x86 + PLATFORM=i686 CI=true - env: diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bb0e7ac..bfe4aefa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,8 +56,13 @@ set(CXX_FEATURES # # # if (PLATFORM MATCHES "i686" OR PLATFORM STREQUAL "x86") set(IS_X86 TRUE) +elseif (PLATFORM MATCHES "ARM64") + set(IS_ARM64 TRUE) + set(IS_X64 TRUE) elseif (PLATFORM MATCHES "ARM") set(IS_ARM TRUE) +elseif (PLATFORM MATCHES "x86_64" OR PLATFORM STREQUAL "x64") + set(IS_X64 TRUE) else() set(IS_X64 TRUE) endif() @@ -78,17 +83,8 @@ else() add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors) endif() -if (CI) - #if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++") - # add_compile_options("$<$,CXX>:-stdlib=libc++>") - # LIST(APPEND CMAKE_LIBRARY_PATH_FLAG "$$ENV{CLANG_PREFIX}/lib") - # include_directories("$ENV{CLANG_PREFIX}/include/c++/v1") - #endif() -endif() - # # # General project output locations -if (PLATFORM MATCHES "x86" OR CMAKE_SIZEOF_VOID_P EQUAL 4) +if (IS_X86 OR CMAKE_SIZEOF_VOID_P EQUAL 4) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/x86/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/x86/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/x86/bin") @@ -118,6 +114,7 @@ option(CI "Enable build of tests" OFF) option(TESTS "Enable build of tests" OFF) option(EXAMPLES "Enable build of examples" OFF) option(INTEROP_EXAMPLES "Enable build of interop examples" OFF) +option(DYNAMIC_LOADING_EXAMPLES "Enable build of interop examples" OFF) option(SINGLE "Enable build of single header files" ON) option(DOCS "Enable build of documentation" OFF) # Single tests and examples tests will only be turned on if both SINGLE and TESTS are defined @@ -125,12 +122,16 @@ CMAKE_DEPENDENT_OPTION(TESTS_SINGLE "Enable build of tests using the generated s "SINGLE;TESTS" OFF) CMAKE_DEPENDENT_OPTION(EXAMPLES_SINGLE "Enable build of examples using the generated single headers" OFF "SINGLE;EXAMPLES" OFF) -CMAKE_DEPENDENT_OPTION(INTEROP_EXAMPLES_SINGLE "Enable build of examples using the generated single headers" OFF +CMAKE_DEPENDENT_OPTION(INTEROP_EXAMPLES_SINGLE "Enable build of interop examples using the generated single headers" OFF "SINGLE;INTEROP_EXAMPLES" OFF) +CMAKE_DEPENDENT_OPTION(DYNAMIC_LOADING_EXAMPLES_SINGLE "Enable build of dynamic loading examples using the generated single headers" OFF + "SINGLE;DYNAMIC_LOADING_EXAMPLES" OFF) CMAKE_DEPENDENT_OPTION(TESTS_EXAMPLES "Enable build of examples as tests" ON "EXAMPLES" OFF) CMAKE_DEPENDENT_OPTION(TESTS_INTEROP_EXAMPLES "Enable build of interop examples as tests" ON - "EXAMPLES;INTEROP_EXAMPLES" OFF) + "INTEROP_EXAMPLES" OFF) +CMAKE_DEPENDENT_OPTION(TESTS_DYNAMIC_LOADING_EXAMPLES "Enable build of dynamic loading examples as tests" ON + "DYNAMIC_LOADING_EXAMPLES" OFF) # # # sol2 Library @@ -215,8 +216,26 @@ if (CI) message(STATUS "sol2 Contiguous Integration is on") endif() +if (EXAMPLES OR TESTS_EXAMPLES OR EXAMPLES_SINGLE OR INTEROP_EXAMPLES OR TESTS_INTEROP_EXAMPLES OR INTEROP_EXAMPLES_SINGLE OR DYNAMIC_LOADING_EXAMPLES OR TESTS_DYNAMIC_LOADING_EXAMPLES OR DYNAMIC_LOADING_EXAMPLES_SINGLE) + set(DO_EXAMPLES TRUE) +else() + set(DO_EXAMPLES FALSE) +endif() + +if (TESTS OR TESTS_SINGLE) + set(DO_TESTS TRUE) +else() + set(DO_TESTS FALSE) +endif() + +if (DO_TESTS OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES OR TESTS_DYNAMIC_LOADING_EXAMPLES) + set(ENABLE_TESTING TRUE) +else() + set(ENABLE_TESTING FALSE) +endif() + # # # Tests, Examples and other CI suites that come with sol2 -if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE OR INTEROP_EXAMPLES) +if (DO_TESTS OR DO_EXAMPLES) # # # Libraries # Here, we pull in all the necessary libraries for building examples and tests # Find threading library @@ -251,7 +270,7 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES OR EXAMPLE endif() # # Enable test harness for regular, example or single tests - if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES) + if (ENABLE_TESTING) # enable ctest message(STATUS "sol2 testing enabled") enable_testing() @@ -259,7 +278,7 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES OR EXAMPLE # # # Examples # # Enable examples to be built against the library - if (EXAMPLES OR TESTS_EXAMPLES OR EXAMPLES_SINGLE OR INTEROP_EXAMPLES OR INTEROP_EXAMPLES_SINGLE OR TEST_INTEROP_EXAMPLES) + if (DO_EXAMPLES) # NOTE: will also add to tests if TESTS is defined message(STATUS "sol2 adding examples...") add_subdirectory(examples "${CMAKE_BINARY_DIR}/examples") @@ -267,10 +286,9 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR TESTS_INTEROP_EXAMPLES OR EXAMPLE # # # Tests # # Add tests here - if (TESTS OR TESTS_SINGLE) + if (DO_TESTS) # add subdir to get going message(STATUS "sol2 adding tests...") add_subdirectory(tests "${CMAKE_BINARY_DIR}/tests") endif() - endif() diff --git a/cmake/Modules/FindLuaBuild/LuaJIT.cmake b/cmake/Modules/FindLuaBuild/LuaJIT.cmake index 40b6027a..987e65ed 100644 --- a/cmake/Modules/FindLuaBuild/LuaJIT.cmake +++ b/cmake/Modules/FindLuaBuild/LuaJIT.cmake @@ -196,6 +196,12 @@ else () list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "BUILDMODE=static") set(LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS} -fPIC") endif() + if (IS_X86) + list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "CC=${CMAKE_C_COMPILER} -m32") + #set(LUA_JIT_MAKE_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS} -m32") + #set(LUA_JIT_MAKE_HOST_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_HOST_CFLAGS_MODIFICATIONS} -m32") + #set(LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS "${LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS} -m32") + endif() set(LUA_JIT_PREBUILT_DLL ${LUA_JIT_DLL_FILENAME}) set(LUA_JIT_PREBUILT_LIB ${LUA_JIT_LIB_FILENAME}) @@ -206,7 +212,7 @@ else () endif() list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "CFLAGS=${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS}") list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "TARGET_CFLAGS=${LUA_JIT_MAKE_TARGET_CFLAGS_MODIFICATIONS}") - list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "HOST_CFLAGS=${LUA_JIT_MAKE_CFLAGS_MODIFICATIONS}") + list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "HOST_CFLAGS=${LUA_JIT_MAKE_HOST_CFLAGS_MODIFICATIONS}") set(LUA_JIT_BUILD_COMMAND BUILD_COMMAND "${MAKE_PROGRAM}" ${LUA_JIT_MAKE_BUILD_MODIFICATIONS}) endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 696477b3..e7b0feec 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,11 +22,13 @@ # # # sol2 Examples -if (INTEROP_EXAMPLES) +if (DYNAMIC_LOADING_EXAMPLES) # # require_from_dll example # just add the subdirectory add_subdirectory(require_dll_example) - +endif(DYNAMIC_LOADING_EXAMPLES) + +if (INTEROP_EXAMPLES) # # interop examples add_subdirectory(interop/kaguya) add_subdirectory(interop/tolua) diff --git a/examples/interop/LuaBridge/CMakeLists.txt b/examples/interop/LuaBridge/CMakeLists.txt index 6d973951..50b5c0f3 100644 --- a/examples/interop/LuaBridge/CMakeLists.txt +++ b/examples/interop/LuaBridge/CMakeLists.txt @@ -34,8 +34,10 @@ function (make_luabridge_interop_example target_library is_single) 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) + if (MSVC) + target_compile_options(${example_name} PRIVATE /W1) + else() + target_compile_options(${example_name} PRIVATE -w) endif() if (TESTS_EXAMPLES) add_test(NAME ${example_name} COMMAND ${example_name}) diff --git a/examples/interop/kaguya/CMakeLists.txt b/examples/interop/kaguya/CMakeLists.txt index 4e8c0914..2bf0ed32 100644 --- a/examples/interop/kaguya/CMakeLists.txt +++ b/examples/interop/kaguya/CMakeLists.txt @@ -34,8 +34,10 @@ function (make_kaguya_interop_example target_library is_single) 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) + if (MSVC) + target_compile_options(${example_name} PRIVATE /W1) + else() + target_compile_options(${example_name} PRIVATE -w) endif() if (TESTS_INTEROP_EXAMPLES) add_test(NAME ${example_name} COMMAND ${example_name}) diff --git a/examples/interop/luwra/CMakeLists.txt b/examples/interop/luwra/CMakeLists.txt index b264a461..267d5413 100644 --- a/examples/interop/luwra/CMakeLists.txt +++ b/examples/interop/luwra/CMakeLists.txt @@ -34,8 +34,10 @@ function (make_luwra_interop_example target_library is_single) 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) + if (MSVC) + target_compile_options(${example_name} PRIVATE /W1) + else() + target_compile_options(${example_name} PRIVATE -w) endif() if (TESTS_EXAMPLES) add_test(NAME ${example_name} COMMAND ${example_name}) diff --git a/examples/interop/tolua/CMakeLists.txt b/examples/interop/tolua/CMakeLists.txt index 71592723..59ce0513 100644 --- a/examples/interop/tolua/CMakeLists.txt +++ b/examples/interop/tolua/CMakeLists.txt @@ -34,8 +34,10 @@ function(make_tolua_interop_example target_library is_single) 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) + if (MSVC) + target_compile_options(${example_name} PRIVATE /W1) + else() + target_compile_options(${example_name} PRIVATE -w) endif() if (TESTS_EXAMPLES) add_test(NAME ${example_name} COMMAND ${example_name}) diff --git a/examples/require_dll_example/CMakeLists.txt b/examples/require_dll_example/CMakeLists.txt index 30744e28..bdd6034e 100644 --- a/examples/require_dll_example/CMakeLists.txt +++ b/examples/require_dll_example/CMakeLists.txt @@ -89,8 +89,8 @@ function(make_require_from_dll_example target_lib is_single) endif() target_include_directories(${example_name} PRIVATE ${LUA_INCLUDE_DIRS}) - if (TESTS_EXAMPLES) - if ((NOT is_single) OR (is_single AND TESTS_SINGLE)) + 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() @@ -98,6 +98,6 @@ function(make_require_from_dll_example target_lib is_single) endfunction() make_require_from_dll_example(sol2 FALSE) -if (EXAMPLES_SINGLE OR TESTS_SINGLE) +if (SOL2_SINGLE_FOUND AND DYNAMIC_LOADING_EXAMPLES_SINGLE) make_require_from_dll_example(sol2_single TRUE) endif() \ No newline at end of file diff --git a/scripts/run.linux.sh b/scripts/run.linux.sh index 3dff2d68..a5362a0c 100644 --- a/scripts/run.linux.sh +++ b/scripts/run.linux.sh @@ -52,7 +52,7 @@ echo -en "travis_fold:start:build_preparation.1\r" if [[ ${LUA_VERSION} =~ "5.3" ]] then - export INTEROP_DEFINES="-DINTEROP_EXAMPLES=ON -DTESTS_INTEROP_EXAMPLES=ON -DINTEROP_EXAMPLES_SINGLE=ON" + export INTEROP_DEFINES="-DINTEROP_EXAMPLES=ON -DTESTS_INTEROP_EXAMPLES=ON -DINTEROP_EXAMPLES_SINGLE=ON -DDYNAMIC_LOADING_EXAMPLES=ON -DDYNAMIC_LOADING_EXAMPLES_SINGLE=ON -DTESTS_DYNAMIC_LOADING_EXAMPLES=ON" else export INTEROP_DEFINES= fi