CMakeLists.txt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. set(TARGET ${GENERATOR_TARGET})
  2. set(TARGET_EXPORT GeneratorTargets)
  3. set(TARGET_CONFIG GeneratorConfig)
  4. set(TARGET_BINDIR ${CMAKE_INSTALL_BINDIR})
  5. set(TARGET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
  6. file(GLOB SOURCES main.cpp
  7. generatorcommon.cpp
  8. generatoroptions.cpp
  9. templates.cpp
  10. generatorbase.cpp
  11. singlefilegenerator.cpp
  12. multifilegenerator.cpp
  13. baseprinter.cpp
  14. messagedeclarationprinter.cpp
  15. messagedefinitionprinter.cpp
  16. enumdeclarationprinter.cpp
  17. enumdefinitionprinter.cpp
  18. servicedeclarationprinterbase.cpp
  19. clientdeclarationprinter.cpp
  20. clientdefinitionprinter.cpp
  21. serverdeclarationprinter.cpp)
  22. file(GLOB HEADERS utils.h
  23. generatorcommon.h
  24. generatoroptions.h
  25. templates.h
  26. generatorbase.h
  27. singlefilegenerator.h
  28. multifilegenerator.h
  29. baseprinter.h
  30. descriptorprinterbase.h
  31. messagedeclarationprinter.h
  32. messagedefinitionprinter.h
  33. enumdeclarationprinter.h
  34. enumdefinitionprinter.h
  35. servicedeclarationprinterbase.h
  36. clientdeclarationprinter.h
  37. clientdefinitionprinter.h
  38. serverdeclarationprinter.h)
  39. add_executable(${TARGET} ${SOURCES})
  40. add_executable(${QT_PROTOBUF_PROJECT}::${TARGET} ALIAS ${TARGET})
  41. if(DEFINED Protobuf_INCLUDE_DIRS)
  42. target_include_directories(${TARGET} PUBLIC ${Protobuf_INCLUDE_DIRS})
  43. endif()
  44. target_link_libraries(${TARGET} protobuf::libprotobuf protobuf::libprotoc)
  45. include(CMakePackageConfigHelpers)
  46. configure_package_config_file(
  47. "${TARGET_CONFIG}.cmake.in" "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
  48. INSTALL_DESTINATION "${TARGET_CMAKE_DIR}")
  49. configure_file("${QT_PROTOBUF_CMAKE_DIR}/QtProtobufGen.cmake" "${QT_PROTOBUF_BINARY_DIR}/QtProtobufGen.cmake" COPYONLY)
  50. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/parsemessages.go" "${QT_PROTOBUF_BINARY_DIR}/parsemessages.go" COPYONLY)
  51. configure_file("${QT_PROTOBUF_CMAKE_DIR}/ProtobufLookup.cmake" "${QT_PROTOBUF_BINARY_DIR}/ProtobufLookup.cmake" COPYONLY)
  52. if(QT_PROTOBUF_INSTALL)
  53. install(TARGETS ${TARGET}
  54. EXPORT ${TARGET_EXPORT} COMPONENT dev
  55. RUNTIME DESTINATION ${TARGET_BINDIR} COMPONENT lib)
  56. install(EXPORT ${TARGET_EXPORT} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake DESTINATION ${TARGET_CMAKE_DIR} COMPONENT dev)
  57. install(FILES "${QT_PROTOBUF_BINARY_DIR}/${TARGET_CONFIG}.cmake"
  58. "${QT_PROTOBUF_BINARY_DIR}/QtProtobufGen.cmake"
  59. "${QT_PROTOBUF_BINARY_DIR}/parsemessages.go"
  60. "${QT_PROTOBUF_BINARY_DIR}/ProtobufLookup.cmake"
  61. DESTINATION "${TARGET_CMAKE_DIR}" COMPONENT dev)
  62. endif()
  63. export(TARGETS ${TARGET} NAMESPACE ${QT_PROTOBUF_PROJECT}:: FILE ${TARGET_EXPORT}.cmake)