if(WIN32)
    if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
        if(NOT EXISTS ${CMAKE_SOURCE_DIR}/ThirdParty/MSVC/lib/x86/SDL2.lib)
            set(MyURL "https://www.libsdl.org/release/SDL2-devel-2.0.12-VC.zip")
            set(Download_Path ${CMAKE_SOURCE_DIR}/ThirdParty/temp/SDL2.zip)
            set(Extracted ${CMAKE_SOURCE_DIR}/ThirdParty/MSVC)
            message(STATUS "Downloading SDL2 to " ${Download_Path})
            file(DOWNLOAD ${MyURL} ${Download_Path})
            message(STATUS "Extracting SDL2 to " ${Extracted})
            execute_process(COMMAND mkdir ${Extracted})
            execute_process(COMMAND powershell Expand-Archive -Path ${Download_Path} -DestinationPath ${CMAKE_SOURCE_DIR}/ThirdParty/temp/)
            execute_process(COMMAND cp -r ${CMAKE_SOURCE_DIR}/ThirdParty/temp/SDL2-2.0.12/* ${Extracted}/)
            execute_process(COMMAND rm -r ${CMAKE_SOURCE_DIR}/ThirdParty/temp)
        endif()
        set(SDL2_INCLUDE_DIRS ${PREFIX}/MSVC/include)
        if(CMAKE_SIZEOF_VOID_P EQUAL 4)
            set(SDL2_LIBRARIES ${PREFIX}/MSVC/lib/x86/SDL2.lib)
        elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
            set(SDL2_LIBRARIES ${PREFIX}/MSVC/lib/x64/SDL2.lib)
        endif()
    elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
        if(NOT EXISTS ${CMAKE_SOURCE_DIR}/ThirdParty/x86/lib/libSDL2.a)
            set(MyURL "https://www.libsdl.org/release/SDL2-devel-2.0.12-mingw.tar.gz")
            set(Download_Path ${CMAKE_SOURCE_DIR}/ThirdParty/temp/SDL2.tar.gz)
            set(Extracted ${CMAKE_SOURCE_DIR}/ThirdParty/x86/)        
            message(STATUS "Downloading SDL2 to " ${Download_Path})
            file(DOWNLOAD ${MyURL} ${Download_Path})
            message(STATUS "Extracting SDL2 to " ${Extracted})
            execute_process(COMMAND mkdir ${Extracted})
            execute_process(COMMAND tar xvzf ${Download_Path} -C ${CMAKE_SOURCE_DIR}/ThirdParty/temp/)
            execute_process(COMMAND cp -r ${CMAKE_SOURCE_DIR}/ThirdParty/temp/SDL2-2.0.12/i686-w64-mingw32/* ${Extracted}/)
            set(Extracted ${CMAKE_SOURCE_DIR}/ThirdParty/x64/)
            execute_process(COMMAND cp -r ${CMAKE_SOURCE_DIR}/ThirdParty/temp/SDL2-2.0.12/x86_64-w64-mingw32/* ${Extracted}/)
            execute_process(COMMAND rm -r ${CMAKE_SOURCE_DIR}/ThirdParty/temp)
        endif()
        if(CMAKE_SIZEOF_VOID_P EQUAL 4)
            set(SDL2_LIBRARIES ${PREFIX}/x86/lib/libSDL2.a)
            set(SDL2_INCLUDE_DIRS ${PREFIX}/x86/include/SDL2)
        elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
            set(SDL2_LIBRARIES ${PREFIX}/x64/lib/libSDL2.a)
            set(SDL2_INCLUDE_DIRS ${PREFIX}/x64/include/SDL2)
        endif()
    endif()  
endif()