1 # Copyright (c) The Bitcoin Core developers
2 # Distributed under the MIT software license, see the accompanying
3 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 5 # Custom test targets for convenience, based on
6 # https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/EmulateMakeCheck.
7 #
8 # CTest already provides a "make test" target, but it just runs existing tests
9 # that were previously built, without building anything itself. Define "make
10 # tests" here as a custom target to build all available tests and "make check"
11 # as a custom target to build and run them.
12 add_custom_target(mptests)
13 add_custom_target(mpcheck COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS mptests)
14 15 # Only add more convenient tests and check targets if project is being built
16 # standalone, to prevent clashes with external projects.
17 if (MP_STANDALONE)
18 add_custom_target(tests DEPENDS mptests)
19 add_custom_target(check DEPENDS mpcheck)
20 endif()
21 22 if(BUILD_TESTING AND TARGET CapnProto::kj-test)
23 set_property(SOURCE ${MP_PROXY_HDRS} PROPERTY GENERATED 1)
24 25 add_executable(mptest
26 ${MP_PROXY_HDRS}
27 mp/test/foo-types.h
28 mp/test/foo.h
29 mp/test/listen_tests.cpp
30 mp/test/spawn_tests.cpp
31 mp/test/test.cpp
32 )
33 include(${PROJECT_SOURCE_DIR}/cmake/TargetCapnpSources.cmake)
34 target_capnp_sources(mptest ${CMAKE_CURRENT_SOURCE_DIR} mp/test/foo.capnp)
35 target_include_directories(mptest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
36 target_link_libraries(mptest PRIVATE CapnProto::kj-test)
37 target_link_libraries(mptest PRIVATE Threads::Threads)
38 39 add_dependencies(mptests mptest)
40 add_test(NAME mptest COMMAND mptest)
41 endif()
42