podspec_rules.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # Use bundler only if the current source tree has it set up. Otherwise fall
  27. # back on the system ruby setup, which may have CocoaPods installed.
  28. set(psf_runner ruby)
  29. if(EXISTS ${FIREBASE_SOURCE_DIR}/.bundle)
  30. set(psf_runner bundle exec)
  31. endif()
  32. execute_process(
  33. COMMAND
  34. ${psf_runner}
  35. ${FIREBASE_SOURCE_DIR}/cmake/podspec_cmake.rb
  36. ${PODSPEC_FILE}
  37. ${CMAKE_CURRENT_BINARY_DIR}/${_properties_file}
  38. ${psf_SPECS}
  39. )
  40. # Get CMake to automatically re-run if the generation script or the podspec
  41. # source changes.
  42. set_property(
  43. DIRECTORY APPEND PROPERTY
  44. CMAKE_CONFIGURE_DEPENDS ${FIREBASE_SOURCE_DIR}/cmake/podspec_cmake.rb
  45. )
  46. set_property(
  47. DIRECTORY APPEND PROPERTY
  48. CMAKE_CONFIGURE_DEPENDS ${PODSPEC_FILE}
  49. )
  50. include(${CMAKE_CURRENT_BINARY_DIR}/${_properties_file})
  51. endif()
  52. endmacro()