#
# 1394020320@qq.com
#

macro(GIT_DEMOS ProName)
    SET(DIRECORTY_CHECK "${CMAKE_CURRENT_SOURCE_DIR}/demos/${ProName}")
    if (NOT EXISTS ${DIRECORTY_CHECK})
        message("Git clone ${ProName}, please wait")
        EXEC_PROGRAM("git" "${CMAKE_CURRENT_SOURCE_DIR}/demos" ARGS "clone https://github.com/soui-demo/${ProName}.git")
    else()
        message("Git update ${ProName}, please wait")
        EXEC_PROGRAM("git" "${CMAKE_CURRENT_SOURCE_DIR}/demos/${ProName}" ARGS "pull")
    endif()
endmacro()

#
# 下载并编译Soui-demo中的demo
#
if (DOWNLOAD_COMPILE_DEMOS)
    message("--- Download the demos in Soui-demo")
    find_package(Git)
    if(Git_FOUND)
        message("Git found: ${GIT_EXECUTABLE}")
        GIT_DEMOS(TimDemo)
        GIT_DEMOS(UiEditor)
        GIT_DEMOS(qqlogin)
        GIT_DEMOS(360)
        GIT_DEMOS(360Preview)
        GIT_DEMOS(souispy)
        GIT_DEMOS(PcManager)
        GIT_DEMOS(SoTool)
        GIT_DEMOS(mclistview_demo)
        GIT_DEMOS(souitest)
        GIT_DEMOS(VUI)
        GIT_DEMOS(BesLyric)
        GIT_DEMOS(QQMain)
        GIT_DEMOS(FrogPlay)
        GIT_DEMOS(MultiLangs)
        GIT_DEMOS(TXMgr)
        GIT_DEMOS(SLogViewer)
        GIT_DEMOS(souieditor)
        GIT_DEMOS(DropDemo)
        GIT_DEMOS(ThreeClearGame)
        GIT_DEMOS(baiduwp)
        GIT_DEMOS(ScreenShotTool)
        GIT_DEMOS(SoftMaster)
        GIT_DEMOS(SweepingEdge)
        GIT_DEMOS(iectrl)
        GIT_DEMOS(mfc.demo)
        GIT_DEMOS(CapScreenDemo)
        GIT_DEMOS(SOUI-CEF)
        GIT_DEMOS(nsisdemo)
        GIT_DEMOS(SouiWallPaper)
        GIT_DEMOS(TczKline)
        message("Git clone Complete")
        FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/__cmake/CMakeLists.txt DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/demos/)
        ADD_SUBDIRECTORY(demos)
    else()
        message("Can't found Git, please install git first")
    endif()
endif()