include_guard(GLOBAL)
block()
    _register_git_cmake_library(renderive::pthreads4w
            "https://github.com/GerHobbelt/pthread-win32.git"
            "v3.0.3.1"
    )
    rcl_get_effective_install_dir(renderive::pthreads4w PTHREADS4W_ROOT)
    set(PTHREADS4W_INCLUDE_DIR "${PTHREADS4W_ROOT}/include")
    if (CMAKE_BUILD_TYPE STREQUAL "Debug")
        set(PTHREADS4W_LIBRARY "${PTHREADS4W_ROOT}/lib/libpthreadVC3d.lib")
    else ()
        set(PTHREADS4W_LIBRARY "${PTHREADS4W_ROOT}/lib/libpthreadVC3.lib")
    endif ()
    set(PTHREADS4W_CONFIG_DIR "${CMAKE_CURRENT_LIST_DIR}/pthreads4w_config")
    set(pthreads4w_opts
            -DENABLE_TESTS=OFF
            "-DDLLDEST=${PTHREADS4W_ROOT}/bin"
            "-DLIBDEST=${PTHREADS4W_ROOT}/lib"
            "-DHDRDEST=${PTHREADS4W_ROOT}/include"
    )
    rcl_cmake_library_set_cmake_options(renderive::pthreads4w ${pthreads4w_opts})
    rcl_cmake_library_set_other_use_opt(renderive::pthreads4w
            "-DPThreads4W_DIR=\"${PTHREADS4W_CONFIG_DIR}\""
            "-DPThreads4W_INCLUDE_DIR=\"${PTHREADS4W_INCLUDE_DIR}\""
            "-DPThreads4W_LIBRARY=\"${PTHREADS4W_LIBRARY}\""
    )
    rcl_cmake_library_set_init_script(renderive::pthreads4w
            "set(PThreads4W_DIR \"${PTHREADS4W_CONFIG_DIR}\")"
            "set(PThreads4W_INCLUDE_DIR \"${PTHREADS4W_INCLUDE_DIR}\")"
    )
    rcl_cmake_library_set_clear_script(renderive::pthreads4w
            "unset(PThreads4W_DIR)"
            "unset(PThreads4W_INCLUDE_DIR)"
            "unset(PThreads4W_LIBRARY)"
    )
endblock()