CMakeLists.txt 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. set(TARGET qtprotobuf_qml_test)
  2. include(${QT_PROTOBUF_CMAKE_DIR}/QtProtobufInternalHelpers.cmake)
  3. qt_protobuf_internal_find_dependencies()
  4. find_package(Qt5 COMPONENTS Quick QuickTest REQUIRED)
  5. set(CMAKE_AUTOMOC OFF)
  6. file(GLOB SOURCES main.cpp)
  7. file(GLOB QML_FILES qml/tst_simple.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::Core Qt5::Qml Qt5::Network Qt5::Quick Qt5::Test Qt5::QuickTest QtProtobufProject::QtProtobuf)
  11. if(TARGET QtProtobufProject::QtProtobufWellKnownTypes)
  12. target_link_libraries(${TARGET} PRIVATE QtProtobufProject::QtProtobufWellKnownTypes)
  13. endif()
  14. if(QT_PROTOBUF_STATIC)
  15. target_link_libraries(${TARGET} PRIVATE ${PROTOBUF_QUICK_PLUGIN_NAME})
  16. endif()
  17. qtprotobuf_link_target(${TARGET} qtprotobuf_test_qtprotobuf_gen)
  18. add_target_qml(TARGET ${TARGET} QML_FILES ${QML_FILES})
  19. add_target_windeployqt(TARGET ${TARGET} QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qml)
  20. add_test(NAME ${TARGET} COMMAND ${TARGET})
  21. set_tests_properties(${TARGET} PROPERTIES
  22. ENVIRONMENT QML2_IMPORT_PATH=$<TARGET_FILE_DIR:${PROTOBUF_QUICK_PLUGIN_NAME}>/..)