FindProtobuf.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright 2018 Google
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. include(FindPackageHandleStandardArgs)
  15. set(BINARY_DIR ${FIREBASE_INSTALL_DIR}/external/protobuf)
  16. find_path(
  17. PROTOBUF_INCLUDE_DIR google/protobuf/stubs/common.h
  18. HINTS ${BINARY_DIR}/src/protobuf/src
  19. )
  20. find_library(
  21. PROTOBUF_LIBRARY
  22. NAMES libprotobuf.a
  23. HINTS ${BINARY_DIR}/src/protobuf-build/src/.libs/
  24. )
  25. find_library(
  26. PROTOBUFLITE_LIBRARY
  27. NAMES libprotobuf-lite.a
  28. HINTS ${BINARY_DIR}/src/protobuf-build/src/.libs/
  29. )
  30. find_package_handle_standard_args(
  31. protobuf
  32. DEFAULT_MSG
  33. PROTOBUF_INCLUDE_DIR
  34. PROTOBUF_LIBRARY
  35. PROTOBUFLITE_LIBRARY
  36. )
  37. if(PROTOBUF_FOUND)
  38. set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
  39. set(PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARY} ${PROTOBUFLITE_LIBRARY})
  40. if (NOT TARGET protobuf-lite)
  41. add_library(protobuf-lite UNKNOWN IMPORTED)
  42. set_target_properties(
  43. protobuf-lite PROPERTIES
  44. INTERFACE_INCLUDE_DIRECTORIES ${PROTOBUF_INCLUDE_DIRS}
  45. IMPORTED_LOCATION ${PROTOBUFLITE_LIBRARY}
  46. )
  47. endif()
  48. if (NOT TARGET protobuf)
  49. add_library(protobuf UNKNOWN IMPORTED)
  50. set_target_properties(
  51. protobuf PROPERTIES
  52. INTERFACE_INCLUDE_DIRECTORIES ${PROTOBUF_INCLUDE_DIRS}
  53. IMPORTED_LOCATION ${PROTOBUF_LIBRARY}
  54. INTERFACE_LINK_LIBRARIES protobuf-lite
  55. )
  56. endif()
  57. endif(PROTOBUF_FOUND)