root/trunk/cmake/FindGooglePerfTools.cmake

Revision 7, 3.2 kB (checked in by whispercastorg, 2 years ago)

version 0.2.0

Line 
1 # Copyright (c) 2009, Whispersoft s.r.l.
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 # * Neither the name of Whispersoft s.r.l. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #
30 # Finds GoolgePerfTools:
31 #   - tcmalloc
32 #   - stacktrace
33 #   - profiler
34 find_path(google_perftools_INCLUDE_DIR google/heap-profiler.h
35   /usr/local/include
36   /usr/include
37   )
38
39 # set(tcmalloc_NAMES ${tcmalloc_NAMES} tcmalloc_debug)
40 set(tcmalloc_NAMES ${tcmalloc_NAMES} tcmalloc)
41 find_library(tcmalloc_LIBRARY
42   NAMES ${tcmalloc_NAMES}
43   PATHS /usr/lib /usr/local/lib
44   )
45
46 set(stacktrace_NAMES ${stacktrace_NAMES} stacktrace)
47 find_library(stacktrace_LIBRARY
48   NAMES ${stacktrace_NAMES}
49   PATHS /usr/lib /usr/local/lib
50   )
51
52 if (stacktrace_LIBRARY AND google_perftools_INCLUDE_DIR)
53   set(stacktrace_LIBRARIES ${stacktrace_LIBRARY})
54 endif (stacktrace_LIBRARY AND google_perftools_INCLUDE_DIR)
55
56 set(profiler_NAMES ${profiler_NAMES} profiler)
57 find_library(profiler_LIBRARY
58   NAMES ${profiler_NAMES}
59   PATHS /usr/lib /usr/local/lib
60   )
61
62 if (profiler_LIBRARY AND google_perftools_INCLUDE_DIR)
63   set(profiler_LIBRARIES ${profiler_LIBRARY})
64 endif (profiler_LIBRARY AND google_perftools_INCLUDE_DIR)
65
66 if (tcmalloc_LIBRARY AND google_perftools_INCLUDE_DIR)
67   set(tcmalloc_LIBRARIES ${tcmalloc_LIBRARY})
68   set(google_perftools_FOUND TRUE)
69 else (tcmalloc_LIBRARY AND google_perftools_INCLUDE_DIR)
70   set(google_perftools_FOUND FALSE)
71 endif (tcmalloc_LIBRARY AND google_perftools_INCLUDE_DIR)
72
73 if (google_perftools_FOUND)
74   if (NOT google_perftools_FIND_QUIETLY)
75     message(STATUS "Found Google perftools: ${google_perftools_LIBRARIES}")
76   endif (NOT google_perftools_FIND_QUIETLY)
77 else (google_perftools_FOUND)
78   if (google_perftools_FIND_REQUIRED)
79     message(FATAL_ERROR "Could not find Google perftools library")
80   endif (google_perftools_FIND_REQUIRED)
81 endif (google_perftools_FOUND)
82
83 mark_as_advanced(
84   tcmalloc_LIBRARY
85   stacktrace_LIBRARY
86   profiler_LIBRARY
87   google_perftools_INCLUDE_DIR
88   )
Note: See TracBrowser for help on using the browser.