aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--cmake/FindTcmalloc.cmake38
-rw-r--r--examples/CMakeLists.txt8
3 files changed, 48 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c0dcbf..539da23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 2.8)
project (crow_all)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
+find_package(Tcmalloc)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
diff --git a/cmake/FindTcmalloc.cmake b/cmake/FindTcmalloc.cmake
new file mode 100644
index 0000000..6ec479d
--- /dev/null
+++ b/cmake/FindTcmalloc.cmake
@@ -0,0 +1,38 @@
+# - Find Tcmalloc
+# Find the native Tcmalloc library
+#
+# Tcmalloc_LIBRARIES - List of libraries when using Tcmalloc.
+# Tcmalloc_FOUND - True if Tcmalloc found.
+
+if (USE_TCMALLOC)
+ set(Tcmalloc_NAMES tcmalloc)
+else ()
+ set(Tcmalloc_NAMES tcmalloc_minimal tcmalloc)
+endif ()
+
+find_library(Tcmalloc_LIBRARY NO_DEFAULT_PATH
+ NAMES ${Tcmalloc_NAMES}
+ PATHS ${HT_DEPENDENCY_LIB_DIR} /lib /usr/lib /usr/local/lib /opt/local/lib
+)
+
+if (Tcmalloc_LIBRARY)
+ set(Tcmalloc_FOUND TRUE)
+ set( Tcmalloc_LIBRARIES ${Tcmalloc_LIBRARY} )
+else ()
+ set(Tcmalloc_FOUND FALSE)
+ set( Tcmalloc_LIBRARIES )
+endif ()
+
+if (Tcmalloc_FOUND)
+ message(STATUS "Found Tcmalloc: ${Tcmalloc_LIBRARY}")
+else ()
+ message(STATUS "Not Found Tcmalloc: ${Tcmalloc_LIBRARY}")
+ if (Tcmalloc_FIND_REQUIRED)
+ message(STATUS "Looked for Tcmalloc libraries named ${Tcmalloc_NAMES}.")
+ message(FATAL_ERROR "Could NOT find Tcmalloc library")
+ endif ()
+endif ()
+
+mark_as_advanced(
+ Tcmalloc_LIBRARY
+ )
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 031cc04..0c3d9bd 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -4,6 +4,11 @@ project (crow_examples)
add_executable(example example.cpp)
#target_link_libraries(example crow)
target_link_libraries(example ${Boost_LIBRARIES} )
+
+if (Tcmalloc_FOUND)
+target_link_libraries(example ${Tcmalloc_LIBRARIES})
+endif(Tcmalloc_FOUND)
+
add_custom_command(OUTPUT example_test.py
COMMAND ${CMAKE_COMMAND} -E
copy ${PROJECT_SOURCE_DIR}/example_test.py ${CMAKE_CURRENT_BINARY_DIR}/example_test.py
@@ -20,3 +25,6 @@ add_custom_command(OUTPUT example_chat.html
DEPENDS ${PROJECT_SOURCE_DIR}/example_chat.html
)
add_custom_target(example_chat_copy ALL DEPENDS example_chat.html)
+
+SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -pg" )
+SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g -pg" )