function(print_list)
    foreach(msg ${ARGV})
        message("${msg}")
    endforeach()
endfunction()

macro(nprune input_list pattern)
    foreach(src_file ${${input_list}})
        if(NOT ${src_file} MATCHES ${pattern})
            list(REMOVE_ITEM ${input_list} "${src_file}")
        endif()
    endforeach()
endmacro()

macro(pprune input_list pattern)
    foreach(src_file ${${input_list}})
        if(${src_file} MATCHES ${pattern})
            list(REMOVE_ITEM ${input_list} "${src_file}")
        endif()
    endforeach()
endmacro()

function(lprune_target targetname pattern)
    get_target_property(source_files "${targetname}" SOURCES)
    foreach(sourcefile ${source_files})
        get_property(defs SOURCE "${sourcefile}" PROPERTY COMPILE_DEFINITIONS)
        string(REPLACE "${pattern}" "" basename "${sourcefile}")
        list(APPEND defs "__FILENAME_CUSTOM__=\"${basename}\"")
        set_property(SOURCE "${sourcefile}" PROPERTY COMPILE_DEFINITIONS ${defs})
    endforeach()
endfunction()

macro (lprune input_list pattern)
    foreach(src_file ${${input_list}})
        list(REMOVE_ITEM ${input_list} "${src_file}")
        string(REPLACE "${pattern}" "" new_src "${src_file}")
        list(APPEND ${input_list} "${new_src}")
    endforeach()
endmacro()
