ctkFunctionApplyPatches.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ###########################################################################
  2. #
  3. # Library: CTK
  4. #
  5. # Copyright (c) 2010 Kitware Inc.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.commontk.org/LICENSE
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. ###########################################################################
  20. #
  21. # Depends on:
  22. # CTK/CMake/ctkFunctionLFtoCRLF.cmake
  23. #
  24. FUNCTION(ctkFunctionApplyPatches PATCH_EXE SRC_DIR PATCH_FILES)
  25. # Make sure patch executable exists
  26. IF(NOT EXISTS ${PATCH_EXE})
  27. MESSAGE(FATAL_ERROR "ERROR: Program [${PATCH_EXE}] doesn't exist !")
  28. ENDIF()
  29. # Apply patches
  30. FOREACH(patch_file ${PATCH_FILES})
  31. MESSAGE("Applying patch: ${patch_file}")
  32. IF(WIN32)
  33. ctkFunctionLFtoCRLF("${patch_file}" "${patch_file}")
  34. ENDIF()
  35. EXECUTE_PROCESS(COMMAND ${PATCH_EXE} -p0 -i "${patch_file}" -d "${SRC_DIR}" RESULT_VARIABLE result_var)
  36. IF(result_var)
  37. MESSAGE("ERROR: ${result_var}")
  38. ENDIF(result_var)
  39. ENDFOREACH()
  40. ENDFUNCTION()