podspec_rules.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # Reads properties from the given podspec and generates a cmake file that
  16. # defines the equivalent framework.
  17. #
  18. # Only does anything useful on Apple platforms. On non-Apple platforms, this
  19. # function has no effect--no target is created.
  20. macro(podspec_framework PODSPEC_FILE)
  21. if(APPLE)
  22. set(multi SPECS)
  23. cmake_parse_arguments(psf "" "" "${multi}" ${ARGN})
  24. get_filename_component(_properties_file ${PODSPEC_FILE} NAME_WE)
  25. set(_properties_file ${_properties_file}.cmake)
  26. execute_process(
  27. COMMAND
  28. bundle exec
  29. ${FIREBASE_SOURCE_DIR}/cmake/podspec_cmake.rb
  30. ${PODSPEC_FILE}
  31. ${CMAKE_CURRENT_BINARY_DIR}/${_properties_file}
  32. ${psf_SPECS}
  33. )
  34. # Get CMake to automatically re-run if the generation script or the podspec
  35. # source changes.
  36. set_property(
  37. DIRECTORY APPEND PROPERTY
  38. CMAKE_CONFIGURE_DEPENDS ${FIREBASE_SOURCE_DIR}/cmake/podspec_cmake.rb
  39. )
  40. set_property(
  41. DIRECTORY APPEND PROPERTY
  42. CMAKE_CONFIGURE_DEPENDS ${PODSPEC_FILE}
  43. )
  44. include(${CMAKE_CURRENT_BINARY_DIR}/${_properties_file})
  45. endif()
  46. endmacro()