navid/haze / 94d8e2a026845bd62732f6eb7c222b5a9c18a60511c534c648cee6fd4b471090 / cmake/clean_samples.cmake

clean_samples.cmake

← cmake · 637 bytes · raw · download

if(NOT DEFINED SAMPLES_DIR)
    message(FATAL_ERROR "SAMPLES_DIR is required")
endif()

file(GLOB_RECURSE sample_sources LIST_DIRECTORIES false "${SAMPLES_DIR}/*.hz")

foreach(source IN LISTS sample_sources)
    get_filename_component(directory "${source}" DIRECTORY)
    get_filename_component(stem "${source}" NAME_WE)

    foreach(extension "" ".exe" ".o" ".s" ".ssa")
        set(candidate "${directory}/${stem}${extension}")
        if(EXISTS "${candidate}" AND NOT IS_DIRECTORY "${candidate}")
            file(REMOVE "${candidate}")
            message(STATUS "Removed ${candidate}")
        endif()
    endforeach()
endforeach()