summaryrefslogtreecommitdiffstats
path: root/Tests/CustomCommand
diff options
context:
space:
mode:
authorEd Branch <brance@mail.utexas.edu>2017-01-14 02:01:17 (GMT)
committerEd Branch <brance@mail.utexas.edu>2017-01-14 02:02:16 (GMT)
commit7c8ab7ddc8944152a1344c43acbb8c57fa2d398a (patch)
treee74c16ab04cd0961e5ca032ba99c45087dbd0dec /Tests/CustomCommand
parenteee51e24d2290771ad3dded566ef897243f21331 (diff)
downloadCMake-7c8ab7ddc8944152a1344c43acbb8c57fa2d398a.zip
CMake-7c8ab7ddc8944152a1344c43acbb8c57fa2d398a.tar.gz
CMake-7c8ab7ddc8944152a1344c43acbb8c57fa2d398a.tar.bz2
add_custom_{command,target}: Add COMMAND_EXPAND_LISTS option
This option allows lists generated by generator expressions to be expanded. Closes: #15935
Diffstat (limited to 'Tests/CustomCommand')
-rw-r--r--Tests/CustomCommand/CMakeLists.txt21
-rw-r--r--Tests/CustomCommand/compare_options.cmake14
2 files changed, 35 insertions, 0 deletions
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index db57e19..e9a9f52 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -513,3 +513,24 @@ add_custom_target(UseConsoleTarget ALL
VERBATIM
USES_TERMINAL
)
+
+# Test COMMAND_EXPAND_LISTS
+set(cmp_args "1ARG=COMMAND_EXPAND_LISTS" "2ARG=test" "3ARG=outfile"
+ "4ARG=content")
+set(AARGS "")
+foreach(arg IN LISTS cmp_args)
+ list(APPEND AARGS "-DA${arg}")
+endforeach()
+
+set(gen_file "expand_custom_command.phony")
+add_custom_command(
+ OUTPUT "${gen_file}"
+ COMMAND ${CMAKE_COMMAND} ${AARGS}
+ "-DB$<JOIN:$<TARGET_PROPERTY:command_expand_lists,CMPARGS>,;-DB>"
+ "-P" "${CMAKE_CURRENT_SOURCE_DIR}/compare_options.cmake"
+ COMMAND_EXPAND_LISTS
+ VERBATIM
+)
+set_property(SOURCE "${gen_file}" PROPERTY SYMBOLIC ON)
+add_custom_target(command_expand_lists ALL DEPENDS "${gen_file}")
+set_property(TARGET command_expand_lists PROPERTY CMPARGS "${cmp_args}")
diff --git a/Tests/CustomCommand/compare_options.cmake b/Tests/CustomCommand/compare_options.cmake
new file mode 100644
index 0000000..a32e579
--- /dev/null
+++ b/Tests/CustomCommand/compare_options.cmake
@@ -0,0 +1,14 @@
+set(range 1 2 3 4 5 6 7 8 9 10)
+set(aargs "")
+set(bargs "")
+foreach(n IN LISTS range)
+ set(aval "${A${n}ARG}")
+ set(bval "${B${n}ARG}")
+ if(aval OR bval)
+ list(APPEND aargs "\"${aval}\"")
+ list(APPEND bargs "\"${bval}\"")
+ endif()
+endforeach()
+if(NOT "${aargs}" STREQUAL "${bargs}")
+ message(FATAL_ERROR "COMPARE_OPTIONS: \n\t${aargs} != \n\t${bargs}")
+endif()