Pass library as a part of -Wl argument in external_jemalloc
Or cmake can place the arguments in random order
This commit is contained in:
parent
b6515c543a
commit
0e6f53ced4
1 changed files with 14 additions and 20 deletions
34
external/jemalloc/CMakeLists.txt
vendored
34
external/jemalloc/CMakeLists.txt
vendored
|
|
@ -13,22 +13,23 @@ endif()
|
||||||
|
|
||||||
if (DESKTOP_APP_USE_PACKAGED)
|
if (DESKTOP_APP_USE_PACKAGED)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(JEMALLOC IMPORTED_TARGET jemalloc)
|
pkg_check_modules(JEMALLOC jemalloc)
|
||||||
|
|
||||||
if (JEMALLOC_FOUND)
|
if (JEMALLOC_FOUND)
|
||||||
target_link_libraries(external_jemalloc
|
target_include_directories(external_jemalloc SYSTEM
|
||||||
INTERFACE
|
INTERFACE
|
||||||
-Wl,--push-state,--no-as-needed
|
${JEMALLOC_INCLUDE_DIRS}
|
||||||
PkgConfig::JEMALLOC
|
|
||||||
${JEMALLOC_LINK_LIBRARIES}
|
|
||||||
-Wl,--pop-state
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_options(external_jemalloc
|
||||||
|
INTERFACE
|
||||||
|
-Wl,--push-state,--no-as-needed,${JEMALLOC_LINK_LIBRARIES},--pop-state
|
||||||
|
)
|
||||||
|
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(external_jemalloc_bundled STATIC IMPORTED)
|
|
||||||
|
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
ExternalProject_Add(jemalloc
|
ExternalProject_Add(jemalloc
|
||||||
URL ${third_party_loc}/jemalloc
|
URL ${third_party_loc}/jemalloc
|
||||||
|
|
@ -42,21 +43,14 @@ ExternalProject_Add(jemalloc
|
||||||
ExternalProject_Get_property(jemalloc SOURCE_DIR)
|
ExternalProject_Get_property(jemalloc SOURCE_DIR)
|
||||||
file(MAKE_DIRECTORY "${SOURCE_DIR}/include")
|
file(MAKE_DIRECTORY "${SOURCE_DIR}/include")
|
||||||
|
|
||||||
set_target_properties(external_jemalloc_bundled PROPERTIES
|
target_include_directories(external_jemalloc SYSTEM
|
||||||
IMPORTED_LOCATION "${SOURCE_DIR}/lib/libjemalloc.a"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(external_jemalloc_bundled SYSTEM
|
|
||||||
INTERFACE
|
INTERFACE
|
||||||
${SOURCE_DIR}/include
|
${SOURCE_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(external_jemalloc_bundled jemalloc-build)
|
target_link_options(external_jemalloc
|
||||||
|
|
||||||
target_link_libraries(external_jemalloc
|
|
||||||
INTERFACE
|
INTERFACE
|
||||||
-Wl,--push-state,--whole-archive
|
-Wl,--push-state,--whole-archive,${SOURCE_DIR}/lib/libjemalloc.a,--pop-state
|
||||||
$<TARGET_FILE:external_jemalloc_bundled>
|
|
||||||
-Wl,--pop-state
|
|
||||||
external_jemalloc_bundled
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_dependencies(external_jemalloc jemalloc-build)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue