find_path(
  GMOCK_INCLUDE_DIR
  NAMES
  gmock
  PATHS
  include)

find_path(
  GTEST_INCLUDE_DIR
  NAMES
  gtest
  PATHS
  include)

SET(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})

find_library(
  GTEST_LIBRARY
  NAMES
  gtest
  libgtest
  PATHS
  lib
  )

find_library(
  GMOCK_LIBRARY
  NAMES
  gmock
  libgmock
  PATHS
  lib)

find_library(
  GMOCK_MAIN_LIBRARIES
  NAMES
  gmock_main
  libgmock_main
  PATHS
  lib)

SET(GMOCK_LIBRARIES ${GMOCK_LIBRARY} ${GTEST_LIBRARY})

SET(GMOCK_BOTH_LIBRARIES ${GMOCK_MAIN_LIBRARIES} ${GMOCK_LIBRARIES})

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(GMOCK REQUIRED_VARS GMOCK_INCLUDE_DIR GTEST_INCLUDE_DIR GMOCK_INCLUDE_DIRS GTEST_LIBRARY GMOCK_LIBRARY GMOCK_LIBRARIES GMOCK_MAIN_LIBRARIES GMOCK_BOTH_LIBRARIES)

if(NOT TARGET GTest::GTest)
    find_package(Threads)

    add_library(GTest::GTest INTERFACE IMPORTED)
    set_property(TARGET GTest::GTest PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS})
    set_property(TARGET GTest::GTest PROPERTY INTERFACE_LINK_LIBRARIES ${GTEST_LIBRARIES} Threads::Threads)
    set_property(TARGET GTest::GTest PROPERTY INTERFACE_COMPILE_DEFINITIONS ${CONAN_COMPILE_DEFINITIONS_GTEST})
endif()

if(NOT TARGET GTest::Main)
    add_library(GTest::Main INTERFACE IMPORTED)
    set_property(TARGET GTest::Main PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS})
    set_property(TARGET GTest::Main PROPERTY INTERFACE_LINK_LIBRARIES ${GTEST_MAIN_LIBRARIES})
    set_property(TARGET GTest::Main PROPERTY INTERFACE_COMPILE_DEFINITIONS ${CONAN_COMPILE_DEFINITIONS_GTEST})
endif()

if(NOT TARGET GMock::GMock)
    add_library(GMock::GMock INTERFACE IMPORTED)
    set_property(TARGET GMock::GMock PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GMOCK_INCLUDE_DIRS})
    set_property(TARGET GMock::GMock PROPERTY INTERFACE_LINK_LIBRARIES ${GMOCK_LIBRARIES} GTest::GTest)
endif()

if(NOT TARGET GMock::Main)
    add_library(GMock::Main INTERFACE IMPORTED)
    set_property(TARGET GMock::Main PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GMOCK_INCLUDE_DIRS})
    set_property(TARGET GMock::Main PROPERTY INTERFACE_LINK_LIBRARIES ${GMOCK_MAIN_LIBRARIES} GMock::GMock)
endif()
