CMake: Add clean target for DAPS specs

This commit is contained in:
2026-04-18 15:05:16 -04:00
parent 27a5d48451
commit 66dc227d31
2 changed files with 37 additions and 0 deletions
+1
View File
@@ -211,6 +211,7 @@ add_custom_command(TARGET salmanoff POST_BUILD
# Add all registered DAPSS targets as dependencies
add_all_daps_dependencies()
add_daps_clean_target()
# Add tests if enabled
if(ENABLE_TESTS)
+36
View File
@@ -6,6 +6,8 @@
# add_daps_target(target_name SOURCES file1.dapss file2.dapss ...)
# register_daps_target(target_name) # In subdirectories
# add_all_daps_dependencies() # In main CMakeLists.txt
# add_daps_clean_target() # Optional: clean_daps_specs removes
# all .daps outputs from add_daps_target.
#
# Examples:
# add_daps_target(device_specs SOURCES devices/avia0.dapss devices/win0.dapss)
@@ -78,6 +80,10 @@ function(add_daps_target target_name)
)
endforeach()
get_property(_daps_all_outputs GLOBAL PROPERTY DAPS_ALL_OUTPUT_FILES)
list(APPEND _daps_all_outputs ${output_files})
set_property(GLOBAL PROPERTY DAPS_ALL_OUTPUT_FILES "${_daps_all_outputs}")
# Create custom target that depends on all output files
add_custom_target(${target_name} DEPENDS ${output_files})
@@ -151,3 +157,33 @@ function(add_all_daps_dependencies)
message(STATUS "No DAPSS targets registered for dependency addition")
endif()
endfunction()
# Custom target that deletes every generated .daps file from add_daps_target (all subdirs).
# Usage: add_daps_clean_target([NAME clean_daps_specs])
# Call once from the top-level CMakeLists.txt after every add_subdirectory that uses DAPSS.
function(add_daps_clean_target)
set(options)
set(oneValueArgs NAME)
set(multiValueArgs)
cmake_parse_arguments(DC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(DC_NAME)
set(_daps_clean_target ${DC_NAME})
else()
set(_daps_clean_target clean_daps_specs)
endif()
if(TARGET ${_daps_clean_target})
message(FATAL_ERROR "add_daps_clean_target: target '${_daps_clean_target}' already exists")
endif()
get_property(_daps_clean_files GLOBAL PROPERTY DAPS_ALL_OUTPUT_FILES)
if(_daps_clean_files)
add_custom_target(${_daps_clean_target}
COMMAND ${CMAKE_COMMAND} -E rm -f ${_daps_clean_files}
COMMENT "Removing generated .daps specification files"
)
else()
add_custom_target(${_daps_clean_target})
endif()
endfunction()