# https://github.com/forexample/package-example

# See manual:
#     * http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:CMakePackageConfigHelpers

find_package(GTest CONFIG REQUIRED PATHS @GTest_DIR@ NO_DEFAULT_PATH)
find_package(
    CppNetlibUri CONFIG REQUIRED PATHS @CppNetlibUri_DIR@ NO_DEFAULT_PATH
)

@PACKAGE_INIT@

include("@PACKAGE_CONF_DEST@/SoberTargets.cmake")

function(_apply_release_imported_config_as_default tgt)
  get_target_property(location ${tgt} IMPORTED_LOCATION_RELEASE)
  get_target_property(link ${tgt} IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE)

  if(NOT location)
    message(FATAL_ERROR "Release target `${tgt}` not installed")
  endif()

  set_target_properties(
      ${tgt}
      PROPERTIES
      IMPORTED_LOCATION "${location}"
  )
  if(link)
    set_target_properties(
        ${tgt}
        PROPERTIES
        IMPORTED_LINK_INTERFACE_LIBRARIES "${link}"
    )
  endif()
endfunction()

_apply_release_imported_config_as_default(sober)

# https://github.com/forexample/package-example

# See manual:
#     * http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:CMakePackageConfigHelpers

find_package(
    CppNetlibUri CONFIG REQUIRED PATHS @CppNetlibUri_DIR@ NO_DEFAULT_PATH
)
find_package(GTest CONFIG REQUIRED PATHS @GTest_DIR@ NO_DEFAULT_PATH)
find_package(JsonSpirit CONFIG REQUIRED PATHS @JsonSpirit_DIR@ NO_DEFAULT_PATH)

@PACKAGE_INIT@

include("@PACKAGE_CONF_DEST@/SoberTargets.cmake")

function(_apply_release_imported_config_as_default tgt)
  get_target_property(location ${tgt} IMPORTED_LOCATION_RELEASE)
  get_target_property(link ${tgt} IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE)

  if(NOT location)
    message(FATAL_ERROR "Release target `${tgt}` not installed")
  endif()

  set_target_properties(
      ${tgt}
      PROPERTIES
      IMPORTED_LOCATION "${location}"
  )
  if(link)
    set_target_properties(
        ${tgt}
        PROPERTIES
        IMPORTED_LINK_INTERFACE_LIBRARIES "${link}"
    )
  endif()
endfunction()

_apply_release_imported_config_as_default(sober)

Add find_package(JsonSpirit ...) to config
Add find_package(JsonSpirit ...) to config
