1cmake_minimum_required(VERSION 3.2 FATAL_ERROR) 2 3project(rxcpp_test LANGUAGES C CXX) 4 5# define some folders 6 7get_filename_component(RXCPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PATH) 8get_filename_component(RXCPP_DIR "${RXCPP_DIR}" PATH) 9get_filename_component(RXCPP_DIR "${RXCPP_DIR}" PATH) 10 11MESSAGE( STATUS "RXCPP_DIR: " ${RXCPP_DIR} ) 12 13include(${RXCPP_DIR}/projects/CMake/shared.cmake) 14 15# configure unit tests via CTest 16enable_testing() 17 18set(TEST_DIR ${RXCPP_DIR}/Rx/v2/test) 19 20# define the sources of the self test 21set(TEST_SOURCES 22 ${TEST_DIR}/subscriptions/coroutine.cpp 23 ${TEST_DIR}/subscriptions/observer.cpp 24 ${TEST_DIR}/subscriptions/subscription.cpp 25 ${TEST_DIR}/subjects/subject.cpp 26 ${TEST_DIR}/sources/create.cpp 27 ${TEST_DIR}/sources/defer.cpp 28 ${TEST_DIR}/sources/empty.cpp 29 ${TEST_DIR}/sources/interval.cpp 30 ${TEST_DIR}/sources/scope.cpp 31 ${TEST_DIR}/sources/timer.cpp 32 ${TEST_DIR}/operators/all.cpp 33 ${TEST_DIR}/operators/any.cpp 34 ${TEST_DIR}/operators/amb.cpp 35 ${TEST_DIR}/operators/amb_variadic.cpp 36 ${TEST_DIR}/operators/buffer.cpp 37 ${TEST_DIR}/operators/combine_latest.cpp 38 ${TEST_DIR}/operators/concat.cpp 39 ${TEST_DIR}/operators/concat_map.cpp 40 ${TEST_DIR}/operators/contains.cpp 41 ${TEST_DIR}/operators/debounce.cpp 42 ${TEST_DIR}/operators/default_if_empty.cpp 43 ${TEST_DIR}/operators/delay.cpp 44 ${TEST_DIR}/operators/distinct.cpp 45 ${TEST_DIR}/operators/distinct_until_changed.cpp 46 ${TEST_DIR}/operators/element_at.cpp 47 ${TEST_DIR}/operators/exists.cpp 48 ${TEST_DIR}/operators/filter.cpp 49 ${TEST_DIR}/operators/finally.cpp 50 ${TEST_DIR}/operators/flat_map.cpp 51 ${TEST_DIR}/operators/group_by.cpp 52 ${TEST_DIR}/operators/ignore_elements.cpp 53 ${TEST_DIR}/operators/is_empty.cpp 54 ${TEST_DIR}/operators/lift.cpp 55 ${TEST_DIR}/operators/map.cpp 56 ${TEST_DIR}/operators/merge.cpp 57 ${TEST_DIR}/operators/merge_delay_error.cpp 58 ${TEST_DIR}/operators/observe_on.cpp 59 ${TEST_DIR}/operators/on_error_resume_next.cpp 60 ${TEST_DIR}/operators/pairwise.cpp 61 ${TEST_DIR}/operators/publish.cpp 62 ${TEST_DIR}/operators/reduce.cpp 63 ${TEST_DIR}/operators/repeat.cpp 64 ${TEST_DIR}/operators/replay.cpp 65 ${TEST_DIR}/operators/retry.cpp 66 ${TEST_DIR}/operators/sample.cpp 67 ${TEST_DIR}/operators/scan.cpp 68 ${TEST_DIR}/operators/sequence_equal.cpp 69 ${TEST_DIR}/operators/skip.cpp 70 ${TEST_DIR}/operators/skip_while.cpp 71 ${TEST_DIR}/operators/skip_last.cpp 72 ${TEST_DIR}/operators/skip_until.cpp 73 ${TEST_DIR}/operators/start_with.cpp 74 ${TEST_DIR}/operators/subscribe_on.cpp 75 ${TEST_DIR}/operators/switch_if_empty.cpp 76 ${TEST_DIR}/operators/switch_on_next.cpp 77 ${TEST_DIR}/operators/take.cpp 78 ${TEST_DIR}/operators/take_last.cpp 79 ${TEST_DIR}/operators/take_until.cpp 80 ${TEST_DIR}/operators/take_while.cpp 81 ${TEST_DIR}/operators/tap.cpp 82 ${TEST_DIR}/operators/time_interval.cpp 83 ${TEST_DIR}/operators/timeout.cpp 84 ${TEST_DIR}/operators/timestamp.cpp 85 ${TEST_DIR}/operators/with_latest_from.cpp 86 ${TEST_DIR}/operators/window.cpp 87 ${TEST_DIR}/operators/window_toggle.cpp 88 ${TEST_DIR}/operators/zip.cpp 89) 90 91set(TEST_COMPILE_DEFINITIONS "") 92set(TEST_COMMAND_ARGUMENTS "") 93 94if (NOT RX_USE_EXCEPTIONS) 95 MESSAGE( STATUS "no exceptions" ) 96 list(APPEND TEST_COMPILE_DEFINITIONS CATCH_CONFIG_DISABLE_EXCEPTIONS) 97 list(APPEND TEST_COMMAND_ARGUMENTS -e) 98endif() 99 100 101add_executable(rxcppv2_test ${TEST_DIR}/test.cpp ${TEST_SOURCES}) 102add_executable(rxcpp::tests ALIAS rxcppv2_test) 103set_target_properties( 104 rxcppv2_test PROPERTIES 105 EXCLUDE_FROM_DEFAULT_BUILD TRUE 106 EXCLUDE_FROM_ALL TRUE 107) 108target_compile_options(rxcppv2_test PUBLIC ${RX_COMPILE_OPTIONS}) 109target_compile_features(rxcppv2_test PUBLIC ${RX_COMPILE_FEATURES}) 110target_compile_definitions(rxcppv2_test PUBLIC ${TEST_COMPILE_DEFINITIONS}) 111target_include_directories(rxcppv2_test 112 PUBLIC ${RX_SRC_DIR} ${RX_CATCH_DIR} 113 ) 114target_link_libraries(rxcppv2_test ${CMAKE_THREAD_LIBS_INIT}) 115 116 117foreach(ONE_TEST_SOURCE ${TEST_SOURCES}) 118 get_filename_component(ONE_TEST_NAME "${ONE_TEST_SOURCE}" NAME) 119 string( REPLACE ".cpp" "" ONE_TEST_NAME ${ONE_TEST_NAME}) 120 set(ONE_TEST_FULL_NAME "rxcpp_test_${ONE_TEST_NAME}") 121 add_executable( ${ONE_TEST_FULL_NAME} ${ONE_TEST_SOURCE} ) 122 add_executable( rxcpp::${ONE_TEST_NAME} ALIAS ${ONE_TEST_FULL_NAME}) 123 target_compile_definitions(${ONE_TEST_FULL_NAME} PUBLIC "CATCH_CONFIG_MAIN" ${TEST_COMPILE_DEFINITIONS}) 124 target_compile_options(${ONE_TEST_FULL_NAME} PUBLIC ${RX_COMPILE_OPTIONS}) 125 target_compile_features(${ONE_TEST_FULL_NAME} PUBLIC ${RX_COMPILE_FEATURES}) 126 target_include_directories(${ONE_TEST_FULL_NAME} 127 PUBLIC ${RX_SRC_DIR} ${RX_CATCH_DIR} 128 ) 129 target_link_libraries(${ONE_TEST_FULL_NAME} ${CMAKE_THREAD_LIBS_INIT}) 130 131 add_test(NAME ${ONE_TEST_NAME} COMMAND ${ONE_TEST_FULL_NAME} ${TEST_COMMAND_ARGUMENTS}) 132endforeach(ONE_TEST_SOURCE ${TEST_SOURCES}) 133 134 135 136