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

Modern cmake #104

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Modern cmake #104

wants to merge 4 commits into from

Conversation

craffael
Copy link

@craffael craffael commented Nov 2, 2021

I don't know if you are interested in CMake support for TcMalloc. I recently had come up with this in order to use TcMalloc with the rest of my codebase and I thought you might be interested (?).

  • The setup is very similar to abseil: there is a tcmalloc_cc_library function which takes almost the same arguments as absl_cc_library
  • One difficulty was the implementation of alwayslink from bazel. I solved this by using a recent feature of CMake 3.21 (https://cmake.org/cmake/help/v3.22/command/target_link_libraries.html#linking-object-libraries-via-target-objects). Because of this CMake 3.21 or higher is required.
  • So far there is no documentation on how to use CMake. If you are interested, I can add this?
  • Because TcMalloc requires Abseil, a CMake installation of abseil must be present on the system and set with the cmake variable absl_DIR.

@google-cla
Copy link

google-cla bot commented Nov 2, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Nov 2, 2021
@craffael
Copy link
Author

craffael commented Nov 2, 2021

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Nov 2, 2021
)

set(LOCAL_GENERATED_INCLUDE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/lib)
install(EXPORT tcmallocTargets DESTINATION ${config_install_dir} NAMESPACE tcmalloc::)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
install(EXPORT tcmallocTargets DESTINATION ${config_install_dir} NAMESPACE tcmalloc::)
install(EXPORT ${PROJECT_NAME}Targets DESTINATION ${config_install_dir} NAMESPACE tcmalloc::)

ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(FILES ${TCMALLOC_CC_LIB_HDRS} DESTINATION "include/tcmalloc")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
install(FILES ${TCMALLOC_CC_LIB_HDRS} DESTINATION "include/tcmalloc")
install(FILES ${TCMALLOC_CC_LIB_HDRS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tcmalloc")

@oontvoo
Copy link
Member

oontvoo commented Mar 15, 2022

Hi, any plan to move forward with this PR? @ckennelly Thanks!

@craffael
Copy link
Author

I'm currently on holidays. I will get back to you guys in about two weeks...

@leo-128t-liu
Copy link

@craffael Appreciate the work to put this together! Could you please also add the doc to show how to use the CMake to build a shared lib of tcmalloc?
Thanks!

@hdu-sdlzx
Copy link

@craffael still working on this PR?

@leo-128t-liu
Copy link

I have got it working and integrated the latest branch with cmake. What issue are you running into? Your build environment should meet the requirements in CMake and g++ or clang version.

@yiguolei
Copy link

yiguolei commented Jan 6, 2023

Any progress on this PR? I want to use the latest TcMalloc in Apache Doris apache/doris#9580.

@ObiWahn
Copy link

ObiWahn commented Mar 14, 2023

https://github.com/ObiWahn/tcmalloc-cmake

If I look at your code, then I see that a lot needs to be done on my side :)

@stonebrakert6
Copy link

Any hope of seeing this? Bazel is too big of a requirement for someone who just wants

  1. To use this library
  2. generate compile_commands.json(compilation DB) for lsp
    I believe bazel doesn't natively support generation of compile_commands.json and bear doesn't work with bazel
    What do googlers use to generate compilation database(compile_commands.json) when your project is built using bazel ? Do you guys use this

@gtkramer
Copy link

@stonebrakert6 raises a good point--any project that wants to use this today MUST use Bazel, which is restrictive and sometimes not possible. Having a way to precompile this library and install it with lib and include folders would go a long way to making this easier to adopt in a project, especially if the project is also CMake based (as many MANY are).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants