macro(GroupSources curdir)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
    foreach(child ${children})
        if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
            GroupSources(${curdir}/${child})
        else()
            string(REPLACE "/" "\\" groupname ${curdir})
            source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
        endif()
   endforeach()
endmacro()

MACRO(SUBDIRLIST result curdir)
  FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
  SET(dirlist "")
  FOREACH(child ${children})
    IF(IS_DIRECTORY ${curdir}/${child})
      LIST(APPEND dirlist ${child})
    ENDIF()
  ENDFOREACH()
  SET(${result} ${dirlist})
ENDMACRO()

MACRO(APPEND_BIN_DIR ARG1 ARG2)
  IF(EXISTS "${${ARG1}}" AND IS_DIRECTORY "${${ARG1}}")
    LIST(APPEND ${ARG2} ${${ARG1}})
  ELSE()
    if(RCC_VERBOSE_CONFIG)
      MESSAGE("${ARG1} : ${${ARG1}} is not a valid directory")
    endif()
  ENDIF()
ENDMACRO(APPEND_BIN_DIR)

MACRO(GENERATE_WIN_DLL_PATHS DLL_PATH_OUTPUT_VAR)
if(WIN32)
	foreach(dir ${BIN_DIRS})
		APPEND_BIN_DIR(${dir}_BIN_DIR_DBG ${DLL_PATH_OUTPUT_VAR})
		APPEND_BIN_DIR(${dir}_BIN_DIR_OPT ${DLL_PATH_OUTPUT_VAR})
		APPEND_BIN_DIR(${dir}_BIN_DIR_OPT ${DLL_PATH_OUTPUT_VAR})
		APPEND_BIN_DIR(${dir}_BIN_DIR ${DLL_PATH_OUTPUT_VAR})
		APPEND_BIN_DIR(${dir}_BIN_DIR ${DLL_PATH_OUTPUT_VAR})
		APPEND_BIN_DIR(${dir}_BIN_DIR ${DLL_PATH_OUTPUT_VAR})
	endforeach(dir ${BIN_DIRS})
	list(REMOVE_DUPLICATES ${DLL_PATH_OUTPUT_VAR})
endif()
ENDMACRO(GENERATE_WIN_DLL_PATHS)

macro(GroupSources curdir)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
    foreach(child ${children})
        if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
            GroupSources(${curdir}/${child})
        else()
            string(REPLACE "/" "\\" groupname ${curdir})
            source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
        endif()
   endforeach()
endmacro()