test/CMakeLists.txt

Sat, 16 Apr 2022 17:28:36 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 16 Apr 2022 17:28:36 +0200
changeset 516
7bcea73303ce
parent 515
6d3909bf1609
child 517
b3baaf9b7e3c
permissions
-rw-r--r--

fix required cast if compiled with C++

# Transitional support for CTest written tests
message(CHECK_START "Searching for CUnit test framework")

find_path(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h)
find_library(CUNIT_LIBRARY NAMES cunit libcunit cunitlib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR)

if (CUNIT_FOUND)
    message(CHECK_PASS "found: compiling tests.")
    set(TESTS
            test_list
    )

    foreach (test ${TESTS})
        add_executable(${test} ${test}.c)
        target_link_libraries(${test} PRIVATE ucx_static ${CUNIT_LIBRARY})
        target_include_directories(${test} PRIVATE ${CUNIT_INCLUDE_DIR})
        add_test(NAME ${test} COMMAND ${test} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
    endforeach ()
else ()
    message(CHECK_FAIL "not found: CUnit tests will not be available.")
endif ()

# Load Google Test Framework
set(CMAKE_CXX_STANDARD 11)

include(FetchContent)
FetchContent_Declare(
        googletest
        GIT_REPOSITORY https://github.com/google/googletest.git
        GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release 1.11.0
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
message(STATUS "Google Test made available")

add_executable(ucxtest
        test_allocator.cpp
        test_tree.cpp
        selftest.cpp
        )
target_link_libraries(ucxtest PRIVATE ucx_static gtest_main)
gtest_discover_tests(ucxtest)

mercurial