libprotobuf.cmake 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. set(libprotobuf_files
  2. ${protobuf_source_dir}/src/google/protobuf/any.cc
  3. ${protobuf_source_dir}/src/google/protobuf/any.pb.cc
  4. ${protobuf_source_dir}/src/google/protobuf/api.pb.cc
  5. ${protobuf_source_dir}/src/google/protobuf/compiler/importer.cc
  6. ${protobuf_source_dir}/src/google/protobuf/compiler/parser.cc
  7. ${protobuf_source_dir}/src/google/protobuf/descriptor.cc
  8. ${protobuf_source_dir}/src/google/protobuf/descriptor.pb.cc
  9. ${protobuf_source_dir}/src/google/protobuf/descriptor_database.cc
  10. ${protobuf_source_dir}/src/google/protobuf/duration.pb.cc
  11. ${protobuf_source_dir}/src/google/protobuf/dynamic_message.cc
  12. ${protobuf_source_dir}/src/google/protobuf/empty.pb.cc
  13. ${protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc
  14. ${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc
  15. ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc
  16. ${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.cc
  17. ${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc
  18. ${protobuf_source_dir}/src/google/protobuf/io/printer.cc
  19. ${protobuf_source_dir}/src/google/protobuf/io/tokenizer.cc
  20. ${protobuf_source_dir}/src/google/protobuf/map_field.cc
  21. ${protobuf_source_dir}/src/google/protobuf/message.cc
  22. ${protobuf_source_dir}/src/google/protobuf/reflection_ops.cc
  23. ${protobuf_source_dir}/src/google/protobuf/service.cc
  24. ${protobuf_source_dir}/src/google/protobuf/source_context.pb.cc
  25. ${protobuf_source_dir}/src/google/protobuf/struct.pb.cc
  26. ${protobuf_source_dir}/src/google/protobuf/stubs/substitute.cc
  27. ${protobuf_source_dir}/src/google/protobuf/text_format.cc
  28. ${protobuf_source_dir}/src/google/protobuf/timestamp.pb.cc
  29. ${protobuf_source_dir}/src/google/protobuf/type.pb.cc
  30. ${protobuf_source_dir}/src/google/protobuf/unknown_field_set.cc
  31. ${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.cc
  32. ${protobuf_source_dir}/src/google/protobuf/util/field_comparator.cc
  33. ${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.cc
  34. ${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.cc
  35. ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.cc
  36. ${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.cc
  37. ${protobuf_source_dir}/src/google/protobuf/util/internal/field_mask_utility.cc
  38. ${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.cc
  39. ${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter.cc
  40. ${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser.cc
  41. ${protobuf_source_dir}/src/google/protobuf/util/internal/object_writer.cc
  42. ${protobuf_source_dir}/src/google/protobuf/util/internal/proto_writer.cc
  43. ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.cc
  44. ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.cc
  45. ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.cc
  46. ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc
  47. ${protobuf_source_dir}/src/google/protobuf/util/internal/utility.cc
  48. ${protobuf_source_dir}/src/google/protobuf/util/json_util.cc
  49. ${protobuf_source_dir}/src/google/protobuf/util/message_differencer.cc
  50. ${protobuf_source_dir}/src/google/protobuf/util/time_util.cc
  51. ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.cc
  52. ${protobuf_source_dir}/src/google/protobuf/wire_format.cc
  53. ${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc
  54. )
  55. set(libprotobuf_includes
  56. ${protobuf_source_dir}/src/google/protobuf/any.h
  57. ${protobuf_source_dir}/src/google/protobuf/any.pb.h
  58. ${protobuf_source_dir}/src/google/protobuf/api.pb.h
  59. ${protobuf_source_dir}/src/google/protobuf/compiler/importer.h
  60. ${protobuf_source_dir}/src/google/protobuf/compiler/parser.h
  61. ${protobuf_source_dir}/src/google/protobuf/descriptor.h
  62. ${protobuf_source_dir}/src/google/protobuf/descriptor.pb.h
  63. ${protobuf_source_dir}/src/google/protobuf/descriptor_database.h
  64. ${protobuf_source_dir}/src/google/protobuf/duration.pb.h
  65. ${protobuf_source_dir}/src/google/protobuf/dynamic_message.h
  66. ${protobuf_source_dir}/src/google/protobuf/empty.pb.h
  67. ${protobuf_source_dir}/src/google/protobuf/field_mask.pb.h
  68. ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.h
  69. ${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.h
  70. ${protobuf_source_dir}/src/google/protobuf/io/printer.h
  71. ${protobuf_source_dir}/src/google/protobuf/io/tokenizer.h
  72. ${protobuf_source_dir}/src/google/protobuf/map_field.h
  73. ${protobuf_source_dir}/src/google/protobuf/message.h
  74. ${protobuf_source_dir}/src/google/protobuf/reflection_ops.h
  75. ${protobuf_source_dir}/src/google/protobuf/service.h
  76. ${protobuf_source_dir}/src/google/protobuf/source_context.pb.h
  77. ${protobuf_source_dir}/src/google/protobuf/struct.pb.h
  78. ${protobuf_source_dir}/src/google/protobuf/stubs/substitute.h
  79. ${protobuf_source_dir}/src/google/protobuf/text_format.h
  80. ${protobuf_source_dir}/src/google/protobuf/timestamp.pb.h
  81. ${protobuf_source_dir}/src/google/protobuf/type.pb.h
  82. ${protobuf_source_dir}/src/google/protobuf/unknown_field_set.h
  83. ${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.h
  84. ${protobuf_source_dir}/src/google/protobuf/util/field_comparator.h
  85. ${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.h
  86. ${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.h
  87. ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.h
  88. ${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.h
  89. ${protobuf_source_dir}/src/google/protobuf/util/internal/field_mask_utility.h
  90. ${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.h
  91. ${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter.h
  92. ${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser.h
  93. ${protobuf_source_dir}/src/google/protobuf/util/internal/object_writer.h
  94. ${protobuf_source_dir}/src/google/protobuf/util/internal/proto_writer.h
  95. ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.h
  96. ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.h
  97. ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.h
  98. ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.h
  99. ${protobuf_source_dir}/src/google/protobuf/util/internal/utility.h
  100. ${protobuf_source_dir}/src/google/protobuf/util/json_util.h
  101. ${protobuf_source_dir}/src/google/protobuf/util/message_differencer.h
  102. ${protobuf_source_dir}/src/google/protobuf/util/time_util.h
  103. ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.h
  104. ${protobuf_source_dir}/src/google/protobuf/wire_format.h
  105. ${protobuf_source_dir}/src/google/protobuf/wrappers.pb.h
  106. )
  107. if (MSVC)
  108. set(libprotobuf_rc_files
  109. ${CMAKE_CURRENT_BINARY_DIR}/version.rc
  110. )
  111. endif()
  112. add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
  113. ${libprotobuf_lite_files} ${libprotobuf_files} ${libprotobuf_includes} ${libprotobuf_rc_files})
  114. target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT})
  115. if(protobuf_WITH_ZLIB)
  116. target_link_libraries(libprotobuf ${ZLIB_LIBRARIES})
  117. endif()
  118. if(protobuf_LINK_LIBATOMIC)
  119. target_link_libraries(libprotobuf atomic)
  120. endif()
  121. if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
  122. target_link_libraries(libprotobuf log)
  123. endif()
  124. target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
  125. if(MSVC AND protobuf_BUILD_SHARED_LIBS)
  126. target_compile_definitions(libprotobuf
  127. PUBLIC PROTOBUF_USE_DLLS
  128. PRIVATE LIBPROTOBUF_EXPORTS)
  129. endif()
  130. set_target_properties(libprotobuf PROPERTIES
  131. VERSION ${protobuf_VERSION}
  132. OUTPUT_NAME ${LIB_PREFIX}protobuf
  133. DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
  134. add_library(protobuf::libprotobuf ALIAS libprotobuf)