From d40deef278b209bfb143b3f78dd02d6d1d20a562 Mon Sep 17 00:00:00 2001 From: craffael Date: Fri, 29 Oct 2021 12:26:11 +0200 Subject: [PATCH 1/6] Add package tcmalloc --- cmake/configs/default.cmake | 1 + cmake/projects/tcmalloc/hunter.cmake | 24 +++++++++++++++++++++++ docs/packages/pkg/tcmalloc.rst | 29 ++++++++++++++++++++++++++++ examples/tcmalloc/CMakeLists.txt | 18 +++++++++++++++++ examples/tcmalloc/boo.cpp | 6 ++++++ 5 files changed, 78 insertions(+) create mode 100644 cmake/projects/tcmalloc/hunter.cmake create mode 100644 docs/packages/pkg/tcmalloc.rst create mode 100644 examples/tcmalloc/CMakeLists.txt create mode 100644 examples/tcmalloc/boo.cpp diff --git a/cmake/configs/default.cmake b/cmake/configs/default.cmake index 3d8f374f4b..dc472a4dfe 100644 --- a/cmake/configs/default.cmake +++ b/cmake/configs/default.cmake @@ -530,6 +530,7 @@ hunter_default_version(tacopie VERSION 3.2.0-h1) hunter_default_version(taocpp-json VERSION 1.0.0-beta.11-e0895587) hunter_default_version(taskflow VERSION 3.0.0-9e50cf2) hunter_default_version(tcl VERSION core8.6.8) +hunter_default_version(tcmalloc VERSION 0.0.0-bc7995b-p0) hunter_default_version(termcolor VERSION 1.0.1) hunter_default_version(tf VERSION 1.12.0-p0) hunter_default_version(tf2 VERSION 0.6.5-p0) diff --git a/cmake/projects/tcmalloc/hunter.cmake b/cmake/projects/tcmalloc/hunter.cmake new file mode 100644 index 0000000000..131215fc5d --- /dev/null +++ b/cmake/projects/tcmalloc/hunter.cmake @@ -0,0 +1,24 @@ +# Copyright (c) 2016-2020, Rahul Sheth, Ruslan Baratov +# All rights reserved. + +# !!! DO NOT PLACE HEADER GUARDS HERE !!! + +include(hunter_add_version) +include(hunter_cacheable) +include(hunter_download) +include(hunter_pick_scheme) + +hunter_add_version( + PACKAGE_NAME + tcmalloc + VERSION + "0.0.0-bc7995b-p0" + URL + "https://github.com/craffael/tcmalloc/archive/0.0.0-bc7995b-p0.tar.gz" + SHA1 + 297cb2eba7e30c9a9639141372ee51c544143780 +) + +hunter_pick_scheme(DEFAULT url_sha1_cmake) +hunter_cacheable(tcmalloc) +hunter_download(PACKAGE_NAME tcmalloc) diff --git a/docs/packages/pkg/tcmalloc.rst b/docs/packages/pkg/tcmalloc.rst new file mode 100644 index 0000000000..facdb1e066 --- /dev/null +++ b/docs/packages/pkg/tcmalloc.rst @@ -0,0 +1,29 @@ +.. spelling:: + + tcmalloc + +.. index:: + single: unsorted ; tcmalloc + +.. _pkg.tcmalloc: + +tcmalloc +======== + +- `Official `__ +- `Hunterized `__ +- `Example `__ +- Added by `Raffael Casagrande `__ (`pr-N `__) + +.. literalinclude:: /../examples/tcmalloc/CMakeLists.txt + :language: cmake + :start-after: # DOCUMENTATION_START { + :end-before: # DOCUMENTATION_END } + +.. note:: + + * Because tcmalloc must be linked as an object library (:code:`alwayslink` in bazel) it is recommended to use Cmake 3.21. + See the corresponding note on ``__ + * Because tcmalloc requires at least C++17 and because it depends on `abseil `__, it is important to make sure that abseil is also built with C++17. + Otherwise you may get link time errors related to :code:`std::basic_string_view`. + The easiest way to achieve this is to use a :code:`CMAKE_TOOLCHAIN_FILE` that sets :code:`CMAKE_CXX_STANDARD` to :code:`17` or higher. \ No newline at end of file diff --git a/examples/tcmalloc/CMakeLists.txt b/examples/tcmalloc/CMakeLists.txt new file mode 100644 index 0000000000..c7c1a2d3f9 --- /dev/null +++ b/examples/tcmalloc/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2016-2020, Rahul Sheth, Ruslan Baratov +# All rights reserved. + +cmake_minimum_required(VERSION 3.2) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(download-tcmalloc) + +# DOCUMENTATION_START { +hunter_add_package(tcmalloc) +find_package(tcmalloc CONFIG REQUIRED) + +add_executable(boo boo.cpp) +target_link_libraries(boo PUBLIC tcmalloc::tcmalloc) +# DOCUMENTATION_END } diff --git a/examples/tcmalloc/boo.cpp b/examples/tcmalloc/boo.cpp new file mode 100644 index 0000000000..c80a129585 --- /dev/null +++ b/examples/tcmalloc/boo.cpp @@ -0,0 +1,6 @@ +#include +#include + +int main() { + std::cout << tcmalloc::MallocExtension::GetStats() << std::endl; +} From a928715bc6dd75e073ddd385f7027fcad1fe0645 Mon Sep 17 00:00:00 2001 From: craffael Date: Fri, 29 Oct 2021 12:28:01 +0200 Subject: [PATCH 2/6] trigger github action --- cmake/projects/tcmalloc/hunter.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/projects/tcmalloc/hunter.cmake b/cmake/projects/tcmalloc/hunter.cmake index 131215fc5d..8c93f9161d 100644 --- a/cmake/projects/tcmalloc/hunter.cmake +++ b/cmake/projects/tcmalloc/hunter.cmake @@ -19,6 +19,7 @@ hunter_add_version( 297cb2eba7e30c9a9639141372ee51c544143780 ) + hunter_pick_scheme(DEFAULT url_sha1_cmake) hunter_cacheable(tcmalloc) hunter_download(PACKAGE_NAME tcmalloc) From 11e9d33afec52a9b7afc0a8e8a181303fe278a89 Mon Sep 17 00:00:00 2001 From: craffael Date: Tue, 2 Nov 2021 08:29:42 +0100 Subject: [PATCH 3/6] update tcmalloc --- cmake/projects/tcmalloc/hunter.cmake | 2 +- docs/packages/pkg/tcmalloc.rst | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/projects/tcmalloc/hunter.cmake b/cmake/projects/tcmalloc/hunter.cmake index 8c93f9161d..48edcdc6be 100644 --- a/cmake/projects/tcmalloc/hunter.cmake +++ b/cmake/projects/tcmalloc/hunter.cmake @@ -16,7 +16,7 @@ hunter_add_version( URL "https://github.com/craffael/tcmalloc/archive/0.0.0-bc7995b-p0.tar.gz" SHA1 - 297cb2eba7e30c9a9639141372ee51c544143780 + f42e1fec0ff66f3cb51648cc644efe3600b1b9f1 ) diff --git a/docs/packages/pkg/tcmalloc.rst b/docs/packages/pkg/tcmalloc.rst index facdb1e066..d4ad2eb004 100644 --- a/docs/packages/pkg/tcmalloc.rst +++ b/docs/packages/pkg/tcmalloc.rst @@ -1,6 +1,8 @@ .. spelling:: tcmalloc + CMake + bazel .. index:: single: unsorted ; tcmalloc @@ -22,7 +24,7 @@ tcmalloc .. note:: - * Because tcmalloc must be linked as an object library (:code:`alwayslink` in bazel) it is recommended to use Cmake 3.21. + * Because tcmalloc must be linked as an object library (:code:`alwayslink` in bazel) it is require to use at least CMake 3.21. See the corresponding note on ``__ * Because tcmalloc requires at least C++17 and because it depends on `abseil `__, it is important to make sure that abseil is also built with C++17. Otherwise you may get link time errors related to :code:`std::basic_string_view`. From 2d0687d7a6641afbd27e4f0e788f6b1ec6e23a9f Mon Sep 17 00:00:00 2001 From: craffael Date: Fri, 26 Nov 2021 22:54:01 +0100 Subject: [PATCH 4/6] switch to cpp-pm/tcmalloc repository --- cmake/projects/tcmalloc/hunter.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/projects/tcmalloc/hunter.cmake b/cmake/projects/tcmalloc/hunter.cmake index 48edcdc6be..caecb382de 100644 --- a/cmake/projects/tcmalloc/hunter.cmake +++ b/cmake/projects/tcmalloc/hunter.cmake @@ -14,7 +14,7 @@ hunter_add_version( VERSION "0.0.0-bc7995b-p0" URL - "https://github.com/craffael/tcmalloc/archive/0.0.0-bc7995b-p0.tar.gz" + "https://github.com/cpp-pm/tcmalloc/archive/0.0.0-bc7995b-p0.tar.gz" SHA1 f42e1fec0ff66f3cb51648cc644efe3600b1b9f1 ) From 578ee244bccb131dfbc7866ac6f5696b3aaeb2b6 Mon Sep 17 00:00:00 2001 From: craffael Date: Fri, 26 Nov 2021 23:39:21 +0100 Subject: [PATCH 5/6] update pull request number --- docs/packages/pkg/tcmalloc.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/packages/pkg/tcmalloc.rst b/docs/packages/pkg/tcmalloc.rst index d4ad2eb004..234a2b4c7b 100644 --- a/docs/packages/pkg/tcmalloc.rst +++ b/docs/packages/pkg/tcmalloc.rst @@ -15,7 +15,7 @@ tcmalloc - `Official `__ - `Hunterized `__ - `Example `__ -- Added by `Raffael Casagrande `__ (`pr-N `__) +- Added by `Raffael Casagrande `__ (`pr-493 `__) .. literalinclude:: /../examples/tcmalloc/CMakeLists.txt :language: cmake @@ -28,4 +28,4 @@ tcmalloc See the corresponding note on ``__ * Because tcmalloc requires at least C++17 and because it depends on `abseil `__, it is important to make sure that abseil is also built with C++17. Otherwise you may get link time errors related to :code:`std::basic_string_view`. - The easiest way to achieve this is to use a :code:`CMAKE_TOOLCHAIN_FILE` that sets :code:`CMAKE_CXX_STANDARD` to :code:`17` or higher. \ No newline at end of file + The easiest way to achieve this is to use a :code:`CMAKE_TOOLCHAIN_FILE` that sets :code:`CMAKE_CXX_STANDARD` to :code:`17` or higher. From 2147be5d62cb2a71dfe52f0641f29a9d0c9d986b Mon Sep 17 00:00:00 2001 From: NeroBurner Date: Mon, 2 Jun 2025 08:43:25 +0200 Subject: [PATCH 6/6] tcmalloc: require CMake 3.10, update copyright --- examples/tcmalloc/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tcmalloc/CMakeLists.txt b/examples/tcmalloc/CMakeLists.txt index c7c1a2d3f9..179a963fa6 100644 --- a/examples/tcmalloc/CMakeLists.txt +++ b/examples/tcmalloc/CMakeLists.txt @@ -1,7 +1,7 @@ -# Copyright (c) 2016-2020, Rahul Sheth, Ruslan Baratov +# Copyright (c) 2022, Raffael Casagrande # All rights reserved. -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.10) # Emulate HunterGate: # * https://github.com/hunter-packages/gate