CMakeLists.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. cmake_minimum_required(VERSION 3.5)
  2. project(clienttutorial LANGUAGES CXX)
  3. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  4. set(CMAKE_AUTOUIC ON)
  5. set(CMAKE_AUTOMOC ON)
  6. set(CMAKE_AUTORCC ON)
  7. find_package(Qt5 COMPONENTS Core Quick REQUIRED)
  8. set(CMAKE_POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE})
  9. if(NOT TARGET ${QT_PROTOBUF_NAMESPACE}::Protobuf)
  10. find_package(${QT_PROTOBUF_NAMESPACE} COMPONENTS Protobuf REQUIRED)
  11. endif()
  12. if(NOT TARGET ${QT_PROTOBUF_NAMESPACE}::Grpc)
  13. find_package(${QT_PROTOBUF_NAMESPACE} COMPONENTS Grpc REQUIRED)
  14. endif()
  15. add_executable(clienttutorial main.cpp echoclientengine.cpp qml.qrc)
  16. qtprotobuf_generate(TARGET clienttutorial
  17. PROTO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial.proto
  18. QML TRUE)
  19. target_compile_definitions(clienttutorial
  20. PRIVATE "$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>")
  21. if(QT_PROTOBUF_STATIC)
  22. add_definitions(-DQT_PROTOBUF_STATIC)# add_definitions is used because old cmake versions
  23. # compatibility
  24. endif()
  25. target_link_libraries(clienttutorial PRIVATE Qt5::Core
  26. Qt5::Quick
  27. ${QT_PROTOBUF_NAMESPACE}::Grpc
  28. ${QT_PROTOBUF_NAMESPACE}::Protobuf)