ScriptMode.cmake 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. cmake_policy(SET CMP0168 ${CMP0168})
  2. include(FetchContent)
  3. file(WRITE tmpFile.txt "Generated contents, not important")
  4. FetchContent_Populate(
  5. t1
  6. DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy
  7. ${CMAKE_CURRENT_BINARY_DIR}/tmpFile.txt
  8. <SOURCE_DIR>/done1.txt
  9. )
  10. if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/t1-src/done1.txt)
  11. message(FATAL_ERROR "Default SOURCE_DIR doesn't contain done1.txt")
  12. endif()
  13. FetchContent_Populate(
  14. t2
  15. SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/mysrc
  16. DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy
  17. ${CMAKE_CURRENT_BINARY_DIR}/tmpFile.txt
  18. <SOURCE_DIR>/done2.txt
  19. )
  20. if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mysrc/done2.txt)
  21. message(FATAL_ERROR "Specified SOURCE_DIR doesn't contain done2.txt")
  22. endif()
  23. FetchContent_Populate(
  24. t3
  25. SOURCE_DIR myrelsrc
  26. DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy
  27. ${CMAKE_CURRENT_BINARY_DIR}/tmpFile.txt
  28. <SOURCE_DIR>/done3.txt
  29. )
  30. if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/myrelsrc/done3.txt)
  31. message(FATAL_ERROR "Relative SOURCE_DIR doesn't contain done3.txt")
  32. endif()