From 4df259da85d77f06ea69ca50d03f08077df86ba7 Mon Sep 17 00:00:00 2001
From: Claudio Bisegni <Claudio.Bisegni@lnf.infn.it>
Date: Thu, 21 Jun 2018 22:46:26 +0200
Subject: [PATCH] readd google gpt external project

---
 CMakeLists.txt        |  6 ++----
 config/CMakeChaos.txt | 47 +++++++++++++++++++++++++++++--------------
 2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff326dbdc..ccc42f016 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,7 @@
 cmake_minimum_required(VERSION 2.8)
-
-include(config/CMakeChaos.txt)
 project(chaosframework)
-include(ExternalProject)
+include(config/CMakeChaos.txt)
+#include(ExternalProject)
 #include(CTest)
 #find git
 find_package(Git REQUIRED)
@@ -14,7 +13,6 @@ unset(CMAKE_CXX_COMPILER_WORKS)
 #specify option
 option(CHAOS_ONLY_DEPENDECY "Download all the dependency" OFF)
 option(CHAOS_ARCHITECTURE_TEST "Architecture tests" OFF)
-option(USE_GPT "Uses Google Performance tool to perform analisys" OFF)
 option(CLING_VIRTUAL_MACHINE_ENABLE "Enable cling for scripting" OFF)
 option(CHAOS_CDS "Chaos Data Service" ON)
 option(CHAOS_MDS "Chaos MetaData Service" ON)
diff --git a/config/CMakeChaos.txt b/config/CMakeChaos.txt
index 3b6f62eaa..ad5221d1d 100644
--- a/config/CMakeChaos.txt
+++ b/config/CMakeChaos.txt
@@ -1,5 +1,6 @@
 cmake_minimum_required(VERSION 2.8)
 include(${CMAKE_CURRENT_LIST_DIR}/CMakeMacroUtils.txt)
+include(ExternalProject)
 
   ### options and configuration variables ####
 
@@ -33,6 +34,7 @@ ENDIF()
 
   ENDIF()
 
+ option(USE_GPT "Uses Google Performance tool to perform analisys" OFF)
   option(CHAOS_FORCE32 "Set to ON to enable 32 bit compilation" OFF)
   option(CHAOS_STATIC "Set static compilation" OFF)
   option(ENABLE_MEMCACHE "Enable Memcacahe" OFF)
@@ -58,6 +60,7 @@ ENDIF()
   ADD_DEFINITIONS(-DCSLIB_VERSION_MINOR="${CHAOS_VERSION_MINOR}")
   ADD_DEFINITIONS(-DCSLIB_BUILD_ID=${CHAOS_BUILD_ID})
 
+
   if(CMAKE_BUILD_TYPE MATCHES PROFILE)
      MESG("ENABLING PROFILE")
      set (CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage")
@@ -141,9 +144,6 @@ ENDIF()
   ENDIF()
 
 
-
-
-
   IF (CHAOS_TARGET)
 
     IF(${CHAOS_TARGET} MATCHES "armhf")
@@ -207,9 +207,9 @@ ENDIF()
     IF(NOT CMAKE_CXX_COMPILER)
       project(config)
     ENDIF()
-    
+
     if(CHAOS_BOOST_DYNAMIC)
-      SET(CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -DBOOST_LOG_DYN_LINK") 
+      SET(CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -DBOOST_LOG_DYN_LINK")
       SET(CHAOS_BOOST_FLAGS ${CHAOS_BOOST_FLAGS} link=shared runtime-link=shared)
     ELSE()
       SET(CHAOS_BOOST_FLAGS ${CHAOS_BOOST_FLAGS} link=static runtime-link=static)
@@ -218,7 +218,7 @@ ENDIF()
       SET(CHAOS_BOOST_FLAGS ${CHAOS_BOOST_FLAGS} linkflags=\""${CHAOS_LINKER_FLAGS}"\")
     ENDIF()
 
-    
+
 #  SET(CHAOS_BOOST_FLAGS ${CHAOS_BOOST_FLAGS} cxxflags=\""${CHAOS_CXX_FLAGS} ${BOOST_CXX_ADDITIONAL_FLAGS}"\" --prefix=${CMAKE_INSTALL_PREFIX} --with-program_options --with-exception --with-chrono --with-filesystem --with-log --with-regex --with-random --with-system --with-thread --with-atomic --with-timer install "-j ${PROCESSOR_COUNT}" )
   SET(CHAOS_BOOST_FLAGS ${CHAOS_BOOST_FLAGS} cxxflags=\""${CHAOS_CXX_FLAGS}"\" --prefix=${CMAKE_INSTALL_PREFIX} --with-program_options --with-exception --with-chrono --with-filesystem --with-log --with-regex --with-random --with-system --with-thread --with-atomic --with-timer install "-j ${PROCESSOR_COUNT}" )
 
@@ -299,13 +299,6 @@ ENDIF()
   #set(FrameworkLib $ENV{CHAOS_LINK_LIBRARY})
   #separate_arguments(FrameworkLib)
 
-
-
-
-
-
-
-
   INCLUDE_DIRECTORIES(. ${PROJECT_SOURCE_DIR} ${CMAKE_INSTALL_PREFIX}/include)
   LINK_DIRECTORIES(${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_INSTALL_PREFIX}/lib)
 
@@ -323,8 +316,6 @@ ENDIF()
   #   ENDIF()
   # ENDFOREACH()
 
-
-
   IF (DEFINED PROJECT_NAME)
     FILE(GLOB conf_src conf/*)
     FILE(GLOB perf_src perf/*)
@@ -379,3 +370,29 @@ ENDIF()
 
   endif()
 
+  IF (USE_GPT)
+      #google performance tools
+      MESG("Add Google Performance Tools as external project")
+      ExternalProject_Add(
+      google_pt
+      GIT_REPOSITORY https://github.com/gperftools/gperftools.git
+      GIT_TAG master
+      PREFIX "${CMAKE_BINARY_DIR}/ext_dep/gpt-prefix"
+      SOURCE_DIR "${CMAKE_BINARY_DIR}/ext_dep/gpt-src"
+      BINARY_DIR "${CMAKE_BINARY_DIR}/ext_dep/gpt-src"
+      CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ext_dep/gpt-src/./autogen.sh COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/ext_dep/gpt-src/./configure --prefix=${CMAKE_INSTALL_PREFIX}
+      LOG_DOWNLOAD ON
+      LOG_CONFIGURE ON
+      LOG_BUILD ON)
+
+      # Specify include dir
+      ExternalProject_Get_Property(google_pt source_dir)
+      set(GPT_INCLUDE_DIR ${google_pt_sdir}/include)
+
+      # Library
+      ExternalProject_Get_Property(google_pt binary_dir)
+      set(GPT_LIBRARY_DIR ${google_pt_bdir})
+
+      MESG("${GPT_INCLUDE_DIR}")
+      MESG("${GPT_LIBRARY_DIR}")
+  ENDIF()
-- 
GitLab