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..caecb382de --- /dev/null +++ b/cmake/projects/tcmalloc/hunter.cmake @@ -0,0 +1,25 @@ +# 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/cpp-pm/tcmalloc/archive/0.0.0-bc7995b-p0.tar.gz" + SHA1 + f42e1fec0ff66f3cb51648cc644efe3600b1b9f1 +) + + +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..234a2b4c7b --- /dev/null +++ b/docs/packages/pkg/tcmalloc.rst @@ -0,0 +1,31 @@ +.. spelling:: + + tcmalloc + CMake + bazel + +.. index:: + single: unsorted ; tcmalloc + +.. _pkg.tcmalloc: + +tcmalloc +======== + +- `Official `__ +- `Hunterized `__ +- `Example `__ +- Added by `Raffael Casagrande `__ (`pr-493 `__) + +.. 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 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`. + 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. 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; +}