CMake/Tests/ExternalProject/Step1Patch.cmake
Brad King 2cc46c12f8 ENH: Add patch step for add_external_project
The patch step runs parallel to the update step since it does not make
sense to have both.  Configuration of the step requires specification of
a PATCH_COMMAND argument to add_external_project.
2009-03-18 11:01:02 -04:00

22 lines
692 B
CMake

# Verify the current working directory.
if(NOT EXISTS CMakeLists.txt)
message(FATAL_ERROR "File does not exist:\n ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")
endif()
if(NOT EXISTS tutorial.cxx)
message(FATAL_ERROR "File does not exist:\n ${CMAKE_CURRENT_SOURCE_DIR}/tutorial.cxx")
endif()
# Check if the patch is already applied.
file(STRINGS CMakeLists.txt prop_line REGEX "^set_property")
if(prop_line)
message(STATUS "Patch already applied!")
return()
endif()
# Apply the patch.
file(APPEND CMakeLists.txt "
# Patch by ExternalProject test:
set_property(TARGET Tutorial PROPERTY OUTPUT_NAME EP-Tutorial)
")
message(STATUS "Patched ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")