CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. cmake_minimum_required(VERSION 3.23)
  2. if (BUILD_SHARED_LIBS)
  3. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../bin)
  4. endif ()
  5. find_package(Catch2 REQUIRED)
  6. add_library(rotor_test_lib STATIC
  7. access.cpp
  8. actor_test.cpp
  9. supervisor_test.cpp
  10. )
  11. target_link_libraries(rotor_test_lib rotor::core Catch2::Catch2WithMain)
  12. add_library(rotor::test ALIAS rotor_test_lib)
  13. set(rotor_TEST_LIBS rotor::core rotor::test)
  14. file(GLOB COMMON_TESTS_SOURCES "0*.cpp")
  15. include(CTest)
  16. include(Catch)
  17. foreach(SOURCES ${COMMON_TESTS_SOURCES})
  18. get_filename_component(EXEC_NAME ${SOURCES} NAME_WE)
  19. add_executable(${EXEC_NAME})
  20. target_sources(${EXEC_NAME} PRIVATE ${SOURCES})
  21. target_link_libraries(${EXEC_NAME} ${rotor_TEST_LIBS})
  22. catch_discover_tests(${EXEC_NAME} TEST_PREFIX "${EXEC_NAME} \\")
  23. endforeach(SOURCES)
  24. if (BUILD_BOOST_ASIO)
  25. set(rotor_BOOTS_TEST_LIBS rotor::test rotor::asio)
  26. if (WIN32)
  27. add_compile_definitions(
  28. _SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
  29. _WIN32_WINNT=0x600
  30. )
  31. endif()
  32. add_executable(101-asio_ping-pong-1-strand 101-asio_ping-pong-1-strand.cpp)
  33. target_link_libraries(101-asio_ping-pong-1-strand ${rotor_BOOTS_TEST_LIBS})
  34. catch_discover_tests(101-asio_ping-pong-1-strand TEST_PREFIX "101-asio_ping-pong-1-strand \\")
  35. add_executable(102-asio_ping-pong-2-strands 102-asio_ping-pong-2-strands.cpp)
  36. target_link_libraries(102-asio_ping-pong-2-strands ${rotor_BOOTS_TEST_LIBS})
  37. catch_discover_tests(102-asio_ping-pong-2-strands TEST_PREFIX "102-asio_ping-pong-2-strands \\")
  38. if (NOT BUILD_THREAD_UNSAFE)
  39. add_executable(103-asio_ping-pong-2-threads 103-asio_ping-pong-2-threads.cpp)
  40. target_link_libraries(103-asio_ping-pong-2-threads ${rotor_BOOTS_TEST_LIBS})
  41. catch_discover_tests(103-asio_ping-pong-2-threads TEST_PREFIX "103-asio_ping-pong-2-threads \\")
  42. endif()
  43. add_executable(104-asio_timer 104-asio_timer.cpp)
  44. target_link_libraries(104-asio_timer ${rotor_BOOTS_TEST_LIBS})
  45. catch_discover_tests(104-asio_timer TEST_PREFIX "104-asio_timer \\")
  46. endif()
  47. if (BUILD_WX)
  48. add_executable(121-wx_ping_ping 121-wx_ping_ping.cpp)
  49. target_link_libraries(121-wx_ping_ping rotor::test rotor::wx)
  50. catch_discover_tests(121-wx_ping_ping)
  51. add_executable(122-wx_timer 122-wx_timer.cpp)
  52. target_link_libraries(122-wx_timer rotor::test rotor::wx)
  53. catch_discover_tests(122-wx_timer)
  54. endif()
  55. if (BUILD_EV)
  56. add_executable(131-ev_ping-pong 131-ev_ping-pong.cpp)
  57. target_link_libraries(131-ev_ping-pong rotor::test rotor::ev)
  58. catch_discover_tests(131-ev_ping-pong TEST_PREFIX "131-ev_ping-pong \\")
  59. add_executable(132-ev_timer 132-ev_timer.cpp)
  60. target_link_libraries(132-ev_timer rotor::test rotor::ev)
  61. catch_discover_tests(132-ev_timer TEST_PREFIX "132-ev_timer \\")
  62. endif()
  63. if (BUILD_THREAD)
  64. add_executable(141-thread_ping-pong 141-thread_ping-pong.cpp)
  65. target_link_libraries(141-thread_ping-pong rotor::test rotor::thread)
  66. catch_discover_tests(141-thread_ping-pong TEST_PREFIX "141-thread_ping-pong \\")
  67. add_executable(142-thread_timer 142-thread_timer.cpp)
  68. target_link_libraries(142-thread_timer rotor::test rotor::thread)
  69. catch_discover_tests(142-thread_timer TEST_PREFIX "142-thread_timer \\")
  70. add_executable(143-thread-shutdown_flag 143-thread-shutdown_flag.cpp)
  71. target_link_libraries(143-thread-shutdown_flag rotor::test rotor::thread)
  72. catch_discover_tests(143-thread-shutdown_flag TEST_PREFIX "143-thread-shutdown_flag \\")
  73. endif()
  74. if (BUILD_FLTK)
  75. add_executable(151-fltk-ping-pong 151-fltk-ping-pong.cpp)
  76. target_link_libraries(151-fltk-ping-pong rotor::test rotor::fltk $<$<PLATFORM_ID:Linux>:jpeg png>)
  77. catch_discover_tests(151-fltk-ping-pong TEST_PREFIX "151-fltk-ping-pong \\")
  78. endif()