summaryrefslogtreecommitdiffstats
path: root/Tests/MakeClean
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-08-26 10:48:27 (GMT)
committerBrad King <brad.king@kitware.com>2019-08-26 13:31:03 (GMT)
commitd040f3f1eee237ca8cb35d7055a348a7c06fa572 (patch)
treee5dd5eaf8b1b63790a868630bd92b57e354e061a /Tests/MakeClean
parent3ed8cffe73755f5267340d5b0abe8cb4e108e822 (diff)
downloadCMake-d040f3f1eee237ca8cb35d7055a348a7c06fa572.zip
CMake-d040f3f1eee237ca8cb35d7055a348a7c06fa572.tar.gz
CMake-d040f3f1eee237ca8cb35d7055a348a7c06fa572.tar.bz2
Tests: Extend MakeClean test to test various target types
This extends the MakeClean test to test the target property `ADDITIONAL_CLEAN_FILES` on executable, library and custom targets.
Diffstat (limited to 'Tests/MakeClean')
-rw-r--r--Tests/MakeClean/ToClean/CMakeLists.txt86
1 files changed, 49 insertions, 37 deletions
diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt
index 6f16d12..a05c38b 100644
--- a/Tests/MakeClean/ToClean/CMakeLists.txt
+++ b/Tests/MakeClean/ToClean/CMakeLists.txt
@@ -15,42 +15,45 @@ function(writeCleanFile FILENAME)
file(WRITE "${FILENAME}" ${CLEAN_FILE_CONTENT})
endfunction()
+set(DUMMY_CONTENT_FILE ${CSD}/toclean.cxx)
+
# Build a simple project whose compiled objects should be cleaned.
add_executable(toclean toclean.cxx)
-addCleanFile("${CBD}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}")
+addCleanFile(
+ "${CBD}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}")
-# Create a post build custom command that copies the toclean output executable
+# Create a post build custom command that copies a dummy file
# to a custom location
-function(addToCleanPostBuildCopy FILENAME)
- add_custom_command(TARGET toclean POST_BUILD
+function(addPostBuildFile TARGET FILENAME)
+ add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND}
- ARGS -E copy $<TARGET_FILE:toclean> ${FILENAME})
+ ARGS -E copy ${DUMMY_CONTENT_FILE} ${FILENAME})
endfunction()
# Create a custom command whose output should be cleaned.
set(CustomCommandFile "${CBD}/CustomCommandFile.txt")
add_custom_command(OUTPUT ${CustomCommandFile}
- DEPENDS ${CSD}/toclean.cxx
+ DEPENDS ${DUMMY_CONTENT_FILE}
COMMAND ${CMAKE_COMMAND}
- ARGS -E copy ${CSD}/toclean.cxx ${CustomCommandFile})
-add_custom_target(generate ALL DEPENDS ${CustomCommandFile})
+ ARGS -E copy ${DUMMY_CONTENT_FILE} ${CustomCommandFile})
+add_custom_target(customTarget ALL DEPENDS ${CustomCommandFile})
addCleanFile(${CustomCommandFile})
### Tests ADDITIONAL_MAKE_CLEAN_FILES directory property
if("${CMAKE_GENERATOR}" MATCHES "Makefile")
# Create a file that must be registered for cleaning.
- set(MakeDirPropFile "${CBD}/MakeDirPropFile.txt")
- writeCleanFile("${MakeDirPropFile}")
- set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MakeDirPropFile}")
- addCleanFile(${MakeDirPropFile})
+ set(MakeDirPropFileAbs "${CBD}/MakeDirPropFile.txt")
+ writeCleanFile("${MakeDirPropFileAbs}")
+ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MakeDirPropFileAbs}")
+ addCleanFile(${MakeDirPropFileAbs})
# Create a custom command whose output should be cleaned, but whose name
# is not known until generate-time
set(MakeDirPropExpFileRel "MakeDirProp_copy${CMAKE_EXECUTABLE_SUFFIX}")
- set(MakeDirPropExpFile "$<TARGET_FILE_DIR:toclean>/${MakeDirPropExpFileRel}")
- addToCleanPostBuildCopy("${MakeDirPropExpFile}")
- set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${MakeDirPropExpFile})
+ set(MakeDirPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${MakeDirPropExpFileRel}")
+ addPostBuildFile(toclean "${MakeDirPropExpFileAbs}")
+ set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${MakeDirPropExpFileAbs})
addCleanFile("${CBD}/${MakeDirPropExpFileRel}")
endif()
@@ -72,34 +75,43 @@ addCleanFile("${DirPropFileAbs}")
# Create a custom command whose output should be cleaned, but whose name
# is not known until generate-time
set(DirPropExpFileRel "DirProp_copy${CMAKE_EXECUTABLE_SUFFIX}")
-set(DirPropExpFile "$<TARGET_FILE_DIR:toclean>/${DirPropExpFileRel}")
-addToCleanPostBuildCopy("${DirPropExpFile}")
-set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropExpFile})
+set(DirPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${DirPropExpFileRel}")
+addPostBuildFile(toclean "${DirPropExpFileAbs}")
+set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropExpFileAbs})
addCleanFile("${CBD}/${DirPropExpFileRel}")
### Tests ADDITIONAL_CLEAN_FILES target property
-# Register a file path relative to the build directory
-set(TgtPropFileRel "TargetPropFileRel.txt")
-writeCleanFile("${CBD}/${TgtPropFileRel}")
-set_target_properties(toclean PROPERTIES ADDITIONAL_CLEAN_FILES ${TgtPropFileRel})
-addCleanFile("${CBD}/${TgtPropFileRel}")
-
-# Register an absolute file path
-set(TgtPropFileAbs "${CBD}/TargetPropFileAbs.txt")
-writeCleanFile("${TgtPropFileAbs}")
-set_property(TARGET toclean APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropFileAbs})
-addCleanFile("${TgtPropFileAbs}")
-
-# Create a custom command whose output should be cleaned, but whose name
-# is not known until generate-time
-set(TgtPropExpFileRel "TgtProp_copy${CMAKE_EXECUTABLE_SUFFIX}")
-set(TgtPropExpFile "$<TARGET_FILE_DIR:toclean>/${TgtPropExpFileRel}")
-addToCleanPostBuildCopy("${TgtPropExpFile}")
-set_property(TARGET toclean APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropExpFile})
-addCleanFile("${CBD}/${TgtPropExpFileRel}")
+function(test_target_property TARGET)
+ # Register a file path relative to the build directory
+ set(TgtPropFileRel "${TARGET}_TargetPropFileRel.txt")
+ writeCleanFile("${CBD}/${TgtPropFileRel}")
+ set_target_properties(${TARGET} PROPERTIES ADDITIONAL_CLEAN_FILES ${TgtPropFileRel})
+ addCleanFile("${CBD}/${TgtPropFileRel}")
+
+ # Register an absolute file path
+ set(TgtPropFileAbs "${CBD}/${TARGET}_TargetPropFileAbs.txt")
+ writeCleanFile("${TgtPropFileAbs}")
+ set_property(TARGET ${TARGET} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropFileAbs})
+ addCleanFile("${TgtPropFileAbs}")
+
+ # Create a custom command whose output should be cleaned, but whose name
+ # is not known until generate-time
+ set(TgtPropExpFileRel "${TARGET}_TargetPropGenExp.txt")
+ set(TgtPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${TgtPropExpFileRel}")
+ addPostBuildFile(${TARGET} "${TgtPropExpFileAbs}")
+ set_property(TARGET ${TARGET} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropExpFileAbs})
+ addCleanFile("${CBD}/${TgtPropExpFileRel}")
+endfunction()
+# Test target property for various target types
+add_executable(acf_exec toclean.cxx)
+test_target_property(acf_exec)
+add_library(acf_lib toclean.cxx)
+test_target_property(acf_lib)
+add_custom_target(acf_custom ALL DEPENDS ${CustomCommandFile})
+test_target_property(acf_custom)
# Process subdirectory without targets
add_subdirectory(EmptySubDir)