CMakeLists.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. set(TARGET addressbookserver)
  2. set(GENERATED_SOURCES
  3. ${CMAKE_CURRENT_BINARY_DIR}/addressbook.pb.cc
  4. ${CMAKE_CURRENT_BINARY_DIR}/addressbook.grpc.pb.cc)
  5. set_source_files_properties(${GENERATED_SOURCES} PROPERTIES GENERATED TRUE)
  6. add_executable(${TARGET} main.cpp ${GENERATED_SOURCES})
  7. target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
  8. if(UNIX)
  9. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  10. # using GCC
  11. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=array-bounds")
  12. endif()
  13. endif()
  14. file(GLOB PROTO_FILES ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/../addressbook/proto/*.proto)
  15. qt_protobuf_internal_protobuf_generate_all(TARGET ${TARGET}
  16. GENERATED_SOURCES ${GENERATED_SOURCES}
  17. PROTO_FILES ${PROTO_FILES})
  18. target_link_libraries(${TARGET} PRIVATE protobuf::libprotobuf gRPC::grpc++ gRPC::grpc)
  19. if(MSVC)
  20. target_compile_definitions(${TARGET} PRIVATE _WIN32_WINNT=0x600 _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS)
  21. endif()
  22. add_custom_command(TARGET ${TARGET}
  23. COMMAND ${CMAKE_COMMAND} -E copy
  24. "${CMAKE_CURRENT_SOURCE_DIR}/cert.pem"
  25. "${CMAKE_CURRENT_SOURCE_DIR}/key.pem"
  26. "$<TARGET_FILE_DIR:${TARGET}>"
  27. )
  28. set(SERVER_EXEC_PATH ${CMAKE_CURRENT_BINARY_DIR}/${TARGET} PARENT_SCOPE)