podspec_rules.cmake 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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(CMakeParseArguments)
  15. macro(podspec_version VARIABLE PODSPEC_FILE)
  16. execute_process(
  17. COMMAND
  18. sed -n
  19. -f ${PROJECT_SOURCE_DIR}/cmake/podspec_version.sed
  20. ${PODSPEC_FILE}
  21. OUTPUT_VARIABLE ${VARIABLE}
  22. OUTPUT_STRIP_TRAILING_WHITESPACE
  23. )
  24. if(${VARIABLE} STREQUAL "")
  25. message(
  26. FATAL_ERROR
  27. "Running the sed script ${PROJECT_SOURCE_DIR}/cmake/podspec_version.sed \
  28. on file ${PODSPEC_FILE} failed; ensure that the `sed` executable is \
  29. installed and that its directory is present in the PATH environment \
  30. variable."
  31. )
  32. endif()
  33. endmacro()
  34. macro(firebase_version VARIABLE PODSPEC_FILE)
  35. execute_process(
  36. COMMAND
  37. sed -n
  38. -f ${PROJECT_SOURCE_DIR}/cmake/firebase_version.sed
  39. ${PODSPEC_FILE}
  40. OUTPUT_VARIABLE ${VARIABLE}
  41. OUTPUT_STRIP_TRAILING_WHITESPACE
  42. )
  43. if(${VARIABLE} STREQUAL "")
  44. message(
  45. FATAL_ERROR
  46. "Running the sed script ${PROJECT_SOURCE_DIR}/cmake/firebase_version.sed \
  47. on file ${PODSPEC_FILE} failed; ensure that the `sed` executable is \
  48. installed and that its directory is present in the PATH environment \
  49. variable."
  50. )
  51. endif()
  52. endmacro()
  53. function(podspec_prep_headers FRAMEWORK_NAME)
  54. file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Headers/${FRAMEWORK_NAME})
  55. execute_process(
  56. COMMAND
  57. ln -sf ${ARGN} ${PROJECT_BINARY_DIR}/Headers/${FRAMEWORK_NAME}
  58. )
  59. endfunction()