forked from boostorg/assert
Add support for testing using CMake
This commit is contained in:
@@ -1,4 +1,12 @@
|
|||||||
|
# Copyright 2018 Peter Dimov
|
||||||
|
#
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
#
|
||||||
|
# See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
# http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
project(BoostAssert LANGUAGES CXX)
|
project(BoostAssert LANGUAGES CXX)
|
||||||
|
|
||||||
add_library(boost_assert INTERFACE)
|
add_library(boost_assert INTERFACE)
|
||||||
@@ -10,3 +18,30 @@ target_link_libraries(boost_assert
|
|||||||
INTERFACE
|
INTERFACE
|
||||||
Boost::config
|
Boost::config
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
|
|
||||||
|
add_subdirectory(../config bin/config)
|
||||||
|
add_subdirectory(../core bin/core)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})
|
||||||
|
|
||||||
|
function(boost_test)
|
||||||
|
|
||||||
|
cmake_parse_arguments(PARSE "" "NAME" "SOURCES;LIBRARIES" ${ARGN})
|
||||||
|
|
||||||
|
add_executable(${PARSE_NAME} EXCLUDE_FROM_ALL ${PARSE_SOURCES})
|
||||||
|
target_link_libraries(${PARSE_NAME} ${PARSE_LIBRARIES})
|
||||||
|
|
||||||
|
add_test(NAME compile-${PARSE_NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${PARSE_NAME})
|
||||||
|
|
||||||
|
add_test(NAME run-${PARSE_NAME} COMMAND ${PARSE_NAME})
|
||||||
|
set_tests_properties(run-${PARSE_NAME} PROPERTIES DEPENDS compile-${PARSE_NAME})
|
||||||
|
|
||||||
|
endfunction(boost_test)
|
||||||
|
|
||||||
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
23
test/CMakeLists.txt
Normal file
23
test/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Copyright 2018 Peter Dimov
|
||||||
|
#
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
#
|
||||||
|
# See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
# http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
boost_test(NAME assert_test SOURCES assert_test.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
boost_test(NAME current_function_test SOURCES current_function_test.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
boost_test(NAME verify_test SOURCES verify_test.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
boost_test(NAME assert_is_void_test SOURCES assert_is_void_test.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
|
||||||
|
# expansion tests are in exp/ so that there is a backslash in the path on Windows
|
||||||
|
|
||||||
|
boost_test(NAME assert_exp_test SOURCES exp/assert_exp_test.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
boost_test(NAME assert_msg_exp_test SOURCES exp/assert_msg_exp_test.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
boost_test(NAME verify_exp_test SOURCES exp/verify_exp_test.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
boost_test(NAME verify_msg_exp_test SOURCES exp/verify_msg_exp_test.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
|
||||||
|
boost_test(NAME assert_test2 SOURCES assert_test2.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
boost_test(NAME assert_msg_test2 SOURCES assert_msg_test2.cpp LIBRARIES Boost::assert Boost::core)
|
||||||
|
|
||||||
|
boost_test(NAME quick SOURCES quick.cpp LIBRARIES Boost::assert Boost::core)
|
Reference in New Issue
Block a user