Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add package tcmalloc #493

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions cmake/projects/tcmalloc/hunter.cmake
Original file line number Diff line number Diff line change
@@ -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)
31 changes: 31 additions & 0 deletions docs/packages/pkg/tcmalloc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. spelling::

tcmalloc
CMake
bazel

.. index::
single: unsorted ; tcmalloc

.. _pkg.tcmalloc:

tcmalloc
========

- `Official <https://github.com/google/tcmalloc>`__
- `Hunterized <https://github.com/cpp-pm/tcmalloc>`__
- `Example <https://github.com/cpp-pm/hunter/blob/master/examples/tcmalloc/CMakeLists.txt>`__
- Added by `Raffael Casagrande <https://github.com/craffael>`__ (`pr-493 <https://github.com/cpp-pm/hunter/pull/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 `<https://cmake.org/cmake/help/latest/command/target_link_libraries.html#linking-object-libraries-via-target-objects>`__
* Because tcmalloc requires at least C++17 and because it depends on `abseil <https://github.com/abseil/abseil-cpp>`__, 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.
18 changes: 18 additions & 0 deletions examples/tcmalloc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 }
6 changes: 6 additions & 0 deletions examples/tcmalloc/boo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <tcmalloc/malloc_extension.h>
#include <iostream>

int main() {
std::cout << tcmalloc::MallocExtension::GetStats() << std::endl;
}