external_rules.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. -DFUZZING=${FUZZING}
  22. ${PROJECT_SOURCE_DIR}/cmake/external
  23. WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/external
  24. )
  25. # Run downloads in parallel if we know how
  26. if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
  27. set(cmake_build_args -j)
  28. endif()
  29. execute_process(
  30. COMMAND ${CMAKE_COMMAND} --build . -- ${cmake_build_args}
  31. WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/external
  32. )
  33. endfunction()
  34. function(add_external_subdirectory NAME)
  35. add_subdirectory(
  36. ${FIREBASE_BINARY_DIR}/external/src/${NAME}
  37. ${FIREBASE_BINARY_DIR}/external/src/${NAME}-build
  38. EXCLUDE_FROM_ALL
  39. )
  40. endfunction()