2021-03-06 23:14:48 +08:00
|
|
|
# # # # sol2
|
2018-12-20 12:17:15 +08:00
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
2021-03-06 14:03:23 +08:00
|
|
|
# Copyright (c) 2013-2021 Rapptz, ThePhD, and contributors
|
2018-12-20 12:17:15 +08:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2021-03-06 23:14:48 +08:00
|
|
|
# # # # sol2 tests - runtime tests
|
2018-12-20 12:17:15 +08:00
|
|
|
|
2021-03-08 03:24:52 +08:00
|
|
|
file(GLOB SOL2_RUNTIME_TEST_SOURCES
|
|
|
|
LIST_DIRECTORIES FALSE
|
|
|
|
CONFIGURE_DEPENDS
|
|
|
|
source/*.cpp)
|
2018-12-20 12:17:15 +08:00
|
|
|
source_group(test_sources FILES ${SOL2_RUNTIME_TEST_SOURCES})
|
|
|
|
|
|
|
|
function(CREATE_TEST test_target_name test_name target_sol)
|
2021-03-06 14:03:23 +08:00
|
|
|
set(test_target_name ${test_target_name})
|
2018-12-20 12:17:15 +08:00
|
|
|
add_executable(${test_target_name} ${SOL2_RUNTIME_TEST_SOURCES})
|
|
|
|
set_target_properties(${test_target_name}
|
|
|
|
PROPERTIES
|
2021-03-06 14:03:23 +08:00
|
|
|
OUTPUT_NAME ${test_name})
|
2018-12-27 15:17:25 +08:00
|
|
|
target_link_libraries(${test_target_name}
|
2021-03-06 14:03:23 +08:00
|
|
|
PUBLIC Threads::Threads ${LUA_LIBRARIES} Catch2::Catch2 ${target_sol} ${CMAKE_DL_LIBS})
|
2020-11-20 04:12:56 +08:00
|
|
|
target_compile_definitions(${test_target_name}
|
|
|
|
PUBLIC SOL_ALL_SAFETIES_ON=1 SOL_PRINT_ERRORS=1 SOL_ENABLE_INTEROP=1)
|
2018-12-20 12:17:15 +08:00
|
|
|
if (MSVC)
|
|
|
|
if (NOT CMAKE_COMPILER_ID MATCHES "Clang")
|
|
|
|
target_compile_options(${test_target_name}
|
2020-11-20 04:12:56 +08:00
|
|
|
PRIVATE /bigobj /W4 /w44800)
|
|
|
|
else()
|
|
|
|
target_compile_options(${test_target_name}
|
|
|
|
PRIVATE -ftemplate-backtrace-limit=0)
|
2018-12-20 12:17:15 +08:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
target_compile_options(${test_target_name}
|
2019-03-23 04:28:17 +08:00
|
|
|
PRIVATE -std=c++1z -pthread
|
|
|
|
-Wno-unknown-warning -Wno-unknown-warning-option
|
|
|
|
-Wall -Wpedantic -Werror -pedantic -pedantic-errors
|
2020-12-19 13:47:55 +08:00
|
|
|
-Wno-noexcept-type)
|
2019-03-23 04:28:17 +08:00
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2020-11-20 04:12:56 +08:00
|
|
|
target_compile_options(${test_target_name}
|
|
|
|
PRIVATE -Wno-microsoft-cast)
|
2019-03-23 04:28:17 +08:00
|
|
|
endif()
|
2018-12-20 12:17:15 +08:00
|
|
|
|
|
|
|
if (IS_X86)
|
|
|
|
if(MINGW)
|
|
|
|
set_target_properties(${test_target_name}
|
|
|
|
PROPERTIES
|
|
|
|
LINK_FLAGS -static-libstdc++)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2018-12-24 02:18:14 +08:00
|
|
|
if (MSVC)
|
|
|
|
target_compile_options(${test_target_name}
|
2019-11-30 02:08:41 +08:00
|
|
|
PRIVATE /EHsc /std:c++latest)
|
2018-12-24 02:18:14 +08:00
|
|
|
target_compile_definitions(${test_target_name}
|
2018-12-27 15:17:25 +08:00
|
|
|
PRIVATE UNICODE _UNICODE
|
|
|
|
_CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE)
|
2018-12-24 02:18:14 +08:00
|
|
|
else()
|
|
|
|
target_compile_options(${test_target_name}
|
|
|
|
PRIVATE -std=c++1z -Wno-unknown-warning -Wno-unknown-warning-option
|
|
|
|
-Wall -Wextra -Wpedantic -pedantic -pedantic-errors)
|
|
|
|
endif()
|
|
|
|
|
2018-12-20 12:17:15 +08:00
|
|
|
if (SOL2_CI)
|
|
|
|
target_compile_definitions(${test_target_name}
|
|
|
|
PRIVATE SOL2_CI)
|
|
|
|
endif()
|
2018-12-24 02:18:14 +08:00
|
|
|
|
2018-12-20 12:17:15 +08:00
|
|
|
add_test(NAME ${test_name} COMMAND ${test_target_name})
|
2020-11-02 00:10:36 +08:00
|
|
|
if(SOL2_ENABLE_INSTALL)
|
|
|
|
install(TARGETS ${test_target_name} RUNTIME DESTINATION bin)
|
|
|
|
endif()
|
2018-12-20 12:17:15 +08:00
|
|
|
endfunction(CREATE_TEST)
|
|
|
|
|
2018-12-20 14:18:07 +08:00
|
|
|
if (SOL2_TESTS)
|
2021-03-06 14:03:23 +08:00
|
|
|
CREATE_TEST(runtime_tests "sol2.runtime_tests" sol2::sol2)
|
2018-12-20 14:18:07 +08:00
|
|
|
endif()
|
|
|
|
if (SOL2_TESTS_SINGLE)
|
2021-03-06 14:03:23 +08:00
|
|
|
CREATE_TEST(runtime_tests_single "sol2.single.runtime_tests" sol2::sol2::single)
|
2018-12-20 12:17:15 +08:00
|
|
|
endif()
|