CMakeLists.txt 915 B

12345678910111213141516171819
  1. set(TARGET echoserver)
  2. set(GENERATED_SOURCES
  3. ${CMAKE_CURRENT_BINARY_DIR}/simpletest.grpc.pb.cc
  4. ${CMAKE_CURRENT_BINARY_DIR}/simpletest.pb.cc
  5. ${CMAKE_CURRENT_BINARY_DIR}/testservice.grpc.pb.cc
  6. ${CMAKE_CURRENT_BINARY_DIR}/testservice.pb.cc)
  7. set_source_files_properties(${GENERATED_SOURCES} PROPERTIES GENERATED TRUE)
  8. add_executable(${TARGET} main.cpp ${GENERATED_SOURCES})
  9. target_link_libraries(${TARGET} PRIVATE gRPC::grpc++ protobuf::libprotobuf)
  10. target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
  11. if(MSVC)
  12. target_compile_definitions(${TARGET} PRIVATE _WIN32_WINNT=0x600 _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS)
  13. endif()
  14. file(GLOB PROTO_FILES ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/../proto/*.proto)
  15. qt_protobuf_internal_protobuf_generate_all(TARGET ${TARGET}
  16. GENERATED_SOURCES ${GENERATED_SOURCES}
  17. PROTO_FILES ${PROTO_FILES})