CMake: Add clean target for DAPS specs
This commit is contained in:
@@ -211,6 +211,7 @@ add_custom_command(TARGET salmanoff POST_BUILD
|
|||||||
|
|
||||||
# Add all registered DAPSS targets as dependencies
|
# Add all registered DAPSS targets as dependencies
|
||||||
add_all_daps_dependencies()
|
add_all_daps_dependencies()
|
||||||
|
add_daps_clean_target()
|
||||||
|
|
||||||
# Add tests if enabled
|
# Add tests if enabled
|
||||||
if(ENABLE_TESTS)
|
if(ENABLE_TESTS)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
# add_daps_target(target_name SOURCES file1.dapss file2.dapss ...)
|
# add_daps_target(target_name SOURCES file1.dapss file2.dapss ...)
|
||||||
# register_daps_target(target_name) # In subdirectories
|
# register_daps_target(target_name) # In subdirectories
|
||||||
# add_all_daps_dependencies() # In main CMakeLists.txt
|
# 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:
|
# Examples:
|
||||||
# add_daps_target(device_specs SOURCES devices/avia0.dapss devices/win0.dapss)
|
# add_daps_target(device_specs SOURCES devices/avia0.dapss devices/win0.dapss)
|
||||||
@@ -78,6 +80,10 @@ function(add_daps_target target_name)
|
|||||||
)
|
)
|
||||||
endforeach()
|
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
|
# Create custom target that depends on all output files
|
||||||
add_custom_target(${target_name} DEPENDS ${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")
|
message(STATUS "No DAPSS targets registered for dependency addition")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user