CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufInternalHelpers.cmake)
  2. qt_protobuf_internal_find_dependencies()
  3. find_package(Qt5 COMPONENTS Quick QuickTest REQUIRED)
  4. set(CMAKE_AUTOMOC OFF)
  5. file(GLOB QML_FILES qml/tst_grpc.qml)
  6. qt5_wrap_cpp(MOC_SOURCES test.h)
  7. add_executable(qtgrpc_qml_test_http2 ${MOC_SOURCES} http2.cpp ${QML_FILES})
  8. if(QT_PROTOBUF_NATIVE_GRPC_CHANNEL)
  9. add_executable(qtgrpc_qml_test_grpc_http ${MOC_SOURCES} grpc_http.cpp ${QML_FILES})
  10. add_executable(qtgrpc_qml_test_grpc_socket ${MOC_SOURCES} grpc_socket.cpp ${QML_FILES})
  11. endif()
  12. target_link_libraries(qtgrpc_qml_test_http2 PRIVATE Qt5::Qml Qt5::Quick Qt5::Test Qt5::QuickTest QtProtobufProject::QtGrpc)
  13. if(QT_PROTOBUF_NATIVE_GRPC_CHANNEL)
  14. target_link_libraries(qtgrpc_qml_test_grpc_http PRIVATE Qt5::Qml Qt5::Quick Qt5::Test Qt5::QuickTest QtProtobufProject::QtGrpc)
  15. target_link_libraries(qtgrpc_qml_test_grpc_socket PRIVATE Qt5::Qml Qt5::Quick Qt5::Test Qt5::QuickTest QtProtobufProject::QtGrpc)
  16. endif()
  17. if(QT_PROTOBUF_STATIC)
  18. target_link_libraries(qtgrpc_qml_test_http2 PRIVATE ${PROTOBUF_QUICK_PLUGIN_NAME} ${GRPC_QUICK_PLUGIN_NAME})
  19. if (QT_PROTOBUF_NATIVE_GRPC_CHANNEL)
  20. target_link_libraries(qtgrpc_qml_test_grpc_http PRIVATE ${PROTOBUF_QUICK_PLUGIN_NAME} ${GRPC_QUICK_PLUGIN_NAME})
  21. target_link_libraries(qtgrpc_qml_test_grpc_socket PRIVATE ${PROTOBUF_QUICK_PLUGIN_NAME} ${GRPC_QUICK_PLUGIN_NAME})
  22. endif()
  23. endif()
  24. qtprotobuf_link_target(qtgrpc_qml_test_http2 qtgrpc_test_qtprotobuf_gen)
  25. if(QT_PROTOBUF_NATIVE_GRPC_CHANNEL)
  26. qtprotobuf_link_target(qtgrpc_qml_test_grpc_http qtgrpc_test_qtprotobuf_gen)
  27. qtprotobuf_link_target(qtgrpc_qml_test_grpc_socket qtgrpc_test_qtprotobuf_gen)
  28. endif()
  29. if(UNIX)
  30. set(TEST_DRIVER_NAME "test_driver.sh")
  31. elseif(WIN32)
  32. set(TEST_DRIVER_NAME "test_driver.bat")
  33. endif()
  34. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../test_grpc/${TEST_DRIVER_NAME}.in ${TEST_DRIVER_NAME} @ONLY)
  35. add_test(NAME qtgrpc_qml_test_http2
  36. COMMAND ${TEST_DRIVER_NAME} $<TARGET_FILE:qtgrpc_qml_test_http2> $<TARGET_FILE:echoserver> $<TARGET_FILE_NAME:qtgrpc_qml_test_http2> $<TARGET_FILE_NAME:echoserver>
  37. )
  38. if(QT_PROTOBUF_NATIVE_GRPC_CHANNEL)
  39. add_test(NAME qtgrpc_qml_test_grpc_http
  40. COMMAND ${TEST_DRIVER_NAME} $<TARGET_FILE:qtgrpc_qml_test_grpc_http> $<TARGET_FILE:echoserver> $<TARGET_FILE_NAME:qtgrpc_qml_test_grpc_http> $<TARGET_FILE_NAME:echoserver>
  41. )
  42. add_test(NAME qtgrpc_qml_test_grpc_socket
  43. COMMAND ${TEST_DRIVER_NAME} $<TARGET_FILE:qtgrpc_qml_test_grpc_socket> $<TARGET_FILE:echoserver> $<TARGET_FILE_NAME:qtgrpc_qml_test_grpc_socket> $<TARGET_FILE_NAME:echoserver>
  44. )
  45. endif()
  46. add_target_qml(TARGET qtgrpc_qml_test_http2 QML_FILES ${QML_FILES})
  47. add_target_windeployqt(TARGET qtgrpc_qml_test_http2 QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qml)
  48. if(QT_PROTOBUF_NATIVE_GRPC_CHANNEL)
  49. add_target_qml(TARGET qtgrpc_qml_test_grpc_http QML_FILES ${QML_FILES})
  50. add_target_windeployqt(TARGET qtgrpc_qml_test_grpc_http QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qml)
  51. add_target_qml(TARGET qtgrpc_qml_test_grpc_socket QML_FILES ${QML_FILES})
  52. add_target_windeployqt(TARGET qtgrpc_qml_test_grpc_socket QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qml)
  53. endif()
  54. if(WIN32)
  55. set_tests_properties(qtgrpc_qml_test_http2 PROPERTIES
  56. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..\;$<TARGET_FILE_DIR:${GRPC_QUICK_PLUGIN_NAME}>/..)
  57. if(QT_PROTOBUF_NATIVE_GRPC_CHANNEL)
  58. set_tests_properties(qtgrpc_qml_test_grpc_http PROPERTIES
  59. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..\;$<TARGET_FILE_DIR:${GRPC_QUICK_PLUGIN_NAME}>/..)
  60. set_tests_properties(qtgrpc_qml_test_grpc_socket PROPERTIES
  61. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..\;$<TARGET_FILE_DIR:${GRPC_QUICK_PLUGIN_NAME}>/..)
  62. endif()
  63. else()
  64. set_tests_properties(qtgrpc_qml_test_http2 PROPERTIES
  65. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..:$<TARGET_FILE_DIR:${GRPC_QUICK_PLUGIN_NAME}>/..)
  66. if(QT_PROTOBUF_NATIVE_GRPC_CHANNEL)
  67. set_tests_properties(qtgrpc_qml_test_grpc_http PROPERTIES
  68. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..:$<TARGET_FILE_DIR:${GRPC_QUICK_PLUGIN_NAME}>/..)
  69. set_tests_properties(qtgrpc_qml_test_grpc_socket PROPERTIES
  70. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..:$<TARGET_FILE_DIR:${GRPC_QUICK_PLUGIN_NAME}>/..)
  71. endif()
  72. endif()