test/CMakeLists.txt

Sat, 16 Apr 2022 08:58:27 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 16 Apr 2022 08:58:27 +0200
changeset 512
096d206b63f9
parent 511
a32e6a6b1ca7
child 515
6d3909bf1609
permissions
-rw-r--r--

compile only one single binary for tests

universe@510 1 # Transitional support for CTest written tests
universe@391 2 message(CHECK_START "Searching for CUnit test framework")
universe@390 3
universe@391 4 find_path(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h)
universe@391 5 find_library(CUNIT_LIBRARY NAMES cunit libcunit cunitlib)
universe@391 6 include(FindPackageHandleStandardArgs)
universe@391 7 find_package_handle_standard_args(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR)
universe@391 8
universe@510 9 if (CUNIT_FOUND)
universe@391 10 message(CHECK_PASS "found: compiling tests.")
universe@391 11 set(TESTS
universe@413 12 test_list
olaf@425 13 test_tree
universe@391 14 )
universe@391 15
universe@510 16 foreach (test ${TESTS})
universe@510 17 add_executable(${test} ${test}.c)
universe@391 18 target_link_libraries(${test} PRIVATE ucx_static ${CUNIT_LIBRARY})
universe@395 19 target_include_directories(${test} PRIVATE ${CUNIT_INCLUDE_DIR})
universe@391 20 add_test(NAME ${test} COMMAND ${test} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
universe@510 21 endforeach ()
universe@510 22 else ()
universe@510 23 message(CHECK_FAIL "not found: CUnit tests will not be available.")
universe@510 24 endif ()
universe@510 25
universe@510 26 # Load Google Test Framework
universe@510 27 set(CMAKE_CXX_STANDARD 11)
universe@510 28
universe@510 29 include(FetchContent)
universe@510 30 FetchContent_Declare(
universe@510 31 googletest
universe@510 32 GIT_REPOSITORY https://github.com/google/googletest.git
universe@510 33 GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release 1.11.0
universe@510 34 )
universe@510 35 # For Windows: Prevent overriding the parent project's compiler/linker settings
universe@510 36 set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
universe@510 37 FetchContent_MakeAvailable(googletest)
universe@510 38 include(GoogleTest)
universe@510 39 message(STATUS "Google Test made available")
universe@510 40
universe@512 41 add_executable(ucxtest
universe@512 42 test_allocator.cpp
universe@512 43 selftest.cpp
universe@510 44 )
universe@512 45 target_link_libraries(ucxtest PRIVATE ucx_static gtest_main)
universe@512 46 gtest_discover_tests(ucxtest)

mercurial