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
|
# 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
|
CMAKE_DEPENDENT_OPTION(TESTS_SINGLE "Enable build of tests using the generated single headers" ON
|
||||||
"SINGLE;TESTS" OFF)
|
"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)
|
"SINGLE;EXAMPLES" OFF)
|
||||||
if (TESTS AND EXAMPLES)
|
if (TESTS AND EXAMPLES)
|
||||||
option(TESTS_EXAMPLES "Enable build of examples as tests" ON)
|
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
|
# # # Libraries
|
||||||
# Here, we pull in all the necessary libraries for building examples and tests
|
# Here, we pull in all the necessary libraries for building examples and tests
|
||||||
# Find threading library
|
# Find threading library
|
||||||
|
if (NOT MSVC)
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
|
endif()
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
# Find way to get Lua: build if requested, or attempt to build if no matching version is found
|
# 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)
|
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
|
||||||
|
|
|
@ -45,8 +45,8 @@ platform:
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
# apparently, I can't quite make LLVM work right now...
|
# apparently, I can't quite make LLVM work right now...
|
||||||
- LUA_VERSION: 5.3.4
|
#- LUA_VERSION: 5.3.4
|
||||||
LLVM_VERSION: 4.0.0
|
# LLVM_VERSION: 4.0.0
|
||||||
- LUA_VERSION: 5.3.4
|
- LUA_VERSION: 5.3.4
|
||||||
MINGW_VERSION: 6.3.0
|
MINGW_VERSION: 6.3.0
|
||||||
- LUA_VERSION: 5.3.4
|
- LUA_VERSION: 5.3.4
|
||||||
|
@ -68,6 +68,8 @@ matrix:
|
||||||
- image: Visual Studio 2017
|
- image: Visual Studio 2017
|
||||||
MINGW_VERSION: 5.3.0
|
MINGW_VERSION: 5.3.0
|
||||||
# LLVM exists in all images, and we only want the x64 versions
|
# LLVM exists in all images, and we only want the x64 versions
|
||||||
|
- image: Visual Studio 2015
|
||||||
|
LLVM_VERSION: 4.0.0
|
||||||
- platform: x86
|
- platform: x86
|
||||||
LLVM_VERSION: 4.0.0
|
LLVM_VERSION: 4.0.0
|
||||||
# Get rid of x86 builds
|
# Get rid of x86 builds
|
||||||
|
|
|
@ -57,7 +57,8 @@ function (MAKE_EXAMPLE example_source_file is_single)
|
||||||
target_include_directories(${example_name}
|
target_include_directories(${example_name}
|
||||||
PRIVATE "${CMAKE_SOURCE_DIR}" "${LUA_INCLUDE_DIR}")
|
PRIVATE "${CMAKE_SOURCE_DIR}" "${LUA_INCLUDE_DIR}")
|
||||||
endif()
|
endif()
|
||||||
target_compile_features(${example_name} PUBLIC ${CXX_FEATURES})
|
target_compile_features(${example_name}
|
||||||
|
PRIVATE ${CXX_FEATURES})
|
||||||
target_link_libraries(${example_name} ${LUA_LIBRARIES})
|
target_link_libraries(${example_name} ${LUA_LIBRARIES})
|
||||||
if(CMAKE_DL_LIBS)
|
if(CMAKE_DL_LIBS)
|
||||||
target_link_libraries(${example_name} ${CMAKE_DL_LIBS})
|
target_link_libraries(${example_name} ${CMAKE_DL_LIBS})
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
#else
|
#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)
|
# define c_assert(condition) do { (void)sizeof(condition); } while (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ int main() {
|
||||||
// passed through std::ref
|
// passed through std::ref
|
||||||
// so, it holds a reference
|
// so, it holds a reference
|
||||||
// which can be updated
|
// 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);
|
c_assert(ref_number_again == 542);
|
||||||
// be careful about referencing local variables,
|
// be careful about referencing local variables,
|
||||||
// if they go out of scope but are still reference
|
// if they go out of scope but are still reference
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
file(GLOB SOL2_TEST_SOURCES test*.cpp)
|
file(GLOB SOL2_TEST_SOURCES test*.cpp)
|
||||||
source_group(test_sources FILES ${SOL2_TEST_SOURCES})
|
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/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}/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)
|
function(CREATE_TEST test_target_name test_name is_single)
|
||||||
if (is_single)
|
if (is_single)
|
||||||
|
@ -33,21 +33,25 @@ function(CREATE_TEST test_target_name test_name is_single)
|
||||||
else()
|
else()
|
||||||
set(header_files ${SOL2_HEADER_SOURCES})
|
set(header_files ${SOL2_HEADER_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(${test_target_name} ${SOL2_TEST_SOURCES} ${header_files})
|
add_executable(${test_target_name} ${SOL2_TEST_SOURCES} ${header_files})
|
||||||
|
set_target_properties(${test_target_name}
|
||||||
|
PROPERTIES
|
||||||
|
OUTPUT_NAME ${test_name})
|
||||||
if (is_single)
|
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}
|
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()
|
else()
|
||||||
target_include_directories(${test_target_name}
|
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()
|
endif()
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
target_compile_options(${test_target_name}
|
target_compile_options(${test_target_name}
|
||||||
PRIVATE /bigobj)
|
PRIVATE /bigobj)
|
||||||
else()
|
else()
|
||||||
target_compile_options(${test_target_name}
|
target_compile_options(${test_target_name}
|
||||||
PRIVATE -Wno-noexcept-type -ftemplate-depth=1024)
|
PRIVATE -Wno-noexcept-type -ftemplate-depth=1024 -pthread)
|
||||||
endif()
|
endif()
|
||||||
if (CI)
|
if (CI)
|
||||||
target_compile_definitions(${test_target_name}
|
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}
|
target_link_libraries(${test_target_name}
|
||||||
Threads::Threads ${LUA_LIBRARIES} ${CMAKE_DL_LIBS})
|
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)
|
install(TARGETS ${test_target_name} RUNTIME DESTINATION bin)
|
||||||
endfunction(CREATE_TEST)
|
endfunction(CREATE_TEST)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user