2017-12-20 17:58:32 +08:00
|
|
|
# # # # sol2
|
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
|
|
|
# Copyright (c) 2013-2017 Rapptz, ThePhD, and contributors
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
# # # # sol2 tests
|
|
|
|
|
2018-02-17 13:42:10 +08:00
|
|
|
find_package(Catch 2.0.1 REQUIRED)
|
2018-02-17 13:18:26 +08:00
|
|
|
|
2017-12-20 17:58:32 +08:00
|
|
|
file(GLOB SOL2_TEST_SOURCES test*.cpp)
|
|
|
|
source_group(test_sources FILES ${SOL2_TEST_SOURCES})
|
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
function(CREATE_TEST test_target_name test_name is_single)
|
2017-12-20 17:58:32 +08:00
|
|
|
if (is_single)
|
|
|
|
set(header_files ${SOL2_SINGLE_HEADER_SOURCES})
|
|
|
|
else()
|
|
|
|
set(header_files ${SOL2_HEADER_SOURCES})
|
|
|
|
endif()
|
2017-12-27 20:42:37 +08:00
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
add_executable(${test_target_name} ${SOL2_TEST_SOURCES} ${header_files})
|
2017-12-27 20:42:37 +08:00
|
|
|
set_target_properties(${test_target_name}
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME ${test_name})
|
2017-12-24 09:34:34 +08:00
|
|
|
if (is_single)
|
2018-01-10 21:40:37 +08:00
|
|
|
target_link_libraries(${test_target_name} sol2_single)
|
2018-01-29 11:21:13 +08:00
|
|
|
target_compile_definitions(${test_target_name}
|
|
|
|
PRIVATE TEST_SINGLE)
|
2017-12-24 09:34:34 +08:00
|
|
|
else()
|
2018-01-10 21:40:37 +08:00
|
|
|
target_link_libraries(${test_target_name} sol2)
|
2017-12-24 09:34:34 +08:00
|
|
|
endif()
|
2018-01-10 21:40:37 +08:00
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
if (MSVC)
|
2018-01-10 21:40:37 +08:00
|
|
|
if (NOT CMAKE_COMPILER_ID MATCHES "Clang")
|
|
|
|
target_compile_options(${test_target_name}
|
|
|
|
PRIVATE /bigobj)
|
|
|
|
endif()
|
2017-12-26 00:44:04 +08:00
|
|
|
else()
|
|
|
|
target_compile_options(${test_target_name}
|
2017-12-27 20:42:37 +08:00
|
|
|
PRIVATE -Wno-noexcept-type -ftemplate-depth=1024 -pthread)
|
2018-02-17 23:44:55 +08:00
|
|
|
|
|
|
|
if (IS_X86)
|
|
|
|
target_compile_options(${test_target_name} BEFORE PRIVATE -m32)
|
|
|
|
if(MINGW)
|
|
|
|
#set_target_properties(${test_target_name}
|
|
|
|
# PROPERTIES
|
|
|
|
# LINK_FLAGS -static-libstdc++)
|
|
|
|
endif()
|
|
|
|
endif()
|
2017-12-26 00:44:04 +08:00
|
|
|
endif()
|
|
|
|
if (CI)
|
|
|
|
target_compile_definitions(${test_target_name}
|
|
|
|
PRIVATE SOL2_CI)
|
2017-12-24 09:34:34 +08:00
|
|
|
endif()
|
2017-12-20 17:58:32 +08:00
|
|
|
target_compile_features(${test_target_name}
|
|
|
|
PRIVATE ${CXX_FEATURES})
|
2018-02-17 13:18:26 +08:00
|
|
|
if (CMAKE_DL_LIBS)
|
|
|
|
target_link_libraries(${test_target_name}
|
|
|
|
${CMAKE_DL_LIBS})
|
|
|
|
endif()
|
2017-12-20 17:58:32 +08:00
|
|
|
target_link_libraries(${test_target_name}
|
2018-02-17 13:18:26 +08:00
|
|
|
Threads::Threads ${LUA_LIBRARIES} ${CATCH_LIBRARIES})
|
|
|
|
|
2017-12-27 20:42:37 +08:00
|
|
|
add_test(NAME ${test_name} COMMAND ${test_target_name})
|
2017-12-25 01:32:23 +08:00
|
|
|
install(TARGETS ${test_target_name} RUNTIME DESTINATION bin)
|
2017-12-20 17:58:32 +08:00
|
|
|
endfunction(CREATE_TEST)
|
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
CREATE_TEST(tests "tests" FALSE)
|
2017-12-24 10:29:29 +08:00
|
|
|
if (TESTS_SINGLE AND SOL2_SINGLE_FOUND)
|
2017-12-24 09:34:34 +08:00
|
|
|
CREATE_TEST(tests_single "tests.single" TRUE)
|
2017-12-20 17:58:32 +08:00
|
|
|
endif()
|