CMakeLists.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. set(TARGET qtprotobuf_qml_test)
  2. qt_protobuf_internal_find_dependencies()
  3. set(CMAKE_AUTOMOC OFF)
  4. file(GLOB SOURCES main.cpp)
  5. file(GLOB QML_FILES qml/tst_simple.qml)
  6. qt5_wrap_cpp(MOC_SOURCES test.h)
  7. add_executable(${TARGET} ${MOC_SOURCES} ${SOURCES} ${QML_FILES})
  8. target_link_libraries(${TARGET} PRIVATE Qt5::Core Qt5::Qml Qt5::Network Qt5::Quick Qt5::Test Qt5::QuickTest ${QT_PROTOBUF_NAMESPACE}::Protobuf)
  9. if(TARGET ${QT_PROTOBUF_NAMESPACE}::ProtobufWellKnownTypes)
  10. target_link_libraries(${TARGET} PRIVATE ${QT_PROTOBUF_NAMESPACE}::ProtobufWellKnownTypes)
  11. endif()
  12. if(QT_PROTOBUF_STATIC)
  13. target_link_libraries(${TARGET} PRIVATE ${QT_PROTOBUF_NAMESPACE}::${PROTOBUF_QUICK_PLUGIN_NAME})
  14. endif()
  15. qtprotobuf_link_target(${TARGET} qtprotobuf_test_qtprotobuf_gen)
  16. qt_protobuf_internal_add_target_qml(TARGET ${TARGET} QML_FILES ${QML_FILES})
  17. qt_protobuf_internal_add_target_windeployqt(TARGET ${TARGET} QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qml)
  18. add_test(NAME ${TARGET} COMMAND ${TARGET})
  19. if(NOT QT_PROTOBUF_STATIC AND NOT QT_PROTOBUF_STANDALONE_TESTS)
  20. set(path_separator ":")
  21. if(WIN32)
  22. set(path_separator "$<SEMICOLON>")
  23. endif()
  24. set_tests_properties(${TARGET} PROPERTIES
  25. ENVIRONMENT "QML2_IMPORT_PATH=$ENV{QML2_IMPORT_PATH}${path_separator}\
  26. $<TARGET_FILE_DIR:${QT_PROTOBUF_NAMESPACE}::${PROTOBUF_QUICK_PLUGIN_NAME}>/.."
  27. )
  28. endif()