From 68248be52ec69f06e41c52dcf950caf7d6f2da08 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 9 Apr 2009 13:56:08 -0400 Subject: [PATCH] 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. --- Modules/AddExternalProject.cmake | 7 +++++++ Tests/ExternalProject/CMakeLists.txt | 4 ++++ Tests/ExternalProject/Step1Patch.cmake | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/Modules/AddExternalProject.cmake b/Modules/AddExternalProject.cmake index 2474de816..be1ab85a4 100644 --- a/Modules/AddExternalProject.cmake +++ b/Modules/AddExternalProject.cmake @@ -211,6 +211,12 @@ function(add_external_project_step name step) endif() get_property(work_dir TARGET ${name} PROPERTY AEP_${step}_WORKING_DIRECTORY) + # Replace list separators. + get_property(sep TARGET ${name} PROPERTY AEP_LIST_SEPARATOR) + if(sep AND command) + string(REPLACE "${sep}" "\\;" command "${command}") + endif() + # Custom comment? get_property(comment_set TARGET ${name} PROPERTY AEP_${step}_COMMENT SET) if(comment_set) @@ -594,6 +600,7 @@ foreach(key IN ITEMS DOWNLOAD_COMMAND INSTALL_ARGS INSTALL_COMMAND + LIST_SEPARATOR PATCH_COMMAND SVN_REPOSITORY SVN_TAG diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 37374c1b7..63ab7ef53 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -117,16 +117,20 @@ endif() set(proj TutorialStep1-LocalTAR) add_external_project(${proj} TAR "${CMAKE_CURRENT_SOURCE_DIR}/Step1.tar" + LIST_SEPARATOR :: PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix} + -DTEST_LIST:STRING=A::B::C INSTALL_COMMAND "" ) set(proj TutorialStep1-LocalNoDirTAR) add_external_project(${proj} TAR "${CMAKE_CURRENT_SOURCE_DIR}/Step1NoDir.tar" + LIST_SEPARATOR @@ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${prefix} -G ${CMAKE_GENERATOR} ${source_dir}/${proj} + -DTEST_LIST:STRING=1@@2@@3 INSTALL_COMMAND "" ) add_external_project_step(${proj} mypatch diff --git a/Tests/ExternalProject/Step1Patch.cmake b/Tests/ExternalProject/Step1Patch.cmake index 1a1920a4d..35e09d948 100644 --- a/Tests/ExternalProject/Step1Patch.cmake +++ b/Tests/ExternalProject/Step1Patch.cmake @@ -17,5 +17,9 @@ endif() 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")