diff options
author | Brad King <brad.king@kitware.com> | 2017-01-17 14:04:50 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2017-01-17 14:04:50 (GMT) |
commit | aa63ab6d3e7bf320f17a5364a596355e3ab976e0 (patch) | |
tree | 96a77958dda05beadf4c18f89cf52a77ac76d4b4 /Tests | |
parent | 020cba316bb3a4d33da5108ab10d2c06b4712427 (diff) | |
parent | 7c8ab7ddc8944152a1344c43acbb8c57fa2d398a (diff) | |
download | CMake-aa63ab6d3e7bf320f17a5364a596355e3ab976e0.zip CMake-aa63ab6d3e7bf320f17a5364a596355e3ab976e0.tar.gz CMake-aa63ab6d3e7bf320f17a5364a596355e3ab976e0.tar.bz2 |
Merge topic 'expand_custom_commands'
7c8ab7dd add_custom_{command,target}: Add COMMAND_EXPAND_LISTS option
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CustomCommand/CMakeLists.txt | 21 | ||||
-rw-r--r-- | Tests/CustomCommand/compare_options.cmake | 14 |
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() |