CMakeLists.txt 1.1 KB

1234567891011121314151617181920212223242526272829
  1. set(TARGET addressbook)
  2. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  3. set(CMAKE_AUTOMOC ON)
  4. set(CMAKE_AUTORCC ON)
  5. find_package(Qt5 COMPONENTS Core Quick Network REQUIRED)
  6. find_package(QtProtobufProject CONFIG REQUIRED COMPONENTS QtProtobuf QtGrpc)
  7. file(GLOB PROTO_FILES ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/proto/addressbook.proto)
  8. generate_qtprotobuf(TARGET ${TARGET}
  9. OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated
  10. PROTO_FILES ${PROTO_FILES}
  11. QML TRUE)
  12. file(GLOB SOURCES main.cpp
  13. addressbookengine.cpp)
  14. add_executable(${TARGET} ${SOURCES} resources.qrc)
  15. add_target_windeployqt(TARGET ${TARGET} QML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/qml)
  16. add_custom_command(TARGET ${TARGET}
  17. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../addressbookserver/cert.pem $<TARGET_FILE_DIR:${TARGET}>)
  18. add_dependencies(${TARGET} ${QtProtobuf_GENERATED} examples_common)
  19. target_link_libraries(${TARGET} examples_common QtProtobufProject::QtProtobuf QtProtobufProject::QtGrpc ${QtProtobuf_GENERATED} Qt5::Quick Qt5::Qml)
  20. set(CLIENT_EXEC_PATH ${CMAKE_CURRENT_BINARY_DIR}/${TARGET} PARENT_SCOPE)