CMakeLists.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. cmake_minimum_required(VERSION 3.16)
  2. project(grpcsimplechat LANGUAGES CXX)
  3. set(CMAKE_AUTOMOC ON)
  4. set(CMAKE_AUTOUIC ON)
  5. if(NOT DEFINED INSTALL_EXAMPLESDIR)
  6. set(INSTALL_EXAMPLESDIR "examples")
  7. endif()
  8. set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/grpc/grpcsimplechat")
  9. find_package(Qt6 REQUIRED COMPONENTS Core Quick Protobuf Grpc)
  10. qt_add_executable(grpcsimplechat
  11. main.cpp
  12. simplechatengine.cpp simplechatengine.h
  13. ../examples_common/universallistmodel.cpp ../examples_common/universallistmodel.h
  14. ../examples_common/universallistmodelbase.cpp ../examples_common/universallistmodel.h
  15. )
  16. target_include_directories(grpcsimplechat PRIVATE ../examples_common)
  17. target_link_libraries(grpcsimplechat PRIVATE
  18. Qt::Core
  19. Qt::Quick
  20. Qt::Protobuf
  21. Qt::Grpc
  22. Qt::Quick
  23. )
  24. qt_add_qml_module(grpcsimplechat
  25. URI examples.grpc.simplechat
  26. VERSION 1.0
  27. QML_FILES
  28. ChatInputField.qml
  29. ChatView.qml
  30. main.qml
  31. RESOURCES
  32. img/arrow.png
  33. NO_RESOURCE_TARGET_PATH
  34. )
  35. qt_protobuf_generate(TARGET grpcsimplechat
  36. PROTO_FILES
  37. proto/simplechat.proto
  38. QML
  39. )
  40. install(TARGETS grpcsimplechat
  41. RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
  42. BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
  43. LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
  44. )
  45. add_custom_command(TARGET grpcsimplechat
  46. COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/../ssl/cert.pem"
  47. "$<TARGET_FILE_DIR:grpcsimplechat>"
  48. )
  49. install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../ssl/cert.pem"
  50. DESTINATION "${INSTALL_EXAMPLEDIR}"
  51. )