summaryrefslogtreecommitdiffstats
path: root/Tests/MakeClean
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-08-27 22:20:29 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-08-27 22:49:29 (GMT)
commitd26594f39073ce08eaa0ebab2f85d09c8673668c (patch)
tree527b0c46674c8767d3125e8ac13cf33eca3a6ac8 /Tests/MakeClean
parentb15ad0d1de7524be3b32d6691b68d3578ee00ca5 (diff)
downloadCMake-d26594f39073ce08eaa0ebab2f85d09c8673668c.zip
CMake-d26594f39073ce08eaa0ebab2f85d09c8673668c.tar.gz
CMake-d26594f39073ce08eaa0ebab2f85d09c8673668c.tar.bz2
Genex: Evaluate genexes for additional make clean files.
This is necessary because custom commands and targets may create custom files whose names are determined by generator expressions. For example, clang should be using $<TARGET_FILE> and $<TARGET_FILE_DIR> instead of reverse engineering the output file name: http://thread.gmane.org/gmane.comp.compilers.clang.scm/80523 However, that can only be done when ADDITIONAL_MAKE_CLEAN_FILES also accepts and evaluates generator expressions. Similarly, KDE uses the LOCATION property where $<TARGET_FILE> would also be better in KDE4_HANDLE_RPATH_FOR_EXECUTABLE but also appends the result to ADDITIONAL_MAKE_CLEAN_FILES. After this patch, both can be ported to generator expressions.
Diffstat (limited to 'Tests/MakeClean')
-rw-r--r--Tests/MakeClean/ToClean/CMakeLists.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt
index 28569dd..37d7292 100644
--- a/Tests/MakeClean/ToClean/CMakeLists.txt
+++ b/Tests/MakeClean/ToClean/CMakeLists.txt
@@ -26,6 +26,18 @@ add_custom_command(OUTPUT ${ToClean_BINARY_DIR}/generated.txt
add_custom_target(generate ALL DEPENDS ${ToClean_BINARY_DIR}/generated.txt)
set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/generated.txt")
+# Create a custom command whose output should be cleaned, but whose name
+# is not known until generate-time
+set(copied_exe "$<TARGET_FILE_DIR:toclean>/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}")
+add_custom_command(TARGET toclean POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy $<TARGET_FILE:toclean>
+ ${copied_exe}
+ )
+set_property(DIRECTORY APPEND PROPERTY
+ ADDITIONAL_MAKE_CLEAN_FILES ${copied_exe})
+list(APPEND TOCLEAN_FILES "${ToClean_BINARY_DIR}/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}")
+
# Configure a file listing these build-time-generated files.
configure_file(${ToClean_SOURCE_DIR}/ToCleanFiles.cmake.in
${ToClean_BINARY_DIR}/ToCleanFiles.cmake @ONLY IMMEDIATE)