function(GET_CURRENT_DEP_INCLUDE_PREFIX FOLDER)
  set(INCLUDE_PREFIX)
  if(WIN32)
    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
      if(MSVC14)
        if(EXISTS "${FOLDER}/include/windows_x86_64_msvc14")
          set(INCLUDE_PREFIX "include/windows_x86_64_msvc14")
        elseif(EXISTS "${FOLDER}/include/windows_x86_64")
          set(INCLUDE_PREFIX "include/windows_x86_64")
        elseif(EXISTS "${FOLDER}/include/windows")
          set(INCLUDE_PREFIX "include/windows")
        elseif(EXISTS "${FOLDER}/include")
          set(INCLUDE_PREFIX "include")
        else()
          set(INCLUDE_PREFIX ".")
        endif()
      else()
        if(EXISTS "${FOLDER}/include/windows_x86_64")
          set(INCLUDE_PREFIX "include/windows_x86_64")
        elseif(EXISTS "${FOLDER}/include/windows")
          set(INCLUDE_PREFIX "include/windows")
        elseif(EXISTS "${FOLDER}/include")
          set(INCLUDE_PREFIX "include")
        else()
          set(INCLUDE_PREFIX ".")
        endif()
      endif()
    else()
      if(MSVC14)
        if(EXISTS "${FOLDER}/include/windows_x86_32_msvc14")
          set(INCLUDE_PREFIX "include/windows_x86_32_msvc14")
        elseif(EXISTS "${FOLDER}/include/windows_x86_32")
          set(INCLUDE_PREFIX "include/windows_x86_32")
        elseif(EXISTS "${FOLDER}/include/windows")
          set(INCLUDE_PREFIX "include/windows")
        elseif(EXISTS "${FOLDER}/include")
          set(INCLUDE_PREFIX "include")
        else()
          set(INCLUDE_PREFIX ".")
        endif()
      else()
        if(EXISTS "${FOLDER}/include/windows_x86_32")
          set(INCLUDE_PREFIX "include/windows_x86_32")
        elseif(EXISTS "${FOLDER}/include/windows")
          set(INCLUDE_PREFIX "include/windows")
        elseif(EXISTS "${FOLDER}/include")
          set(INCLUDE_PREFIX "include")
        else()
          set(INCLUDE_PREFIX ".")
        endif()
      endif()
    endif()
  elseif(APPLE)
    if(BUILD64)
      if(EXISTS "${FOLDER}/include/macos_x86_64")
        set(INCLUDE_PREFIX "include/macos_x86_64")
      elseif(EXISTS "${FOLDER}/include/macos")
        set(INCLUDE_PREFIX "include/macos")
      elseif(EXISTS "${FOLDER}/include")
        set(INCLUDE_PREFIX "include")
      else()
        set(INCLUDE_PREFIX ".")
      endif()
    else()
      if(EXISTS "${FOLDER}/include/macos_x86_32")
        set(INCLUDE_PREFIX "include/macos_x86_32")
      elseif(EXISTS "${FOLDER}/include/macos")
        set(INCLUDE_PREFIX "include/macos")
      elseif(EXISTS "${FOLDER}/include")
        set(INCLUDE_PREFIX "include")
      else()
        set(INCLUDE_PREFIX ".")
      endif()
    endif()
  else()
    if(BUILD64)
      if(EXISTS "${FOLDER}/include/linux_x86_64")
        set(INCLUDE_PREFIX "include/linux_x86_64")
      elseif(EXISTS "${FOLDER}/include/linux")
        set(INCLUDE_PREFIX "include/linux")
      elseif(EXISTS "${FOLDER}/include")
        set(INCLUDE_PREFIX "include")
      else()
        set(INCLUDE_PREFIX ".")
      endif()
    else()
      if(EXISTS "${FOLDER}/include/linux_x86_32")
        set(INCLUDE_PREFIX "include/linux_x86_32")
      elseif(EXISTS "${FOLDER}/include/linux")
        set(INCLUDE_PREFIX "include/linux")
      elseif(EXISTS "${FOLDER}/include")
        set(INCLUDE_PREFIX "include")
      else()
        set(INCLUDE_PREFIX ".")
      endif()
    endif()
  endif()
  set(CURRENT_DEP_INCLUDE_PREFIX ${CURRENT_DEP_INCLUDE_PREFIX} ${INCLUDE_PREFIX} PARENT_SCOPE)
endfunction()

function(ADD_DEP_INCLUDE_DIR FOLDER)
  GET_CURRENT_DEP_INCLUDE_PREFIX(${FOLDER})
  set(DEP_INCLUDE_DIR ${DEP_INCLUDE_DIR} "${FOLDER}/${CURRENT_DEP_INCLUDE_PREFIX}" PARENT_SCOPE)
endfunction()

function(GET_CURRENT_DEP_LIBRARY_PREFIX FOLDER)
  set(LIBRARY_PREFIX)
  if(WIN32)
    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
      if(MSVC14)
        if(EXISTS "${FOLDER}/lib/windows_x86_64_msvc14")
          set(LIBRARY_PREFIX "lib/windows_x86_64_msvc14")
        elseif(EXISTS "${FOLDER}/lib/windows_x86_64")
          set(LIBRARY_PREFIX "lib/windows_x86_64")
        elseif(EXISTS "${FOLDER}/lib/windows")
          set(LIBRARY_PREFIX "lib/windows")
        elseif(EXISTS "${FOLDER}/lib")
          set(LIBRARY_PREFIX "lib")
        else()
          set(LIBRARY_PREFIX ".")
        endif()
      else()
        if(EXISTS "${FOLDER}/lib/windows_x86_64")
          set(LIBRARY_PREFIX "lib/windows_x86_64")
        elseif(EXISTS "${FOLDER}/lib/windows")
          set(LIBRARY_PREFIX "lib/windows")
        elseif(EXISTS "${FOLDER}/lib")
          set(LIBRARY_PREFIX "lib")
        else()
          set(LIBRARY_PREFIX ".")
        endif()
      endif()
    else()
      if(MSVC14)
        if(EXISTS "${FOLDER}/lib/windows_x86_32_msvc14")
          set(LIBRARY_PREFIX "lib/windows_x86_32_msvc14")
        elseif(EXISTS "${FOLDER}/lib/windows_x86_32")
          set(LIBRARY_PREFIX "lib/windows_x86_32")
        elseif(EXISTS "${FOLDER}/lib/windows")
          set(LIBRARY_PREFIX "lib/windows")
        elseif(EXISTS "${FOLDER}/lib")
          set(LIBRARY_PREFIX "lib")
        else()
          set(LIBRARY_PREFIX ".")
        endif()
      else()
        if(EXISTS "${FOLDER}/lib/windows_x86_32")
          set(LIBRARY_PREFIX "lib/windows_x86_32")
        elseif(EXISTS "${FOLDER}/lib/windows")
          set(LIBRARY_PREFIX "lib/windows")
        elseif(EXISTS "${FOLDER}/lib")
          set(LIBRARY_PREFIX "lib")
        else()
          set(LIBRARY_PREFIX ".")
        endif()
      endif()
    endif()
  elseif(APPLE)
    if(BUILD64)
      if(EXISTS "${FOLDER}/lib/macos_x86_64")
        set(LIBRARY_PREFIX "lib/macos_x86_64")
      elseif(EXISTS "${FOLDER}/lib/macos")
        set(LIBRARY_PREFIX "lib/macos")
      elseif(EXISTS "${FOLDER}/lib")
        set(LIBRARY_PREFIX "lib")
      else()
        set(LIBRARY_PREFIX ".")
      endif()
    else()
      if(EXISTS "${FOLDER}/lib/macos_x86_32")
        set(LIBRARY_PREFIX "lib/macos_x86_32")
      elseif(EXISTS "${FOLDER}/lib/macos")
        set(LIBRARY_PREFIX "lib/macos")
      elseif(EXISTS "${FOLDER}/lib")
        set(LIBRARY_PREFIX "lib")
      else()
        set(LIBRARY_PREFIX ".")
      endif()
    endif()
  else()
    if(BUILD64)
      if(EXISTS "${FOLDER}/lib/linux_x86_64")
        set(LIBRARY_PREFIX "lib/linux_x86_64")
      elseif(EXISTS "${FOLDER}/lib/linux")
        set(LIBRARY_PREFIX "lib/linux")
      elseif(EXISTS "${FOLDER}/lib")
        set(LIBRARY_PREFIX "lib")
      else()
        set(LIBRARY_PREFIX ".")
      endif()
    else()
      if(EXISTS "${FOLDER}/lib/linux_x86_32")
        set(LIBRARY_PREFIX "lib/linux_x86_32")
      elseif(EXISTS "${FOLDER}/lib/linux")
        set(LIBRARY_PREFIX "lib/linux")
      elseif(EXISTS "${FOLDER}/lib")
        set(LIBRARY_PREFIX "lib")
      else()
        set(LIBRARY_PREFIX ".")
      endif()
    endif()
  endif()
  set(CURRENT_DEP_LIBRARY_PREFIX ${CURRENT_DEP_LIBRARY_PREFIX} ${LIBRARY_PREFIX} PARENT_SCOPE)
endfunction()

function(ADD_DEP_LIBRARY_DIR FOLDER)
  GET_CURRENT_DEP_LIBRARY_PREFIX(${FOLDER})
  set(DEP_LIBRARY_DIR ${DEP_LIBRARY_DIR} "${FOLDER}/${CURRENT_DEP_LIBRARY_PREFIX}" PARENT_SCOPE)
endfunction()
