FindGoogleMock.cmake 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#-----------------------------------------------------------------------------
# Find path
#-----------------------------------------------------------------------------
find_path(GoogleMock_INCLUDE_DIR
  NAMES
    gmock/gmock.h
  PATH_SUFFIXES
    googlemock/include
    )
mark_as_advanced(GoogleMock_INCLUDE_DIR)
list(APPEND GoogleMock_INCLUDE_DIRS ${GoogleMock_INCLUDE_DIR})

#-----------------------------------------------------------------------------
# Find library
#-----------------------------------------------------------------------------
find_library(GoogleMock_LIBRARY
  NAMES
    libgmock
    gmock
20 21
    libgmockd
    gmockd
22 23 24 25 26 27 28 29
  )
mark_as_advanced(GoogleMock_LIBRARY)
list(APPEND GoogleMock_LIBRARIES ${GoogleMock_LIBRARY})

find_library(GoogleMock_main_LIBRARY
  NAMES
    libgmock_main
    gmock_main
30 31
    libgmock_maind
    gmock_maind
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
  )
mark_as_advanced(GoogleMock_main_LIBRARY)
list(APPEND GoogleMock_LIBRARIES ${GoogleMock_main_LIBRARY})

#-----------------------------------------------------------------------------
# Find package
#-----------------------------------------------------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GoogleMock
  REQUIRED_VARS
    GoogleMock_INCLUDE_DIRS
    GoogleMock_LIBRARIES)

#-----------------------------------------------------------------------------
# If missing target, create it
#-----------------------------------------------------------------------------
if(GoogleMock_FOUND AND NOT TARGET GoogleMock)
  add_library(GoogleMock INTERFACE IMPORTED)
  set_target_properties(GoogleMock PROPERTIES
    INTERFACE_LINK_LIBRARIES "${GoogleMock_LIBRARY}"
    INTERFACE_INCLUDE_DIRECTORIES "${GoogleMock_INCLUDE_DIR}"
  )
endif()