macro(plugin_output_dirs_prepare)
    set(PLUGIN_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
    set(PLUGIN_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
    set(PLUGIN_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
    if (NOT ANDROID)
        set(PLUGIN_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mgps)
        set(PLUGIN_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/mgps)
        set(PLUGIN_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/mgps)
    endif()
endmacro()

macro(set_plugin_output_directories TARGET)
    foreach(DEST RUNTIME ARCHIVE LIBRARY)
        set_target_properties(${TARGET} PROPERTIES
            ${DEST}_OUTPUT_DIRECTORY ${PLUGIN_${DEST}_OUTPUT_DIRECTORY}
            )
        foreach(BUILD_TYPE DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
        set_target_properties(${TARGET} PROPERTIES
            ${DEST}_OUTPUT_DIRECTORY_${BUILD_TYPE} ${PLUGIN_${DEST}_OUTPUT_DIRECTORY}
            )
        endforeach()
    endforeach()
endmacro()
