How to link jemalloc shared library using cmake

For future generations, as this still comes up as one of the first links on Google.

Jemalloc comes with pkg-config setup, which can be used like this:

find_package(PkgConfig REQUIRED)
pkg_check_modules (JEMALLOC jemalloc)

pkg_search_module(JEMALLOC REQUIRED jemalloc)
include_directories(${JEMALLOC_INCLUDE_DIRS})

target_link_libraries(your_target_name ${JEMALLOC_LIBRARIES})