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.
This commit is contained in:
parent
6ae0ff626a
commit
2cc46c12f8
|
@ -448,6 +448,35 @@ function(add_external_project_update_command name)
|
||||||
endfunction(add_external_project_update_command)
|
endfunction(add_external_project_update_command)
|
||||||
|
|
||||||
|
|
||||||
|
function(add_external_project_patch_command name)
|
||||||
|
get_external_project_directories(base_dir build_dir downloads_dir install_dir
|
||||||
|
sentinels_dir source_dir tmp_dir)
|
||||||
|
|
||||||
|
get_target_property(cmd ${name} AEP_PATCH_COMMAND)
|
||||||
|
if(cmd)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${sentinels_dir}/${name}-patch
|
||||||
|
COMMAND ${cmd}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch ${sentinels_dir}/${name}-patch
|
||||||
|
WORKING_DIRECTORY ${source_dir}/${name}
|
||||||
|
COMMENT "Performing patch step for '${name}'"
|
||||||
|
DEPENDS ${sentinels_dir}/${name}-download
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${sentinels_dir}/${name}-patch
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch ${sentinels_dir}/${name}-patch
|
||||||
|
WORKING_DIRECTORY ${sentinels_dir}
|
||||||
|
COMMENT "No patch step for '${name}'"
|
||||||
|
DEPENDS ${sentinels_dir}/${name}-download
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endfunction(add_external_project_patch_command)
|
||||||
|
|
||||||
|
|
||||||
function(add_external_project_configure_command name)
|
function(add_external_project_configure_command name)
|
||||||
get_external_project_directories(base_dir build_dir downloads_dir install_dir
|
get_external_project_directories(base_dir build_dir downloads_dir install_dir
|
||||||
sentinels_dir source_dir tmp_dir)
|
sentinels_dir source_dir tmp_dir)
|
||||||
|
@ -464,6 +493,7 @@ function(add_external_project_configure_command name)
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${working_dir}
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${working_dir}
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch ${sentinels_dir}/${name}-working_dir
|
COMMAND ${CMAKE_COMMAND} -E touch ${sentinels_dir}/${name}-working_dir
|
||||||
DEPENDS ${sentinels_dir}/${name}-update
|
DEPENDS ${sentinels_dir}/${name}-update
|
||||||
|
${sentinels_dir}/${name}-patch
|
||||||
${file_deps}
|
${file_deps}
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
@ -635,6 +665,7 @@ foreach(key IN ITEMS
|
||||||
DOWNLOAD_COMMAND
|
DOWNLOAD_COMMAND
|
||||||
INSTALL_ARGS
|
INSTALL_ARGS
|
||||||
INSTALL_COMMAND
|
INSTALL_COMMAND
|
||||||
|
PATCH_COMMAND
|
||||||
SVN_REPOSITORY
|
SVN_REPOSITORY
|
||||||
SVN_TAG
|
SVN_TAG
|
||||||
TAR
|
TAR
|
||||||
|
@ -721,6 +752,7 @@ function(add_external_project name)
|
||||||
#
|
#
|
||||||
add_external_project_download_command(${name})
|
add_external_project_download_command(${name})
|
||||||
add_external_project_update_command(${name})
|
add_external_project_update_command(${name})
|
||||||
|
add_external_project_patch_command(${name})
|
||||||
add_external_project_configure_command(${name})
|
add_external_project_configure_command(${name})
|
||||||
add_external_project_build_command(${name})
|
add_external_project_build_command(${name})
|
||||||
add_external_project_install_command(${name})
|
add_external_project_install_command(${name})
|
||||||
|
|
|
@ -90,6 +90,7 @@ add_external_project(${proj}
|
||||||
DOWNLOAD_COMMAND ""
|
DOWNLOAD_COMMAND ""
|
||||||
INSTALL_ARGS ""
|
INSTALL_ARGS ""
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
|
PATCH_COMMAND ""
|
||||||
SVN_REPOSITORY ""
|
SVN_REPOSITORY ""
|
||||||
SVN_TAG ""
|
SVN_TAG ""
|
||||||
TAR ""
|
TAR ""
|
||||||
|
@ -116,6 +117,7 @@ endif()
|
||||||
set(proj TutorialStep1-LocalTAR)
|
set(proj TutorialStep1-LocalTAR)
|
||||||
add_external_project(${proj}
|
add_external_project(${proj}
|
||||||
TAR "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar"
|
TAR "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar"
|
||||||
|
PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake
|
||||||
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
|
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix}
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
|
@ -263,7 +265,7 @@ if(can_build_tutorial_step5)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_test(TutorialStep1-LocalTAR-BuildTreeTest
|
add_test(TutorialStep1-LocalTAR-BuildTreeTest
|
||||||
"${build_dir}/TutorialStep1-LocalTAR/Tutorial" 36)
|
"${build_dir}/TutorialStep1-LocalTAR/EP-Tutorial" 36)
|
||||||
|
|
||||||
add_test(TutorialStep1-LocalNoDirTAR-BuildTreeTest
|
add_test(TutorialStep1-LocalNoDirTAR-BuildTreeTest
|
||||||
"${build_dir}/TutorialStep1-LocalNoDirTAR/Tutorial" 25)
|
"${build_dir}/TutorialStep1-LocalNoDirTAR/Tutorial" 25)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
# 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")
|
Loading…
Reference in New Issue