MACRO(SOURCE_GROUP_BY_PATH)
    FOREACH(filename ${ARGV})
        GET_FILENAME_COMPONENT(path "${filename}" REALPATH)
        FILE(RELATIVE_PATH path ${PROJECT_SOURCE_DIR} ${path})
        GET_FILENAME_COMPONENT(path "${path}" PATH)
        string(REPLACE "/" "\\" path "${path}")
        IF(${filename} MATCHES "ui_|cxx$")
            SOURCE_GROUP("generated" FILES ${filename})
        ELSEIF(${filename} MATCHES "h$|hpp$|cpp$|c$|py$|fx$|ogsfx$|fxh$|ogsfh$")
            SOURCE_GROUP("${path}" FILES ${filename})
        ENDIF()
    ENDFOREACH()
ENDMACRO(SOURCE_GROUP_BY_PATH)