Adds support for GPerftools. Add compiler and linker flags only if the library is available.

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@292 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2012-12-24 10:21:31 +00:00
parent d8cdb68985
commit 91feed486c
2 changed files with 72 additions and 6 deletions

View File

@ -119,18 +119,23 @@ include_directories(${GFlags_INCLUDE_DIRS})
# GPerftools - http://code.google.com/p/gperftools/ # GPerftools - http://code.google.com/p/gperftools/
################################################################################ ################################################################################
set(GCC_GPERFTOOLS_FLAGS "")
find_package(Gperftools) find_package(Gperftools)
if ( NOT Gperftools_FOUND ) if ( NOT GPERFTOOLS_FOUND )
message("GPerftools library not found!") message("The optional library GPerftools has not been found.")
else() else()
message ( "GPerftools library found" ) message ( "GPerftools library found" )
endif( NOT Gperftools_FOUND ) link_libraries(profiler tcmalloc)
endif( NOT GPERFTOOLS_FOUND )
list(APPEND CMAKE_CXX_FLAGS ${GCC_GPERFTOOLS_FLAGS})
################################################################################ ################################################################################
# Doxygen - http://www.stack.nl/~dimitri/doxygen/index.html # Doxygen - http://www.stack.nl/~dimitri/doxygen/index.html
################################################################################ ################################################################################
include(FindDoxygen) include(FindDoxygen)
IF (DOXYGEN_EXECUTABLE) IF (DOXYGEN_EXECUTABLE)
message( STATUS "Setting Doxygen Generator" ) message( STATUS "Setting Doxygen Generator" )
@ -198,6 +203,7 @@ include_directories(
${GLOG_INCLUDE_DIRS} ${GLOG_INCLUDE_DIRS}
${GFLAGS_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIRS}
${UHD_INCLUDE_DIRS} ${UHD_INCLUDE_DIRS}
${GPERFTOOLS_INCLUDE_DIRS}
) )
link_directories( link_directories(
@ -206,18 +212,26 @@ link_directories(
${GNURADIO_CORE_LIBRARY_DIRS} ${GNURADIO_CORE_LIBRARY_DIRS}
${GLOG_LIBRARY_DIRS} ${GLOG_LIBRARY_DIRS}
${GFLAGS_LIBRARY_DIRS} ${GFLAGS_LIBRARY_DIRS}
${GPERFTOOLS_LIBRARY_DIRS}
) )
list(APPEND CMAKE_CXX_FLAGS "-msse2 -msse3 -mfpmath=sse -Wall -std=c++0x") if(GPERFTOOLS_FOUND)
if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
list(APPEND CMAKE_CXX_FLAGS "-msse2 -msse3 -mfpmath=sse -Wall -std=c++0x -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")
else(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
list(APPEND CMAKE_CXX_FLAGS "-msse2 -msse3 -mfpmath=sse -Wall -std=c++0x")
endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
else(GPERFTOOLS_FOUND)
list(APPEND CMAKE_CXX_FLAGS "-msse2 -msse3 -mfpmath=sse -Wall -std=c++0x")
endif(GPERFTOOLS_FOUND)
######################################################################## ########################################################################
# Add subdirectories (in order of deps) # Add subdirectories (in order of deps)
######################################################################## ########################################################################
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(drivers) #add_subdirectory(drivers)
#add_subdirectory(firmware) #add_subdirectory(firmware)
#add_subdirectory($OSMOSDR_ROOT/include/osmosdr) #add_subdirectory($OSMOSDR_ROOT/include/osmosdr)
#add_subdirectory(${GTEST_DIR}/include) #add_subdirectory(${GTEST_DIR}/include)

View File

@ -0,0 +1,52 @@
# Tries to find Gperftools.
#
# Usage of this module as follows:
#
# find_package(Gperftools)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# Gperftools_ROOT_DIR Set this variable to the root installation of
# Gperftools if the module has problems finding
# the proper installation path.
#
# Variables defined by this module:
#
# GPERFTOOLS_FOUND System has Gperftools libs/headers
# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler)
# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers
find_library(GPERFTOOLS_TCMALLOC
NAMES tcmalloc
HINTS ${Gperftools_ROOT_DIR}/lib)
find_library(GPERFTOOLS_PROFILER
NAMES profiler
HINTS ${Gperftools_ROOT_DIR}/lib)
find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER
NAMES tcmalloc_and_profiler
HINTS ${Gperftools_ROOT_DIR}/lib)
find_path(GPERFTOOLS_INCLUDE_DIR
NAMES gperftools/heap-profiler.h
HINTS ${Gperftools_ROOT_DIR}/include)
set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Gperftools
DEFAULT_MSG
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR
)
mark_as_advanced(
Gperftools_ROOT_DIR
GPERFTOOLS_TCMALLOC
GPERFTOOLS_PROFILER
GPERFTOOLS_TCMALLOC_AND_PROFILER
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR)