typesense/cmake/Jemalloc.cmake
Yonas Yanfa 34c4c0142f
Fix FreeBSD build by upgrading to latest jemalloc (#733)
* Update SHOWCASE.md (#661)

* Update README.md (#670)

* Update README.md

* Update README.md

* Update README.md

* Fix FreeBSD build by upgrading to latest jemalloc

Latest version of jemalloc as of September 21, 2022: https://github.com/jemalloc/jemalloc/releases/tag/5.3.0

Co-authored-by: Ray Jasson <48130098+rayjasson98@users.noreply.github.com>
Co-authored-by: rzrymiak <106121613+rzrymiak@users.noreply.github.com>
Co-authored-by: Jason Bosco <jason@typesense.org>
2022-09-22 08:52:07 +05:30

35 lines
1.4 KiB
CMake

# Download and build Jemalloc
set(JEMALLOC_VERSION 5.3.0)
set(JEMALLOC_NAME jemalloc-${JEMALLOC_VERSION})
set(JEMALLOC_TAR_PATH ${DEP_ROOT_DIR}/${JEMALLOC_NAME}.tar.bz2)
if(NOT EXISTS ${JEMALLOC_TAR_PATH})
message(STATUS "Downloading ${JEMALLOC_NAME}...")
file(DOWNLOAD https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/${JEMALLOC_NAME}.tar.bz2
${JEMALLOC_TAR_PATH})
endif()
if(NOT EXISTS ${DEP_ROOT_DIR}/${JEMALLOC_NAME})
message(STATUS "Extracting jemalloc...")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${JEMALLOC_TAR_PATH} WORKING_DIRECTORY ${DEP_ROOT_DIR})
endif()
if(NOT EXISTS ${DEP_ROOT_DIR}/${JEMALLOC_NAME}/Makefile)
message("Configuring jemalloc locally...")
# Builds with "--with-jemalloc-prefix=je_" on OSX
execute_process(COMMAND ./configure WORKING_DIRECTORY ${DEP_ROOT_DIR}/${JEMALLOC_NAME} RESULT_VARIABLE JEMALLOC_CONFIGURE)
if(NOT JEMALLOC_CONFIGURE EQUAL 0)
message(FATAL_ERROR "${JEMALLOC_NAME} configure failed!")
message("${RESULT_VARIABLE}")
endif()
endif()
if(NOT EXISTS ${DEP_ROOT_DIR}/${JEMALLOC_NAME}/lib/libjemalloc.a)
message("Building jemalloc locally...")
execute_process(COMMAND make "build_lib_static" WORKING_DIRECTORY ${DEP_ROOT_DIR}/${JEMALLOC_NAME})
if(NOT EXISTS ${DEP_ROOT_DIR}/${JEMALLOC_NAME}/lib/libjemalloc.a)
message(FATAL_ERROR "${JEMALLOC_NAME} build failed!")
endif()
endif()