if(NOT SHADERC_CORE_LIBRARY)
  find_path(SHADERC_CORE_INCLUDE_DIR "shaderc/shaderc.hpp")
  find_library(SHADERC_CORE_LIBRARY_DEBUG
    NAMES
      shadercd  # Windows
      shaderc  # Arch Linux
    PATH_SUFFIXES
      lib
  )
  find_library(SHADERC_CORE_LIBRARY_RELEASE
    NAMES
      shaderc  # Arch Linux and Windows
    PATH_SUFFIXES
      lib
  )
  set(SHADERC_CORE_LIBRARY
    debug ${SHADERC_CORE_LIBRARY_DEBUG}
    optimized ${SHADERC_CORE_LIBRARY_RELEASE}
  )
endif()

FIND_PACKAGE_HANDLE_STANDARD_ARGS(SHADERC_CORE REQUIRED_VARS
  SHADERC_CORE_LIBRARY SHADERC_CORE_INCLUDE_DIR)

mark_as_advanced(SHADERC_CORE_INCLUDE_DIRS)
mark_as_advanced(SHADERC_CORE_LIBRARIES)

if(SHADERC_CORE_FOUND)
  set(SHADERC_CORE_INCLUDE_DIRS ${SHADERC_CORE_INCLUDE_DIR})
  set(SHADERC_CORE_LIBRARIES ${SHADERC_CORE_LIBRARY})

  if(NOT TARGET ShaderC::core)
    add_library(ShaderC::core UNKNOWN IMPORTED)
    set_target_properties(ShaderC::core PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${SHADERC_CORE_INCLUDE_DIRS}")

    set_property(TARGET ShaderC::core APPEND PROPERTY
      IMPORTED_CONFIGURATIONS RELEASE)
    set_property(TARGET ShaderC::core APPEND PROPERTY
      IMPORTED_CONFIGURATIONS DEBUG)

    if(SHADERC_CORE_LIBRARY_DEBUG AND SHADERC_CORE_LIBRARY_RELEASE)
      set_target_properties(ShaderC::core PROPERTIES
        IMPORTED_LOCATION_DEBUG "${SHADERC_CORE_LIBRARY_DEBUG}"
        IMPORTED_LOCATION_RELEASE "${SHADERC_CORE_LIBRARY_RELEASE}"
      )
    else()
      set_target_properties(ShaderC::core PROPERTIES
        IMPORTED_LOCATION "${SHADERC_CORE_LIBRARY_RELEASE}"
      )
    endif()
  endif()
endif()

################################################################################

if(NOT SHADERC_COMBINED_LIBRARY)
  find_path(SHADERC_COMBINED_INCLUDE_DIR "shaderc/shaderc.hpp")
  find_library(SHADERC_COMBINED_LIBRARY_DEBUG
    NAMES
      shaderc_combinedd  # Windows
      shaderc_combined  # Arch Linux
    PATH_SUFFIXES
      lib
  )
  find_library(SHADERC_COMBINED_LIBRARY_RELEASE
    NAMES
      shaderc_combined  # Arch Linux and Windows
    PATH_SUFFIXES
      lib
  )
  set(SHADERC_COMBINED_LIBRARY
    debug ${SHADERC_COMBINED_LIBRARY_DEBUG}
    optimized ${SHADERC_COMBINED_LIBRARY_RELEASE}
  )
endif()

FIND_PACKAGE_HANDLE_STANDARD_ARGS(SHADERC_COMBINED REQUIRED_VARS
  SHADERC_COMBINED_LIBRARY SHADERC_COMBINED_INCLUDE_DIR)

mark_as_advanced(SHADERC_COMBINED_INCLUDE_DIRS)
mark_as_advanced(SHADERC_COMBINED_LIBRARIES)

if(SHADERC_COMBINED_FOUND)
  set(SHADERC_COMBINED_INCLUDE_DIRS ${SHADERC_COMBINED_INCLUDE_DIR})
  set(SHADERC_COMBINED_LIBRARIES ${SHADERC_COMBINED_LIBRARY})

  if(NOT TARGET ShaderC::combined)
    add_library(ShaderC::combined UNKNOWN IMPORTED)
    set_target_properties(ShaderC::combined PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${SHADERC_COMBINED_INCLUDE_DIRS}")

    set_property(TARGET ShaderC::combined APPEND PROPERTY
      IMPORTED_CONFIGURATIONS RELEASE)
    set_property(TARGET ShaderC::combined APPEND PROPERTY
      IMPORTED_CONFIGURATIONS DEBUG)

    if(SHADERC_COMBINED_LIBRARY_DEBUG AND SHADERC_COMBINED_LIBRARY_RELEASE)
      set_target_properties(ShaderC::combined PROPERTIES
        IMPORTED_LOCATION_DEBUG "${SHADERC_COMBINED_LIBRARY_DEBUG}"
        IMPORTED_LOCATION_RELEASE "${SHADERC_COMBINED_LIBRARY_RELEASE}"
      )
    else()
      set_target_properties(ShaderC::combined PROPERTIES
        IMPORTED_LOCATION "${SHADERC_COMBINED_LIBRARY_RELEASE}"
      )
    endif()
  endif()
endif()
