1
0
Fork 0

Improve finding gperftools and disable profiling by default (even with gperftools installed)

This commit is contained in:
Thomas Geymayer 2012-11-19 13:10:38 +01:00
parent 379e7a2fd5
commit 82884ab3c6
3 changed files with 43 additions and 61 deletions

View file

@ -105,7 +105,7 @@ option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM (default
option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" ${EVENT_INPUT_DEFAULT}) option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" ${EVENT_INPUT_DEFAULT})
option(ENABLE_LIBSVN "Set to ON to build FlightGear/terrasync with libsvnclient support (default)" ON) option(ENABLE_LIBSVN "Set to ON to build FlightGear/terrasync with libsvnclient support (default)" ON)
option(ENABLE_RTI "Set to ON to build FlightGear with RTI support" OFF) option(ENABLE_RTI "Set to ON to build FlightGear with RTI support" OFF)
option(ENABLE_PROFILE "Set to ON to build FlightGear with gperftools profiling support" ON) option(ENABLE_PROFILE "Set to ON to build FlightGear with gperftools profiling support" OFF)
option(JPEG_FACTORY "Set to ON to build FlightGear with JPEG-factory support" OFF) option(JPEG_FACTORY "Set to ON to build FlightGear with JPEG-factory support" OFF)
option(SYSTEM_SQLITE "Set to ON to build FlightGear with the system's SQLite3 library" OFF) option(SYSTEM_SQLITE "Set to ON to build FlightGear with the system's SQLite3 library" OFF)
@ -225,10 +225,9 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(windows.h HAVE_WINDOWS_H) check_include_file(windows.h HAVE_WINDOWS_H)
if(ENABLE_PROFILE) if(ENABLE_PROFILE)
find_package(GooglePerfTools) find_package(GooglePerfTools REQUIRED)
if(GOOGLE_PERFTOOLS_FOUND) set(FG_HAVE_GPERFTOOLS 1)
set(FG_HAVE_GPERFTOOLS 1) message(STATUS "Built-in profiler using gperftools available")
endif()
endif() endif()
if(ENABLE_RTI) if(ENABLE_RTI)

View file

@ -1,66 +1,48 @@
# -*- cmake -*- # - Try to find GooglePerfTools headers and libraries
#
# Usage of this module as follows:
#
# find_package(GooglePerfTools)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# GooglePerfTools_ROOT_DIR Set this variable to the root installation of
# GooglePerfTools if the module has problems finding
# the proper installation path.
#
# Variables defined by this module:
#
# GooglePerfTools_FOUND System has GooglePerfTools libs/headers
# GooglePerfTools_LIBRARIES The GooglePerfTools libraries
# GooglePerfTools_INCLUDE_DIR The location of GooglePerfTools headers
# - Find Google perftools find_path(GooglePerfTools_ROOT_DIR
# Find the Google perftools includes and libraries NAMES include/google/profiler.h
# This module defines
# GOOGLE_PERFTOOLS_INCLUDE_DIR, where to find heap-profiler.h, etc.
# GOOGLE_PERFTOOLS_FOUND, If false, do not try to use Google perftools.
# also defined for general use are
# TCMALLOC_LIBRARIES, where to find the tcmalloc library.
# STACKTRACE_LIBRARIES, where to find the stacktrace library.
# PROFILER_LIBRARIES, where to find the profiler library.
FIND_PATH(GOOGLE_PERFTOOLS_INCLUDE_DIR google/heap-profiler.h
/usr/local/include
/usr/include
) )
SET(TCMALLOC_NAMES ${TCMALLOC_NAMES} tcmalloc_and_profiler) find_path(GooglePerfTools_INCLUDE_DIR
FIND_LIBRARY(TCMALLOC_LIBRARY NAMES google/profiler.h
NAMES ${TCMALLOC_NAMES} HINTS ${GooglePerfTools_ROOT_DIR}
PATHS /usr/lib /usr/local/lib
) )
IF (TCMALLOC_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR) find_library(GooglePerfTools_PROFILER_LIBRARY
SET(TCMALLOC_LIBRARIES ${TCMALLOC_LIBRARY}) NAMES profiler
SET(GOOGLE_PERFTOOLS_FOUND "YES") HINTS ${GooglePerfTools_ROOT_DIR}
ELSE (TCMALLOC_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR)
SET(GOOGLE_PERFTOOLS_FOUND "NO")
ENDIF (TCMALLOC_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR)
SET(STACKTRACE_NAMES ${STACKTRACE_NAMES} stacktrace)
FIND_LIBRARY(STACKTRACE_LIBRARY
NAMES ${STACKTRACE_LIBRARY}
PATHS /usr/lib /usr/local/lib
) )
IF (STACKTRACE_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR) set(GooglePerfTools_LIBRARIES ${GooglePerfTools_PROFILER_LIBRARY})
SET(STACKTRACE_LIBRARIES ${STACKTRACE_LIBRARY})
ENDIF (STACKTRACE_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR)
SET(PROFILER_NAMES ${PROFILER_NAMES} profiler) include(FindPackageHandleStandardArgs)
FIND_LIBRARY(PROFILER_LIBRARY find_package_handle_standard_args(GooglePerfTools
NAMES ${PROFILER_LIBRARY} "Try setting GooglePerfTools_ROOT_DIR to root of your gperftools installation"
PATHS /usr/lib /usr/local/lib GooglePerfTools_LIBRARIES
GooglePerfTools_INCLUDE_DIR
) )
IF (PROFILER_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR) mark_as_advanced(
SET(PROFILER_LIBRARIES ${PROFILER_LIBRARY}) GooglePerfTools_ROOT_DIR
ENDIF (PROFILER_LIBRARY AND GOOGLE_PERFTOOLS_INCLUDE_DIR) GooglePerfTools_LIBRARIES
GooglePerfTools_PROFILER_LIBRARY
IF (GOOGLE_PERFTOOLS_FOUND) GooglePerfTools_INCLUDE_DIR
IF (NOT GOOGLE_PERFTOOLS_FIND_QUIETLY)
MESSAGE(STATUS "Found Google perftools: ${GOOGLE_PERFTOOLS_LIBRARIES}")
ENDIF (NOT GOOGLE_PERFTOOLS_FIND_QUIETLY)
ELSE (GOOGLE_PERFTOOLS_FOUND)
IF (GOOGLE_PERFTOOLS_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Google perftools library")
ENDIF (GOOGLE_PERFTOOLS_FIND_REQUIRED)
ENDIF (GOOGLE_PERFTOOLS_FOUND)
MARK_AS_ADVANCED(
TCMALLOC_LIBRARY
STACKTRACE_LIBRARY
PROFILER_LIBRARY
GOOGLE_PERFTOOLS_INCLUDE_DIR
) )

View file

@ -91,7 +91,8 @@ if(ENABLE_JSBSIM)
endif() endif()
if(FG_HAVE_GPERFTOOLS) if(FG_HAVE_GPERFTOOLS)
target_link_libraries(fgfs profiler tcmalloc) include_directories(${GooglePerfTools_INCLUDE_DIR})
target_link_libraries(fgfs ${GooglePerfTools_LIBRARIES})
endif() endif()
target_link_libraries(fgfs target_link_libraries(fgfs