From 45be9e321517f15378982bd0353f80ab884679eb Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 19 May 2021 10:22:35 +0400 Subject: [PATCH] Link external_mallocng with --whole-archive. --- external/mallocng/CMakeLists.txt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/external/mallocng/CMakeLists.txt b/external/mallocng/CMakeLists.txt index cfe42a8..50b841c 100644 --- a/external/mallocng/CMakeLists.txt +++ b/external/mallocng/CMakeLists.txt @@ -4,13 +4,15 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL -add_library(external_mallocng STATIC) +add_library(external_mallocng INTERFACE IMPORTED GLOBAL) add_library(desktop-app::external_mallocng ALIAS external_mallocng) -init_target(external_mallocng "(external)") + +add_library(external_mallocng_bundled STATIC) +init_target(external_mallocng_bundled "(external)") set(mallocng_loc ${third_party_loc}/mallocng) -nice_target_sources(external_mallocng ${mallocng_loc} +nice_target_sources(external_mallocng_bundled ${mallocng_loc} PRIVATE malloc.c calloc.c @@ -24,18 +26,25 @@ PRIVATE glue.h ) -target_compile_options(external_mallocng +target_compile_options(external_mallocng_bundled PRIVATE -Wno-unused-value ) -target_include_directories(external_mallocng +target_include_directories(external_mallocng_bundled PRIVATE ${mallocng_loc} ) +target_link_libraries(external_mallocng +INTERFACE + -Wl,--whole-archive + external_mallocng_bundled + -Wl,--no-whole-archive +) + target_compile_options(external_mallocng -PUBLIC +INTERFACE -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc