CMake/Tests/ExternalProject/Step1Patch.cmake
Brad King 68248be52e ENH: Allow lists in AddExternalProject arguments
The add_external_project function separates its arguments with ';'
separators, so previously no command line argument could contain one.
When specifying CMAKE_ARGS, some -D argument values may need to contain
a semicolon to form lists in the external project cache.

This adds add_external_project argument LIST_SEPARATOR to specify a list
separator string.  The separator is replaced by ';' in arguments to any
command created to drive the external project.  For example:

  add_external_project(...
    LIST_SEPARATOR ::
    CMAKE_ARGS -DSOME_LIST:STRING=A::B::C
    ...)

passes "-DSOME_LIST:STRING=A;B;C" to CMake for the external project.
2009-04-09 13:56:08 -04:00

26 lines
809 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)
list(LENGTH TEST_LIST len)
if(NOT len EQUAL 3)
message(FATAL_ERROR \"TEST_LIST length is \${len}, not 3\")
endif()
")
message(STATUS "Patched ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")