CMakeLists.txt 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. set(TARGET qtprotobuf_qml_test)
  2. find_package(Qt5 COMPONENTS Core Quick Network Test QuickTest REQUIRED)
  3. find_package(QtProtobufProject COMPONENTS QtProtobuf 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_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}>/..)