Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
07982b72
Unverified
Commit
07982b72
authored
Jun 29, 2022
by
alexliyu7352
Committed by
GitHub
Jun 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
静态连接到jemalloc库: #1759
parent
d6224816
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
102 行增加
和
6 行删除
+102
-6
CMakeLists.txt
+12
-0
cmake/FindJEMALLOC.cmake
+39
-6
cmake/Jemalloc.cmake
+51
-0
没有找到文件。
CMakeLists.txt
查看文件 @
07982b72
...
...
@@ -22,6 +22,10 @@ endif()
set
(
CMAKE_CXX_STANDARD 11
)
#加载自定义模块
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
set
(
DEP_ROOT_DIR
${
CMAKE_SOURCE_DIR
}
/3rdpart/external-
${
CMAKE_SYSTEM_NAME
}
)
if
(
NOT EXISTS
${
DEP_ROOT_DIR
}
)
file
(
MAKE_DIRECTORY
${
DEP_ROOT_DIR
}
)
endif
()
find_program
(
CCACHE_FOUND ccache
)
if
(
CCACHE_FOUND
)
...
...
@@ -108,6 +112,7 @@ option(ENABLE_MSVC_MT "Enable MSVC Mt/Mtd lib" true)
option
(
ENABLE_API_STATIC_LIB
"Enable mk_api static lib"
false
)
option
(
USE_SOLUTION_FOLDERS
"Enable solution dir supported"
ON
)
option
(
ENABLE_SRT
"Enable SRT"
true
)
option
(
ENABLE_JEMALLOC_STATIC
"Enable static linking to the jemalloc library"
false
)
# ----------------------------------------------------------------------------
# Solution folders:
# ----------------------------------------------------------------------------
...
...
@@ -299,6 +304,13 @@ if (ENABLE_FFMPEG)
endif
()
if
(
ENABLE_JEMALLOC_STATIC
)
include
(
cmake/Jemalloc.cmake
)
include_directories
(
${
DEP_ROOT_DIR
}
/
${
JEMALLOC_NAME
}
/include/jemalloc
)
link_directories
(
${
DEP_ROOT_DIR
}
/
${
JEMALLOC_NAME
}
/lib
)
set
(
JEMALLOC_ROOT_DIR
"
${
DEP_ROOT_DIR
}
/
${
JEMALLOC_NAME
}
"
)
endif
()
#默认链接jemalloc库避免内存碎片
find_package
(
JEMALLOC QUIET
)
if
(
JEMALLOC_FOUND
)
...
...
cmake/FindJEMALLOC.cmake
查看文件 @
07982b72
find_path
(
JEMALLOC_INCLUDE_DIR
# Tries to find Jemalloc headers and libraries.
#
# Usage of this module as follows:
#
# find_package(jemalloc)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# JEMALLOC_ROOT_DIR Set this variable to the root installation of
# Jemalloc if the module has problems finding
# the proper installation path.
#
# Variables defined by this module:
#
# JEMALLOC_FOUND System has Jemalloc libs/headers
# JEMALLOC_LIBRARIES The Jemalloc libraries
# JEMALLOC_INCLUDE_DIR The location of Jemalloc headers
if
(
ENABLE_JEMALLOC_STATIC
)
find_path
(
JEMALLOC_INCLUDE_DIR
NAMES jemalloc.h
HINTS
${
JEMALLOC_ROOT_DIR
}
/include/jemalloc
NO_DEFAULT_PATH
)
find_library
(
JEMALLOC_LIBRARIES
NAMES jemalloc
HINTS
${
JEMALLOC_ROOT_DIR
}
/lib
NO_DEFAULT_PATH
)
else
()
find_path
(
JEMALLOC_INCLUDE_DIR
NAMES jemalloc/jemalloc.h
)
find_library
(
JEMALLOC_LIBRARY
find_library
(
JEMALLOC_LIBRARIES
NAMES jemalloc
)
set
(
JEMALLOC_INCLUDE_DIRS
${
JEMALLOC_INCLUDE_DIR
}
)
set
(
JEMALLOC_LIBRARIES
${
JEMALLOC_LIBRARY
}
)
endif
()
include
(
FindPackageHandleStandardArgs
)
find_package_handle_standard_args
(
JEMALLOC DEFAULT_MSG
JEMALLOC_LIBRARIES
JEMALLOC_INCLUDE_DIR
)
find_package_handle_standard_args
(
JEMALLOC DEFAULT_MSG JEMALLOC_LIBRARY JEMALLOC_INCLUDE_DIR
)
mark_as_advanced
(
JEMALLOC_ROOT_DIR
JEMALLOC_LIBRARIES
JEMALLOC_INCLUDE_DIR
)
cmake/Jemalloc.cmake
0 → 100644
查看文件 @
07982b72
# Download and build Jemalloc
set
(
JEMALLOC_VERSION 5.2.1
)
set
(
JEMALLOC_NAME jemalloc-
${
JEMALLOC_VERSION
}
)
set
(
JEMALLOC_TAR_PATH
${
DEP_ROOT_DIR
}
/
${
JEMALLOC_NAME
}
.tar.bz2
)
list
(
APPEND jemalloc_CONFIG_ARGS --disable-initial-exec-tls
)
list
(
APPEND jemalloc_CONFIG_ARGS --without-export
)
list
(
APPEND jemalloc_CONFIG_ARGS --disable-stats
)
list
(
APPEND jemalloc_CONFIG_ARGS --disable-libdl
)
#list(APPEND jemalloc_CONFIG_ARGS --disable-cxx)
#list(APPEND jemalloc_CONFIG_ARGS --with-jemalloc-prefix=je_)
#list(APPEND jemalloc_CONFIG_ARGS --enable-debug)
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
()
SET
(
DIR_CONTAINING_JEMALLOC
${
DEP_ROOT_DIR
}
/
${
JEMALLOC_NAME
}
)
if
(
NOT EXISTS
${
DIR_CONTAINING_JEMALLOC
}
)
message
(
STATUS
"Extracting jemalloc..."
)
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-E tar xzf
${
JEMALLOC_TAR_PATH
}
WORKING_DIRECTORY
${
DEP_ROOT_DIR
}
)
endif
()
if
(
NOT EXISTS
${
DIR_CONTAINING_JEMALLOC
}
/Makefile
)
message
(
"Configuring jemalloc locally..."
)
# Builds with "--with-jemalloc-prefix=je_" on OSX
# SET( BASH_COMMAND_TO_RUN bash -l -c "cd ${DIR_CONTAINING_JEMALLOC} && ./configure ${jemalloc_CONFIG_ARGS}" )
#
# EXECUTE_PROCESS( COMMAND ${BASH_COMMAND_TO_RUN}
# WORKING_DIRECTORY ${DIR_CONTAINING_JEMALLOC} RESULT_VARIABLE JEMALLOC_CONFIGURE )
execute_process
(
COMMAND ./configure
${
jemalloc_CONFIG_ARGS
}
WORKING_DIRECTORY
${
DIR_CONTAINING_JEMALLOC
}
RESULT_VARIABLE JEMALLOC_CONFIGURE
)
if
(
NOT JEMALLOC_CONFIGURE EQUAL 0
)
message
(
FATAL_ERROR
"
${
JEMALLOC_NAME
}
configure failed!"
)
message
(
"
${
JEMALLOC_CONFIGURE
}
"
)
endif
()
endif
()
if
(
NOT EXISTS
${
DIR_CONTAINING_JEMALLOC
}
/lib/libjemalloc.a
)
message
(
"Building jemalloc locally..."
)
execute_process
(
COMMAND make
"build_lib_static"
WORKING_DIRECTORY
${
DIR_CONTAINING_JEMALLOC
}
)
if
(
NOT EXISTS
${
DIR_CONTAINING_JEMALLOC
}
/lib/libjemalloc.a
)
message
(
FATAL_ERROR
"
${
JEMALLOC_NAME
}
build failed!"
)
endif
()
endif
()
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论