mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
big sigh; one day we'll get this all right...
This commit is contained in:
parent
37cdc50a5c
commit
0051548dfa
|
@ -96,7 +96,7 @@ option(SINGLE "Enable build of single header files" ON)
|
|||
# Single tests will only be turned on if both SINGLE and TESTS are defined
|
||||
CMAKE_DEPENDENT_OPTION(TESTS_SINGLE "Enable build of tests using the generated single headers" ON
|
||||
"SINGLE;TESTS" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(EXAMPLES_SINGLE "Enable build of tests using the generated single headers" OFF
|
||||
CMAKE_DEPENDENT_OPTION(EXAMPLES_SINGLE "Enable build of examples using the generated single headers" OFF
|
||||
"SINGLE;EXAMPLES" OFF)
|
||||
if (TESTS AND EXAMPLES)
|
||||
option(TESTS_EXAMPLES "Enable build of examples as tests" ON)
|
||||
|
@ -194,6 +194,9 @@ if (TESTS OR TESTS_SINGLE OR EXAMPLES OR TESTS_EXAMPLES)
|
|||
# # # Libraries
|
||||
# Here, we pull in all the necessary libraries for building examples and tests
|
||||
# Find threading library
|
||||
if (NOT MSVC)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
endif()
|
||||
find_package(Threads)
|
||||
# Find way to get Lua: build if requested, or attempt to build if no matching version is found
|
||||
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
|
||||
|
|
|
@ -45,8 +45,8 @@ platform:
|
|||
environment:
|
||||
matrix:
|
||||
# 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
|
||||
# LLVM_VERSION: 4.0.0
|
||||
- LUA_VERSION: 5.3.4
|
||||
MINGW_VERSION: 6.3.0
|
||||
- LUA_VERSION: 5.3.4
|
||||
|
@ -68,6 +68,8 @@ matrix:
|
|||
- image: Visual Studio 2017
|
||||
MINGW_VERSION: 5.3.0
|
||||
# LLVM exists in all images, and we only want the x64 versions
|
||||
- image: Visual Studio 2015
|
||||
LLVM_VERSION: 4.0.0
|
||||
- platform: x86
|
||||
LLVM_VERSION: 4.0.0
|
||||
# Get rid of x86 builds
|
||||
|
|
|
@ -57,7 +57,8 @@ function (MAKE_EXAMPLE example_source_file is_single)
|
|||
target_include_directories(${example_name}
|
||||
PRIVATE "${CMAKE_SOURCE_DIR}" "${LUA_INCLUDE_DIR}")
|
||||
endif()
|
||||
target_compile_features(${example_name} PUBLIC ${CXX_FEATURES})
|
||||
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})
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
} \
|
||||
} while (false)
|
||||
#else
|
||||
# define m_assert(condition, message) do { (void)sizeof(condition); (void)sizeof(message); } while (false)
|
||||
# define m_assert(condition, message) do { if (false) { (void)(condition); (void)sizeof(message); } } while (false)
|
||||
# define c_assert(condition) do { (void)sizeof(condition); } while (false)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ int main() {
|
|||
// passed through std::ref
|
||||
// so, it holds a reference
|
||||
// which can be updated
|
||||
int ref_number_again = lua["test"]["number"];
|
||||
int ref_number_again = lua["test"]["ref_number"];
|
||||
c_assert(ref_number_again == 542);
|
||||
// be careful about referencing local variables,
|
||||
// if they go out of scope but are still reference
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
file(GLOB SOL2_TEST_SOURCES test*.cpp)
|
||||
source_group(test_sources FILES ${SOL2_TEST_SOURCES})
|
||||
#file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v2.0.1/catch.hpp ${CMAKE_BINARY_DIR}/Catch/include/catch.hpp)
|
||||
file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v1.11.0/catch.hpp ${CMAKE_BINARY_DIR}/Catch/include/catch.hpp)
|
||||
file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v2.0.1/catch.hpp ${CMAKE_BINARY_DIR}/vendor/Catch/include/catch.hpp)
|
||||
#file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v1.11.0/catch.hpp ${CMAKE_BINARY_DIR}/vendor/Catch/include/catch.hpp)
|
||||
|
||||
function(CREATE_TEST test_target_name test_name is_single)
|
||||
if (is_single)
|
||||
|
@ -33,21 +33,25 @@ function(CREATE_TEST test_target_name test_name is_single)
|
|||
else()
|
||||
set(header_files ${SOL2_HEADER_SOURCES})
|
||||
endif()
|
||||
|
||||
add_executable(${test_target_name} ${SOL2_TEST_SOURCES} ${header_files})
|
||||
set_target_properties(${test_target_name}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME ${test_name})
|
||||
if (is_single)
|
||||
add_dependencies(${test_target_name} sol2_single_header ${LUA_LIBRARIES})
|
||||
add_dependencies(${test_target_name} sol2_single_header)
|
||||
target_include_directories(${test_target_name}
|
||||
PRIVATE "${CMAKE_BINARY_DIR}/include/single/sol" "${LUA_INCLUDE_DIR}" "${CMAKE_BINARY_DIR}/Catch/include/")
|
||||
PRIVATE "${CMAKE_BINARY_DIR}/include/single/sol" "${LUA_INCLUDE_DIR}" "${CMAKE_BINARY_DIR}/vendor/Catch/include/")
|
||||
else()
|
||||
target_include_directories(${test_target_name}
|
||||
PRIVATE "${CMAKE_SOURCE_DIR}" "${LUA_INCLUDE_DIR}" "${CMAKE_BINARY_DIR}/Catch/include/")
|
||||
PRIVATE "${CMAKE_SOURCE_DIR}" "${LUA_INCLUDE_DIR}" "${CMAKE_BINARY_DIR}/vendor/Catch/include/")
|
||||
endif()
|
||||
if (MSVC)
|
||||
target_compile_options(${test_target_name}
|
||||
PRIVATE /bigobj)
|
||||
else()
|
||||
target_compile_options(${test_target_name}
|
||||
PRIVATE -Wno-noexcept-type -ftemplate-depth=1024)
|
||||
PRIVATE -Wno-noexcept-type -ftemplate-depth=1024 -pthread)
|
||||
endif()
|
||||
if (CI)
|
||||
target_compile_definitions(${test_target_name}
|
||||
|
@ -59,7 +63,7 @@ function(CREATE_TEST test_target_name test_name is_single)
|
|||
target_link_libraries(${test_target_name}
|
||||
Threads::Threads ${LUA_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
|
||||
add_test(NAME ${test_target_name} COMMAND ${test_target_name})
|
||||
add_test(NAME ${test_name} COMMAND ${test_target_name})
|
||||
install(TARGETS ${test_target_name} RUNTIME DESTINATION bin)
|
||||
endfunction(CREATE_TEST)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user