Step1Patch.cmake 809 B

12345678910111213141516171819202122232425
  1. # Verify the current working directory.
  2. if(NOT EXISTS CMakeLists.txt)
  3. message(FATAL_ERROR "File does not exist:\n ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")
  4. endif()
  5. if(NOT EXISTS tutorial.cxx)
  6. message(FATAL_ERROR "File does not exist:\n ${CMAKE_CURRENT_SOURCE_DIR}/tutorial.cxx")
  7. endif()
  8. # Check if the patch is already applied.
  9. file(STRINGS CMakeLists.txt prop_line REGEX "^set_property")
  10. if(prop_line)
  11. message(STATUS "Patch already applied!")
  12. return()
  13. endif()
  14. # Apply the patch.
  15. file(APPEND CMakeLists.txt "
  16. # Patch by ExternalProject test:
  17. set_property(TARGET Tutorial PROPERTY OUTPUT_NAME EP-Tutorial)
  18. list(LENGTH TEST_LIST len)
  19. if(NOT len EQUAL 3)
  20. message(FATAL_ERROR \"TEST_LIST length is \${len}, not 3\")
  21. endif()
  22. ")
  23. message(STATUS "Patched ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")