summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/add_custom_command
diff options
context:
space:
mode:
authorPeter Würth <wuerth.peter@freenet.de>2022-11-18 11:29:47 (GMT)
committerPeter Würth <wuerth.peter@freenet.de>2022-11-19 12:32:56 (GMT)
commit26d813092bffdcda77976ab5ba59c114e3e2fda5 (patch)
tree13704e2e7a4ca069d7ff331fece81150929bd580 /Tests/RunCMake/add_custom_command
parent60a5a39022c8c2504173d635732110b2550b7f91 (diff)
downloadCMake-26d813092bffdcda77976ab5ba59c114e3e2fda5.zip
CMake-26d813092bffdcda77976ab5ba59c114e3e2fda5.tar.gz
CMake-26d813092bffdcda77976ab5ba59c114e3e2fda5.tar.bz2
add_custom_{command,target}: add genex support for COMMENT
Evaluate and expand generator expressions in the `COMMENT` argument of the `add_custom_command()` and `add_custom_target()` commands. This allows to include generator expressions, e.g. a targets location $<TARGET_...> or the current configuration $<CONFIG>, in the build-time messages. Fixes #22507
Diffstat (limited to 'Tests/RunCMake/add_custom_command')
-rw-r--r--Tests/RunCMake/add_custom_command/CommentGenex-build-stdout.txt1
-rw-r--r--Tests/RunCMake/add_custom_command/CommentGenex.cmake9
-rw-r--r--Tests/RunCMake/add_custom_command/RunCMakeTest.cmake9
3 files changed, 19 insertions, 0 deletions
diff --git a/Tests/RunCMake/add_custom_command/CommentGenex-build-stdout.txt b/Tests/RunCMake/add_custom_command/CommentGenex-build-stdout.txt
new file mode 100644
index 0000000..bf49657
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/CommentGenex-build-stdout.txt
@@ -0,0 +1 @@
+lorem ipsum, 01
diff --git a/Tests/RunCMake/add_custom_command/CommentGenex.cmake b/Tests/RunCMake/add_custom_command/CommentGenex.cmake
new file mode 100644
index 0000000..f517392
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/CommentGenex.cmake
@@ -0,0 +1,9 @@
+add_custom_target(helper)
+set_property(TARGET helper PROPERTY MY_TEXT "lorem ipsum")
+add_custom_command(
+ OUTPUT out.txt
+ COMMAND ${CMAKE_COMMAND} -E echo true
+ COMMENT "$<TARGET_PROPERTY:helper,MY_TEXT>$<COMMA> $<STREQUAL:foo,bar>$<EQUAL:42,42>"
+)
+set_property(SOURCE out.txt PROPERTY SYMBOLIC 1)
+add_custom_target(main ALL DEPENDS out.txt)
diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
index ad6b258..6c677c0 100644
--- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
@@ -60,3 +60,12 @@ function(test_genex name)
endfunction()
test_genex(TargetGenexEvent)
+
+if(NOT RunCMake_GENERATOR STREQUAL "Xcode")
+ block()
+ run_cmake(CommentGenex)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CommentGenex-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(CommentGenex-build ${CMAKE_COMMAND} --build .)
+ endblock()
+endif()