find_package(PkgConfig QUIET)

if (PKG_CONFIG_FOUND)
    pkg_search_module(GLFW REQUIRED glfw3)
    if (GLFW_FOUND)
        message(STATUS "Found GLFW")
    else ()
        message(STATUS "GLFW not found! Trying to download and build from the source.")
        include(DownloadGLFW)
    endif ()
else ()
    message(STATUS "pkg-config is not available! Try to use Pixar module to find GLFW.")
    find_package(GLFW 3.2 QUIET)

    if (GLFW_FOUND)
        message(STATUS "Found GLFW")
    else ()
        message(STATUS "GLFW not found! Trying to download and build from the source.")
        include(DownloadGLFW)
    endif ()
endif ()    
