1.1 --- a/test/CMakeLists.txt Sat Apr 09 18:02:53 2022 +0200 1.2 +++ b/test/CMakeLists.txt Fri Apr 15 21:28:51 2022 +0200 1.3 @@ -1,3 +1,4 @@ 1.4 +# Transitional support for CTest written tests 1.5 message(CHECK_START "Searching for CUnit test framework") 1.6 1.7 find_path(CUNIT_INCLUDE_DIR NAMES CUnit/CUnit.h) 1.8 @@ -5,7 +6,7 @@ 1.9 include(FindPackageHandleStandardArgs) 1.10 find_package_handle_standard_args(CUnit DEFAULT_MSG CUNIT_LIBRARY CUNIT_INCLUDE_DIR) 1.11 1.12 -if(CUNIT_FOUND) 1.13 +if (CUNIT_FOUND) 1.14 message(CHECK_PASS "found: compiling tests.") 1.15 set(TESTS 1.16 test_allocator 1.17 @@ -13,12 +14,36 @@ 1.18 test_tree 1.19 ) 1.20 1.21 - foreach(test ${TESTS}) 1.22 - add_executable(${test} util_allocator.c ${test}.c) 1.23 + foreach (test ${TESTS}) 1.24 + add_executable(${test} ${test}.c) 1.25 target_link_libraries(${test} PRIVATE ucx_static ${CUNIT_LIBRARY}) 1.26 target_include_directories(${test} PRIVATE ${CUNIT_INCLUDE_DIR}) 1.27 add_test(NAME ${test} COMMAND ${test} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 1.28 - endforeach() 1.29 -else() 1.30 - message(CHECK_FAIL "not found: unit tests will not be available.") 1.31 -endif() 1.32 + endforeach () 1.33 +else () 1.34 + message(CHECK_FAIL "not found: CUnit tests will not be available.") 1.35 +endif () 1.36 + 1.37 +# Load Google Test Framework 1.38 +set(CMAKE_CXX_STANDARD 11) 1.39 + 1.40 +include(FetchContent) 1.41 +FetchContent_Declare( 1.42 + googletest 1.43 + GIT_REPOSITORY https://github.com/google/googletest.git 1.44 + GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release 1.11.0 1.45 +) 1.46 +# For Windows: Prevent overriding the parent project's compiler/linker settings 1.47 +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 1.48 +FetchContent_MakeAvailable(googletest) 1.49 +include(GoogleTest) 1.50 +message(STATUS "Google Test made available") 1.51 + 1.52 +set(TESTS 1.53 + selftest 1.54 + ) 1.55 +foreach (test ${TESTS}) 1.56 + add_executable(${test} ${test}.cpp) 1.57 + target_link_libraries(${test} PRIVATE ucx_static gtest_main) 1.58 +endforeach () 1.59 +gtest_discover_tests(${TESTS})