Skip to content

Commit

Permalink
Switch from mallocng to jemalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin authored and john-preston committed Jul 1, 2021
1 parent cb92f08 commit 8d7772a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 49 deletions.
6 changes: 3 additions & 3 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ if (add_hunspell_library)
add_checked_subdirectory(hunspell)
endif()
add_checked_subdirectory(iconv)
if (LINUX)
add_checked_subdirectory(jemalloc)
endif()
add_checked_subdirectory(jpeg)
if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
add_checked_subdirectory(kwayland)
endif()
add_checked_subdirectory(lz4)
if (LINUX)
add_checked_subdirectory(mallocng)
endif()
add_checked_subdirectory(minizip)
if (LINUX)
add_checked_subdirectory(nimf_qt5)
Expand Down
51 changes: 51 additions & 0 deletions external/jemalloc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL

add_library(external_jemalloc INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_jemalloc ALIAS external_jemalloc)

This comment has been minimized.

Copy link
@Casperdamost

Casperdamost Jun 5, 2023

open_source


if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(JEMALLOC IMPORTED_TARGET jemalloc)

if (JEMALLOC_FOUND)
target_link_libraries(external_jemalloc INTERFACE PkgConfig::JEMALLOC)
endif()
endif()

if (NOT JEMALLOC_FOUND)
add_library(external_jemalloc_bundled STATIC IMPORTED GLOBAL)

include(ExternalProject)
ExternalProject_Add(jemalloc
URL https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2
CONFIGURE_COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/jemalloc-prefix/src/jemalloc" && ./configure
BUILD_IN_SOURCE 1
)

ExternalProject_Get_property(jemalloc SOURCE_DIR)
ExternalProject_Get_property(jemalloc BINARY_DIR)

file(MAKE_DIRECTORY "${SOURCE_DIR}/include")

set_target_properties(external_jemalloc_bundled PROPERTIES
IMPORTED_LOCATION "${BINARY_DIR}/lib/libjemalloc.a"
)

target_include_directories(external_jemalloc_bundled
INTERFACE
${SOURCE_DIR}/include
)

add_dependencies(external_jemalloc_bundled jemalloc)

target_link_libraries(external_jemalloc
INTERFACE
-Wl,--whole-archive
external_jemalloc_bundled
-Wl,--no-whole-archive
)
endif()
46 changes: 0 additions & 46 deletions external/mallocng/CMakeLists.txt

This file was deleted.

5 changes: 5 additions & 0 deletions options_linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ if (DESKTOP_APP_SPECIAL_TARGET)
endif()
endif()

target_link_libraries(common_options
INTERFACE
desktop-app::external_jemalloc
)

if (DESKTOP_APP_USE_PACKAGED)
find_library(ATOMIC_LIBRARY atomic)
else()
Expand Down

0 comments on commit 8d7772a

Please sign in to comment.