CMakeLists.txt 1.3 KB

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