FindGTest.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Locate the Google C++ Testing Framework.
  2. #
  3. # Defines the following variables:
  4. #
  5. # GTEST_FOUND - Found the Google Testing framework
  6. # GTEST_INCLUDE_DIRS - Include directories
  7. # GTEST_LIBRARIES - The GTest library
  8. # GTEST_MAIN_LIBRARIES - The GTest library for automatic main()
  9. #
  10. # Accepts the following CMake/Environment variables as input:
  11. #
  12. # GTEST_ROOT - The root directory of the gtest install prefix
  13. #
  14. #=============================================================================
  15. # Copyright 2009 Kitware, Inc.
  16. # Copyright 2009 Philip Lowman <[email protected]>
  17. #
  18. # Distributed under the OSI-approved BSD License (the "License");
  19. # see accompanying file Copyright.txt for details.
  20. #
  21. # This software is distributed WITHOUT ANY WARRANTY; without even the
  22. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  23. # See the License for more information.
  24. #=============================================================================
  25. # (To distributed this file outside of CMake, substitute the full
  26. # License text for the above reference.)
  27. find_path(GTEST_INCLUDE_DIR gtest/gtest.h
  28. HINTS
  29. $ENV{GTEST_ROOT}/include
  30. ${GTEST_ROOT}/include
  31. )
  32. function(_gtest_find_library _name _library)
  33. find_library(${_name} ${_library}
  34. HINTS
  35. $ENV{GTEST_ROOT}
  36. ${GTEST_ROOT}
  37. PATH_SUFFIXES lib64 lib
  38. )
  39. endfunction()
  40. _gtest_find_library(GTEST_LIBRARY gtest)
  41. _gtest_find_library(GTEST_LIBRARY_DEBUG gtestd)
  42. _gtest_find_library(GTEST_MAIN_LIBRARY gtest_main)
  43. _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind)
  44. mark_as_advanced(GTEST_INCLUDE_DIR)
  45. mark_as_advanced(GTEST_LIBRARY)
  46. mark_as_advanced(GTEST_LIBRARY_DEBUG)
  47. mark_as_advanced(GTEST_MAIN_LIBRARY)
  48. mark_as_advanced(GTEST_MAIN_LIBRARY_DEBUG)
  49. include(FindPackageHandleStandardArgs)
  50. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTEST DEFAULT_MSG GTEST_INCLUDE_DIR GTEST_LIBRARY GTEST_MAIN_LIBRARY)
  51. set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
  52. # Have *_LIBRARIES contain debug/release keywords if DEBUG library is available
  53. if(GTEST_LIBRARY AND GTEST_LIBRARY_DEBUG)
  54. set(GTEST_LIBRARIES
  55. optimized ${GTEST_LIBRARY}
  56. debug ${GTEST_LIBRARY_DEBUG})
  57. else()
  58. set(GTEST_LIBRARIES ${GTEST_LIBRARY})
  59. endif()
  60. if(GTEST_MAIN_LIBRARY AND GTEST_MAIN_LIBRARY_DEBUG)
  61. set(GTEST_MAIN_LIBRARIES
  62. optimized ${GTEST_MAIN_LIBRARY}
  63. debug ${GTEST_MAIN_LIBRARY_DEBUG})
  64. else()
  65. set(GTEST_MAIN_LIBRARIES ${GTEST_MAIN_LIBRARY})
  66. endif()