#This function loads a variable libvar with all the static libraries found in a folder

function(get_libraries libdir libname libvar)
    file(GLOB static_files "${libdir}/*.a")
    file(GLOB shared_files "${libdir}/*.so")
    set(localvar "")
    foreach(file ${static_files})
        get_filename_component(filename ${file} NAME)
        if(${filename} MATCHES "${libname}")
            set(localvar ${localvar} ${file})
        endif()
    endforeach()
    foreach(file ${shared_files})
        get_filename_component(filename ${file} NAME)
        if(${filename} MATCHES "${libname}")
            set(localvar ${localvar} ${file})
        endif()
    endforeach()
    set(${libvar} ${localvar} ${${libvar}} PARENT_SCOPE)
endfunction()