DownloadPrebuilt.cmake.in 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # This script drives download of prebuilt packages during the build.
  2. # The top-level CMakeLists.txt configures packages and tool locations.
  3. set(packages "@PREBUILT_PACKAGES@")
  4. set(python "@PYTHON_EXECUTABLE@")
  5. set(install_dir "@CMAKE_SOURCE_DIR@/..")
  6. set(scripts_dir "@SCRIPTS_DIR@")
  7. set(sentinel_dir "@CMAKE_BINARY_DIR@/prepare")
  8. set(prebuilt_type "@PREBUILT_TYPE@")
  9. foreach(package ${packages})
  10. if(${install_dir}/install.xml IS_NEWER_THAN ${sentinel_dir}/${package}_installed)
  11. # This package is missing or out of date.
  12. message(STATUS "Obtaining${proprietary_message} prebuilt '${package}'")
  13. execute_process(
  14. COMMAND ${python} install.py -p${prebuilt_type} --install-dir=${install_dir} ${package}
  15. WORKING_DIRECTORY ${scripts_dir}
  16. RESULT_VARIABLE result
  17. )
  18. if(result STREQUAL 0)
  19. # Write a sentinel to avoid attempting a download again.
  20. file(WRITE ${sentinel_dir}/${package}_installed "Obtained '${package}'")
  21. else(result STREQUAL 0)
  22. # Remove the sentinel to ensure a download is attempted again.
  23. file(REMOVE ${sentinel_dir}/prebuilt
  24. ${sentinel_dir}/${package}_installed)
  25. message(FATAL_ERROR
  26. "Failed to download or unpack prebuilt '${package}'. "
  27. "Process returned: ${result}")
  28. endif(result STREQUAL 0)
  29. else(${install_dir}/install.xml IS_NEWER_THAN ${sentinel_dir}/${package}_installed)
  30. # This package is ready.
  31. message(STATUS "Prebuilt '${package}' is up-to-date")
  32. endif(${install_dir}/install.xml IS_NEWER_THAN ${sentinel_dir}/${package}_installed)
  33. endforeach(package)
  34. # Store a sentinel to avoid running this script unnecessarily.
  35. file(WRITE ${sentinel_dir}/prebuilt "All prebuilts obtained successfully\n")