CMakeLists.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. set(TARGET qtgrpc_qml_test)
  2. find_package(Qt5 COMPONENTS Core Quick Network Test QuickTest REQUIRED)
  3. find_package(QtProtobufProject COMPONENTS QtGrpc REQUIRED)
  4. include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufTest.cmake)
  5. set(CMAKE_AUTOMOC OFF)
  6. file(GLOB SOURCES main.cpp)
  7. file(GLOB QML_FILES qml/tst_grpc.qml)
  8. qt5_wrap_cpp(MOC_SOURCES test.h)
  9. add_executable(${TARGET} ${MOC_SOURCES} ${SOURCES} ${QML_FILES})
  10. target_link_libraries(${TARGET} PRIVATE Qt5::Qml Qt5::Quick Qt5::Test Qt5::QuickTest QtProtobufProject::QtGrpc)
  11. if(QT_PROTOBUF_STATIC)
  12. target_link_libraries(${TARGET} PRIVATE ${PROTOBUF_QUICK_PLUGIN_NAME} ${GRPC_QUICK_PLUGIN_NAME})
  13. endif()
  14. qtprotobuf_link_target(${TARGET} qtgrpc_test_qtprotobuf_gen)
  15. if(UNIX)
  16. set(TEST_DRIVER_NAME "test_driver.sh")
  17. elseif(WIN32)
  18. set(TEST_DRIVER_NAME "test_driver.bat")
  19. endif()
  20. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../test_grpc/${TEST_DRIVER_NAME}.in ${TEST_DRIVER_NAME} @ONLY)
  21. add_test(NAME ${TARGET}
  22. COMMAND ${TEST_DRIVER_NAME} $<TARGET_FILE:${TARGET}> $<TARGET_FILE:echoserver> $<TARGET_FILE_NAME:${TARGET}> $<TARGET_FILE_NAME:echoserver>
  23. )
  24. add_target_qml(TARGET ${TARGET} QML_FILES ${QML_FILES})
  25. add_target_windeployqt(TARGET ${TARGET} QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qml)
  26. if(WIN32)
  27. set_tests_properties(${TARGET} PROPERTIES
  28. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..\;$<TARGET_FILE_DIR:${GRPC_QUICK_PLUGIN_NAME}>/..)
  29. else()
  30. set_tests_properties(${TARGET} PROPERTIES
  31. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..:$<TARGET_FILE_DIR:${GRPC_QUICK_PLUGIN_NAME}>/..)
  32. endif()