external_rules.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. function(download_external_sources)
  15. file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/external)
  16. execute_process(
  17. COMMAND
  18. ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
  19. -DFIREBASE_DOWNLOAD_DIR=${FIREBASE_DOWNLOAD_DIR}
  20. -DCMAKE_INSTALL_PREFIX=${FIREBASE_INSTALL_DIR}
  21. ${PROJECT_SOURCE_DIR}/cmake/external
  22. WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/external
  23. )
  24. # Run downloads in parallel if we know how
  25. if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
  26. set(cmake_build_args -j)
  27. endif()
  28. execute_process(
  29. COMMAND ${CMAKE_COMMAND} --build . -- ${cmake_build_args}
  30. WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/external
  31. )
  32. endfunction()
  33. function(add_external_subdirectory NAME)
  34. add_subdirectory(
  35. ${FIREBASE_BINARY_DIR}/external/src/${NAME}
  36. ${FIREBASE_BINARY_DIR}/external/src/${NAME}-build
  37. EXCLUDE_FROM_ALL
  38. )
  39. endfunction()