If labels are found on the tests, then print a time summary for all the tests run...
[cmake.git] / Modules / FindGTest.cmake
blob30e67d349a58ba6d36acaea1c03020876035379b
1 # Locate the Google C++ Testing Framework.
3 # Defines the following variables:
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()
10 # Accepts the following CMake/Environment variables as input:
12 #   GTEST_ROOT - The root directory of the gtest install prefix
15 # Copyright (c) 2009, Philip Lowman <philip@yhbt.com>
17 # Redistribution AND use is allowed according to the terms of the New
18 # BSD license.
19 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
21 find_path(GTEST_INCLUDE_DIR gtest/gtest.h
22     HINTS
23         $ENV{GTEST_ROOT}/include
24         ${GTEST_ROOT}/include
27 function(_gtest_find_library _name _library)
28    find_library(${_name} ${_library}
29       HINTS
30          $ENV{GTEST_ROOT}
31          ${GTEST_ROOT}
32       PATH_SUFFIXES lib64 lib
33    )
34 endfunction()
36 _gtest_find_library(GTEST_LIBRARY gtest)
37 _gtest_find_library(GTEST_LIBRARY_DEBUG gtestd)
38 _gtest_find_library(GTEST_MAIN_LIBRARY gtest_main)
39 _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind)
41 mark_as_advanced(GTEST_INCLUDE_DIR)
42 mark_as_advanced(GTEST_LIBRARY)
43 mark_as_advanced(GTEST_LIBRARY_DEBUG)
44 mark_as_advanced(GTEST_MAIN_LIBRARY)
45 mark_as_advanced(GTEST_MAIN_LIBRARY_DEBUG)
47 include(FindPackageHandleStandardArgs)
48 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTEST DEFAULT_MSG GTEST_INCLUDE_DIR GTEST_LIBRARY GTEST_MAIN_LIBRARY)
50 set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
52 # Have *_LIBRARIES contain debug/release keywords if DEBUG library is available
54 if(GTEST_LIBRARY AND GTEST_LIBRARY_DEBUG)
55    set(GTEST_LIBRARIES
56          optimized ${GTEST_LIBRARY}
57          debug ${GTEST_LIBRARY_DEBUG})
58 else()
59    set(GTEST_LIBRARIES ${GTEST_LIBRARY})
60 endif()
62 if(GTEST_MAIN_LIBRARY AND GTEST_MAIN_LIBRARY_DEBUG)
63    set(GTEST_MAIN_LIBRARIES
64          optimized ${GTEST_MAIN_LIBRARY}
65          debug ${GTEST_MAIN_LIBRARY_DEBUG})
66 else()
67    set(GTEST_MAIN_LIBRARIES ${GTEST_MAIN_LIBRARY})
68 endif()