Browse Source

Cmake 增加perftools profile类的检查

tanghai 14 years ago
parent
commit
c3b44642a8
2 changed files with 17 additions and 5 deletions
  1. 7 2
      Cpp/CMakeLists.txt
  2. 10 3
      Cpp/Cmake/FindPerftools.cmake

+ 7 - 2
Cpp/CMakeLists.txt

@@ -5,9 +5,10 @@ SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
 
 PROJECT(Cpp)
 
-OPTION(BUILD_TESTS "Decide if the test suite shall be built or not" ON)
+OPTION(TESTS "Decide if the test suite shall be built or not" ON)
+OPTION(PROFILE "Use Google Perftool Profile" OFF)
 
-IF(BUILD_TESTS)
+IF(TESTS)
 	ENABLE_TESTING()
 ENDIF()
 
@@ -54,5 +55,9 @@ set(ThirdPartyLibs
 	${PERFTOOLS_DEBUG_LIBRARIES}
 )
 
+IF(PROFILE)
+    set(ThirdPartyLibs ${ThirdPartyLibs} ${PERFTOOLS_PROFILE_LIBRARIES})
+ENDIF()
+
 ADD_SUBDIRECTORY(Platform)
 ADD_SUBDIRECTORY(Game)

+ 10 - 3
Cpp/Cmake/FindPerftools.cmake

@@ -14,14 +14,21 @@ ENDIF()
 FIND_LIBRARY(PERFTOOLS_LIBRARY NAMES tcmalloc
 			DOC "The Google Perftools Library"
 			)
-			
-MARK_AS_ADVANCED(PERFTOOLS_INCLUDE_DIR PERFTOOLS_DEBUG_LIBRARIE PERFTOOLS_LIBRARIE)
+
+FIND_LIBRARY(PERFTOOLS_PROFILE_LIBRARY NAMES profiler
+			DOC "The Google Perftools Profile Library"
+			)
+
+MARK_AS_ADVANCED(PERFTOOLS_INCLUDE_DIR PERFTOOLS_DEBUG_LIBRARY PERFTOOLS_LIBRARY PERFTOOLS_PROFILE_LIBRARY)
 
 INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PERFTOOLS DEFAULT_MSG PERFTOOLS_INCLUDE_DIR PERFTOOLS_DEBUG_LIBRARY PERFTOOLS_LIBRARY)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PERFTOOLS DEFAULT_MSG 
+    PERFTOOLS_LIBRARY PERFTOOLS_DEBUG_LIBRARY PERFTOOLS_PROFILE_LIBRARY 
+    PERFTOOLS_INCLUDE_DIR)
 
 IF(PERFTOOLS_FOUND)
 	SET(PERFTOOLS_INCLUDE_DIRS ${PERFTOOLS_INCLUDE_DIR})
 	SET(PERFTOOLS_DEBUG_LIBRARIES ${PERFTOOLS_DEBUG_LIBRARY})
 	SET(PERFTOOLS_LIBRARIES ${PERFTOOLS_LIBRARY})
+	SET(PERFTOOLS_PROFILE_LIBRARIES ${PERFTOOLS_PROFILE_LIBRARY})
 ENDIF()